| 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 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 HttpAuth::ChallengeTokenizer tok_stale(stale_challenge.begin(), | 546 HttpAuth::ChallengeTokenizer tok_stale(stale_challenge.begin(), |
| 547 stale_challenge.end()); | 547 stale_challenge.end()); |
| 548 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_STALE, | 548 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_STALE, |
| 549 handler->HandleAnotherChallenge(&tok_stale)); | 549 handler->HandleAnotherChallenge(&tok_stale)); |
| 550 | 550 |
| 551 std::string stale_false_challenge = default_challenge + ", stale=false"; | 551 std::string stale_false_challenge = default_challenge + ", stale=false"; |
| 552 HttpAuth::ChallengeTokenizer tok_stale_false(stale_false_challenge.begin(), | 552 HttpAuth::ChallengeTokenizer tok_stale_false(stale_false_challenge.begin(), |
| 553 stale_false_challenge.end()); | 553 stale_false_challenge.end()); |
| 554 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_REJECT, | 554 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_REJECT, |
| 555 handler->HandleAnotherChallenge(&tok_stale_false)); | 555 handler->HandleAnotherChallenge(&tok_stale_false)); |
| 556 |
| 557 std::string realm_change_challenge = |
| 558 "Digest realm=\"SomethingElse\", nonce=\"nonce-value2\""; |
| 559 HttpAuth::ChallengeTokenizer tok_realm_change(realm_change_challenge.begin(), |
| 560 realm_change_challenge.end()); |
| 561 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_DIFFERENT_REALM, |
| 562 handler->HandleAnotherChallenge(&tok_realm_change)); |
| 556 } | 563 } |
| 557 | 564 |
| 558 TEST(HttpAuthHandlerDigest, RespondToServerChallenge) { | 565 TEST(HttpAuthHandlerDigest, RespondToServerChallenge) { |
| 559 std::string auth_token; | 566 std::string auth_token; |
| 560 EXPECT_TRUE(RespondToChallenge( | 567 EXPECT_TRUE(RespondToChallenge( |
| 561 HttpAuth::AUTH_SERVER, | 568 HttpAuth::AUTH_SERVER, |
| 562 std::string(), | 569 std::string(), |
| 563 "http://www.example.com/path/to/resource", | 570 "http://www.example.com/path/to/resource", |
| 564 kSimpleChallenge, | 571 kSimpleChallenge, |
| 565 &auth_token)); | 572 &auth_token)); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 EXPECT_EQ("Digest username=\"foo\", realm=\"Oblivion\", " | 645 EXPECT_EQ("Digest username=\"foo\", realm=\"Oblivion\", " |
| 639 "nonce=\"nonce-value\", uri=\"/path/to/resource\", " | 646 "nonce=\"nonce-value\", uri=\"/path/to/resource\", " |
| 640 "response=\"5b1459beda5cee30d6ff9e970a69c0ea\", " | 647 "response=\"5b1459beda5cee30d6ff9e970a69c0ea\", " |
| 641 "opaque=\"opaque text\", " | 648 "opaque=\"opaque text\", " |
| 642 "qop=auth, nc=00000001, cnonce=\"client_nonce\"", | 649 "qop=auth, nc=00000001, cnonce=\"client_nonce\"", |
| 643 auth_token); | 650 auth_token); |
| 644 } | 651 } |
| 645 | 652 |
| 646 | 653 |
| 647 } // namespace net | 654 } // namespace net |
| OLD | NEW |