| 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 "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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 "xyz", | 56 "xyz", |
| 57 "", | 57 "", |
| 58 "", | 58 "", |
| 59 false, | 59 false, |
| 60 HttpAuthHandlerDigest::ALGORITHM_MD5, | 60 HttpAuthHandlerDigest::ALGORITHM_MD5, |
| 61 HttpAuthHandlerDigest::QOP_UNSPECIFIED | 61 HttpAuthHandlerDigest::QOP_UNSPECIFIED |
| 62 }, | 62 }, |
| 63 | 63 |
| 64 { // Check that md5-sess is recognized, as is single QOP | 64 { // Check that md5-sess is recognized, as is single QOP |
| 65 "Digest nonce=\"xyz\", algorithm=\"md5-sess\", " | 65 "Digest nonce=\"xyz\", algorithm=\"md5-sess\", " |
| 66 "realm=\"Oblivion\", qop=\"auth\"", | 66 "realm=\"Oblivion\", qop=\"auth\"", |
| 67 true, | 67 true, |
| 68 "Oblivion", | 68 "Oblivion", |
| 69 "xyz", | 69 "xyz", |
| 70 "", | 70 "", |
| 71 "", | 71 "", |
| 72 false, | 72 false, |
| 73 HttpAuthHandlerDigest::ALGORITHM_MD5_SESS, | 73 HttpAuthHandlerDigest::ALGORITHM_MD5_SESS, |
| 74 HttpAuthHandlerDigest::QOP_AUTH | 74 HttpAuthHandlerDigest::QOP_AUTH |
| 75 }, | 75 }, |
| 76 | 76 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 250 } |
| 251 }; | 251 }; |
| 252 GURL origin("http://www.example.com"); | 252 GURL origin("http://www.example.com"); |
| 253 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 253 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 254 scoped_refptr<HttpAuthHandlerDigest> digest = new HttpAuthHandlerDigest; | 254 scoped_refptr<HttpAuthHandlerDigest> digest = new HttpAuthHandlerDigest; |
| 255 std::string challenge = tests[i].challenge; | 255 std::string challenge = tests[i].challenge; |
| 256 HttpAuth::ChallengeTokenizer tok(challenge.begin(), challenge.end()); | 256 HttpAuth::ChallengeTokenizer tok(challenge.begin(), challenge.end()); |
| 257 EXPECT_TRUE(digest->InitFromChallenge(&tok, HttpAuth::AUTH_SERVER, origin)); | 257 EXPECT_TRUE(digest->InitFromChallenge(&tok, HttpAuth::AUTH_SERVER, origin)); |
| 258 | 258 |
| 259 std::string creds = digest->AssembleCredentials(tests[i].req_method, | 259 std::string creds = digest->AssembleCredentials(tests[i].req_method, |
| 260 tests[i].req_path, tests[i].username, tests[i].password, | 260 tests[i].req_path, |
| 261 tests[i].cnonce, tests[i].nonce_count); | 261 tests[i].username, |
| 262 tests[i].password, |
| 263 tests[i].cnonce, |
| 264 tests[i].nonce_count); |
| 262 | 265 |
| 263 EXPECT_STREQ(tests[i].expected_creds, creds.c_str()); | 266 EXPECT_STREQ(tests[i].expected_creds, creds.c_str()); |
| 264 } | 267 } |
| 265 } | 268 } |
| 266 | 269 |
| 267 } // namespace net | 270 } // namespace net |
| OLD | NEW |