| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "testing/gtest/include/gtest/gtest.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "net/http/http_auth_handler_digest.h" | 8 #include "net/http/http_auth_handler_digest.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 "15c07961ed8575c4", // cnonce | 228 "15c07961ed8575c4", // cnonce |
| 229 1, // nc | 229 1, // nc |
| 230 | 230 |
| 231 // Authorization | 231 // Authorization |
| 232 "Digest username=\"USER\", realm=\"Baztastic\", " | 232 "Digest username=\"USER\", realm=\"Baztastic\", " |
| 233 "nonce=\"AAAAAAAA\", uri=\"/\", algorithm=MD5-sess, " | 233 "nonce=\"AAAAAAAA\", uri=\"/\", algorithm=MD5-sess, " |
| 234 "response=\"cbc1139821ee7192069580570c541a03\", " | 234 "response=\"cbc1139821ee7192069580570c541a03\", " |
| 235 "qop=auth, nc=00000001, cnonce=\"15c07961ed8575c4\"" | 235 "qop=auth, nc=00000001, cnonce=\"15c07961ed8575c4\"" |
| 236 } | 236 } |
| 237 }; | 237 }; |
| 238 GURL origin("http://www.example.com"); |
| 238 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 239 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 239 scoped_refptr<HttpAuthHandlerDigest> digest = new HttpAuthHandlerDigest; | 240 scoped_refptr<HttpAuthHandlerDigest> digest = new HttpAuthHandlerDigest; |
| 240 std::string challenge = tests[i].challenge; | 241 std::string challenge = tests[i].challenge; |
| 241 EXPECT_TRUE(digest->InitFromChallenge( | 242 EXPECT_TRUE(digest->InitFromChallenge( |
| 242 challenge.begin(), challenge.end(), HttpAuth::AUTH_SERVER)); | 243 challenge.begin(), challenge.end(), HttpAuth::AUTH_SERVER, origin)); |
| 243 | 244 |
| 244 std::string creds = digest->AssembleCredentials(tests[i].req_method, | 245 std::string creds = digest->AssembleCredentials(tests[i].req_method, |
| 245 tests[i].req_path, tests[i].username, tests[i].password, | 246 tests[i].req_path, tests[i].username, tests[i].password, |
| 246 tests[i].cnonce, tests[i].nonce_count); | 247 tests[i].cnonce, tests[i].nonce_count); |
| 247 | 248 |
| 248 EXPECT_STREQ(tests[i].expected_creds, creds.c_str()); | 249 EXPECT_STREQ(tests[i].expected_creds, creds.c_str()); |
| 249 } | 250 } |
| 250 } | 251 } |
| 251 | 252 |
| 252 } // namespace net | 253 } // namespace net |
| OLD | NEW |