OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // Empty username and empty password. | 29 // Empty username and empty password. |
30 { "", "", "Basic Og==" }, | 30 { "", "", "Basic Og==" }, |
31 }; | 31 }; |
32 GURL origin("http://www.example.com"); | 32 GURL origin("http://www.example.com"); |
33 HttpAuthHandlerBasic::Factory factory; | 33 HttpAuthHandlerBasic::Factory factory; |
34 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 34 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
35 std::string challenge = "Basic realm=\"Atlantis\""; | 35 std::string challenge = "Basic realm=\"Atlantis\""; |
36 scoped_ptr<HttpAuthHandler> basic; | 36 scoped_ptr<HttpAuthHandler> basic; |
37 EXPECT_EQ(OK, factory.CreateAuthHandlerFromString( | 37 EXPECT_EQ(OK, factory.CreateAuthHandlerFromString( |
38 challenge, HttpAuth::AUTH_SERVER, origin, BoundNetLog(), &basic)); | 38 challenge, HttpAuth::AUTH_SERVER, origin, BoundNetLog(), &basic)); |
39 AuthCredentials credentials(ASCIIToUTF16(tests[i].username), | 39 AuthCredentials credentials(base::ASCIIToUTF16(tests[i].username), |
40 ASCIIToUTF16(tests[i].password)); | 40 base::ASCIIToUTF16(tests[i].password)); |
41 HttpRequestInfo request_info; | 41 HttpRequestInfo request_info; |
42 std::string auth_token; | 42 std::string auth_token; |
43 int rv = basic->GenerateAuthToken(&credentials, &request_info, | 43 int rv = basic->GenerateAuthToken(&credentials, &request_info, |
44 CompletionCallback(), &auth_token); | 44 CompletionCallback(), &auth_token); |
45 EXPECT_EQ(OK, rv); | 45 EXPECT_EQ(OK, rv); |
46 EXPECT_STREQ(tests[i].expected_credentials, auth_token.c_str()); | 46 EXPECT_STREQ(tests[i].expected_credentials, auth_token.c_str()); |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 TEST(HttpAuthHandlerBasicTest, HandleAnotherChallenge) { | 50 TEST(HttpAuthHandlerBasicTest, HandleAnotherChallenge) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 scoped_ptr<HttpAuthHandler> basic; | 187 scoped_ptr<HttpAuthHandler> basic; |
188 int rv = factory.CreateAuthHandlerFromString( | 188 int rv = factory.CreateAuthHandlerFromString( |
189 challenge, HttpAuth::AUTH_SERVER, origin, BoundNetLog(), &basic); | 189 challenge, HttpAuth::AUTH_SERVER, origin, BoundNetLog(), &basic); |
190 EXPECT_EQ(tests[i].expected_rv, rv); | 190 EXPECT_EQ(tests[i].expected_rv, rv); |
191 if (rv == OK) | 191 if (rv == OK) |
192 EXPECT_EQ(tests[i].expected_realm, basic->realm()); | 192 EXPECT_EQ(tests[i].expected_realm, basic->realm()); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 } // namespace net | 196 } // namespace net |
OLD | NEW |