Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: net/http/http_auth_handler_basic_unittest.cc

Issue 8340026: Use AuthCredentials throughout the network stack instead of username/password. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix comments Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_auth_handler_basic.cc ('k') | net/http/http_auth_handler_digest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 18 matching lines...) Expand all
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 string16 username(ASCIIToUTF16(tests[i].username)); 39 AuthCredentials credentials(ASCIIToUTF16(tests[i].username),
40 string16 password(ASCIIToUTF16(tests[i].password)); 40 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(&username, &password, &request_info, 43 int rv = basic->GenerateAuthToken(&credentials, &request_info,
44 NULL, &auth_token); 44 NULL, &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) {
51 static const struct { 51 static const struct {
52 const char* challenge; 52 const char* challenge;
53 HttpAuth::AuthorizationResult expected_rv; 53 HttpAuth::AuthorizationResult expected_rv;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « net/http/http_auth_handler_basic.cc ('k') | net/http/http_auth_handler_digest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698