| 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 "testing/gtest/include/gtest/gtest.h" | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/string_util.h" |
| 8 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 9 #include "net/http/http_auth_handler_digest.h" | 10 #include "net/http/http_auth_handler_digest.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 12 |
| 11 namespace net { | 13 namespace net { |
| 12 | 14 |
| 13 TEST(HttpAuthHandlerDigestTest, ParseChallenge) { | 15 TEST(HttpAuthHandlerDigestTest, ParseChallenge) { |
| 14 static const struct { | 16 static const struct { |
| 15 // The challenge string. | 17 // The challenge string. |
| 16 const char* challenge; | 18 const char* challenge; |
| 17 // Expected return value of ParseChallenge. | 19 // Expected return value of ParseChallenge. |
| 18 bool parsed_success; | 20 bool parsed_success; |
| 19 // The expected values that were parsed. | 21 // The expected values that were parsed. |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 int rv = factory->CreateAuthHandlerFromString(tests[i].challenge, | 271 int rv = factory->CreateAuthHandlerFromString(tests[i].challenge, |
| 270 HttpAuth::AUTH_SERVER, | 272 HttpAuth::AUTH_SERVER, |
| 271 origin, | 273 origin, |
| 272 BoundNetLog(), | 274 BoundNetLog(), |
| 273 &handler); | 275 &handler); |
| 274 EXPECT_EQ(OK, rv); | 276 EXPECT_EQ(OK, rv); |
| 275 ASSERT_TRUE(handler != NULL); | 277 ASSERT_TRUE(handler != NULL); |
| 276 | 278 |
| 277 HttpAuthHandlerDigest* digest = | 279 HttpAuthHandlerDigest* digest = |
| 278 static_cast<HttpAuthHandlerDigest*>(handler.get()); | 280 static_cast<HttpAuthHandlerDigest*>(handler.get()); |
| 279 std::string creds = digest->AssembleCredentials(tests[i].req_method, | 281 std::string creds = |
| 280 tests[i].req_path, | 282 digest->AssembleCredentials(tests[i].req_method, |
| 281 tests[i].username, | 283 tests[i].req_path, |
| 282 tests[i].password, | 284 ASCIIToUTF16(tests[i].username), |
| 283 tests[i].cnonce, | 285 ASCIIToUTF16(tests[i].password), |
| 284 tests[i].nonce_count); | 286 tests[i].cnonce, |
| 287 tests[i].nonce_count); |
| 285 | 288 |
| 286 EXPECT_STREQ(tests[i].expected_creds, creds.c_str()); | 289 EXPECT_STREQ(tests[i].expected_creds, creds.c_str()); |
| 287 } | 290 } |
| 288 } | 291 } |
| 289 | 292 |
| 290 } // namespace net | 293 } // namespace net |
| OLD | NEW |