| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 scoped_ptr<HttpAuthHandlerDigest::Factory> factory( | 456 scoped_ptr<HttpAuthHandlerDigest::Factory> factory( |
| 457 new HttpAuthHandlerDigest::Factory()); | 457 new HttpAuthHandlerDigest::Factory()); |
| 458 scoped_ptr<HttpAuthHandler> handler; | 458 scoped_ptr<HttpAuthHandler> handler; |
| 459 std::string default_challenge = | 459 std::string default_challenge = |
| 460 "Digest realm=\"Oblivion\", nonce=\"nonce-value\""; | 460 "Digest realm=\"Oblivion\", nonce=\"nonce-value\""; |
| 461 GURL origin("intranet.google.com"); | 461 GURL origin("intranet.google.com"); |
| 462 int rv = factory->CreateAuthHandlerFromString( | 462 int rv = factory->CreateAuthHandlerFromString( |
| 463 default_challenge, HttpAuth::AUTH_SERVER, origin, BoundNetLog(), | 463 default_challenge, HttpAuth::AUTH_SERVER, origin, BoundNetLog(), |
| 464 &handler); | 464 &handler); |
| 465 EXPECT_EQ(OK, rv); | 465 EXPECT_EQ(OK, rv); |
| 466 | 466 ASSERT_TRUE(handler.get() != NULL); |
| 467 HttpAuth::ChallengeTokenizer tok_default(default_challenge.begin(), | 467 HttpAuth::ChallengeTokenizer tok_default(default_challenge.begin(), |
| 468 default_challenge.end()); | 468 default_challenge.end()); |
| 469 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_REJECT, | 469 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_REJECT, |
| 470 handler->HandleAnotherChallenge(&tok_default)); | 470 handler->HandleAnotherChallenge(&tok_default)); |
| 471 | 471 |
| 472 std::string stale_challenge = default_challenge + ", stale=true"; | 472 std::string stale_challenge = default_challenge + ", stale=true"; |
| 473 HttpAuth::ChallengeTokenizer tok_stale(stale_challenge.begin(), | 473 HttpAuth::ChallengeTokenizer tok_stale(stale_challenge.begin(), |
| 474 stale_challenge.end()); | 474 stale_challenge.end()); |
| 475 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_STALE, | 475 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_STALE, |
| 476 handler->HandleAnotherChallenge(&tok_stale)); | 476 handler->HandleAnotherChallenge(&tok_stale)); |
| 477 | 477 |
| 478 std::string stale_false_challenge = default_challenge + ", stale=false"; | 478 std::string stale_false_challenge = default_challenge + ", stale=false"; |
| 479 HttpAuth::ChallengeTokenizer tok_stale_false(stale_false_challenge.begin(), | 479 HttpAuth::ChallengeTokenizer tok_stale_false(stale_false_challenge.begin(), |
| 480 stale_false_challenge.end()); | 480 stale_false_challenge.end()); |
| 481 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_REJECT, | 481 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_REJECT, |
| 482 handler->HandleAnotherChallenge(&tok_stale_false)); | 482 handler->HandleAnotherChallenge(&tok_stale_false)); |
| 483 } | 483 } |
| 484 | 484 |
| 485 } // namespace net | 485 } // namespace net |
| OLD | NEW |