| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 tests[i].req_path, | 284 tests[i].req_path, |
| 285 ASCIIToUTF16(tests[i].username), | 285 ASCIIToUTF16(tests[i].username), |
| 286 ASCIIToUTF16(tests[i].password), | 286 ASCIIToUTF16(tests[i].password), |
| 287 tests[i].cnonce, | 287 tests[i].cnonce, |
| 288 tests[i].nonce_count); | 288 tests[i].nonce_count); |
| 289 | 289 |
| 290 EXPECT_STREQ(tests[i].expected_creds, creds.c_str()); | 290 EXPECT_STREQ(tests[i].expected_creds, creds.c_str()); |
| 291 } | 291 } |
| 292 } | 292 } |
| 293 | 293 |
| 294 TEST(HttpAuthHandlerDigest, HandleAnotherChallenge_Failed) { |
| 295 scoped_ptr<HttpAuthHandlerDigest::Factory> factory( |
| 296 new HttpAuthHandlerDigest::Factory()); |
| 297 scoped_ptr<HttpAuthHandler> handler; |
| 298 std::string default_challenge = |
| 299 "Digest realm=\"Oblivion\", nonce=\"nonce-value\""; |
| 300 GURL origin("intranet.google.com"); |
| 301 int rv = factory->CreateAuthHandlerFromString( |
| 302 default_challenge, HttpAuth::AUTH_SERVER, origin, BoundNetLog(), |
| 303 &handler); |
| 304 EXPECT_EQ(OK, rv); |
| 305 |
| 306 HttpAuth::ChallengeTokenizer tok_default(default_challenge.begin(), |
| 307 default_challenge.end()); |
| 308 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_REJECT, |
| 309 handler->HandleAnotherChallenge(&tok_default)); |
| 310 |
| 311 std::string stale_challenge = default_challenge + ", stale=true"; |
| 312 HttpAuth::ChallengeTokenizer tok_stale(stale_challenge.begin(), |
| 313 stale_challenge.end()); |
| 314 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_STALE, |
| 315 handler->HandleAnotherChallenge(&tok_stale)); |
| 316 |
| 317 std::string stale_false_challenge = default_challenge + ", stale=false"; |
| 318 HttpAuth::ChallengeTokenizer tok_stale_false(stale_false_challenge.begin(), |
| 319 stale_false_challenge.end()); |
| 320 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_REJECT, |
| 321 handler->HandleAnotherChallenge(&tok_stale_false)); |
| 322 } |
| 323 |
| 294 } // namespace net | 324 } // namespace net |
| OLD | NEW |