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

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

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: one more fix, content bound_net_log_ Created 4 years, 3 months 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
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 "net/http/http_auth.h" 5 #include "net/http/http_auth.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 18 matching lines...) Expand all
29 namespace { 29 namespace {
30 30
31 HttpAuthHandlerMock* CreateMockHandler(bool connection_based) { 31 HttpAuthHandlerMock* CreateMockHandler(bool connection_based) {
32 HttpAuthHandlerMock* auth_handler = new HttpAuthHandlerMock(); 32 HttpAuthHandlerMock* auth_handler = new HttpAuthHandlerMock();
33 auth_handler->set_connection_based(connection_based); 33 auth_handler->set_connection_based(connection_based);
34 std::string challenge_text = "Basic"; 34 std::string challenge_text = "Basic";
35 HttpAuthChallengeTokenizer challenge(challenge_text.begin(), 35 HttpAuthChallengeTokenizer challenge(challenge_text.begin(),
36 challenge_text.end()); 36 challenge_text.end());
37 GURL origin("www.example.com"); 37 GURL origin("www.example.com");
38 SSLInfo null_ssl_info; 38 SSLInfo null_ssl_info;
39 EXPECT_TRUE(auth_handler->InitFromChallenge( 39 EXPECT_TRUE(auth_handler->InitFromChallenge(&challenge, HttpAuth::AUTH_SERVER,
40 &challenge, HttpAuth::AUTH_SERVER, null_ssl_info, origin, BoundNetLog())); 40 null_ssl_info, origin,
41 NetLogWithSource()));
41 return auth_handler; 42 return auth_handler;
42 } 43 }
43 44
44 HttpResponseHeaders* HeadersFromResponseText(const std::string& response) { 45 HttpResponseHeaders* HeadersFromResponseText(const std::string& response) {
45 return new HttpResponseHeaders( 46 return new HttpResponseHeaders(
46 HttpUtil::AssembleRawHeaders(response.c_str(), response.length())); 47 HttpUtil::AssembleRawHeaders(response.c_str(), response.length()));
47 } 48 }
48 49
49 HttpAuth::AuthorizationResult HandleChallengeResponse( 50 HttpAuth::AuthorizationResult HandleChallengeResponse(
50 bool connection_based, 51 bool connection_based,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // Make a HttpResponseHeaders object. 132 // Make a HttpResponseHeaders object.
132 std::string headers_with_status_line("HTTP/1.1 401 Unauthorized\n"); 133 std::string headers_with_status_line("HTTP/1.1 401 Unauthorized\n");
133 headers_with_status_line += tests[i].headers; 134 headers_with_status_line += tests[i].headers;
134 scoped_refptr<HttpResponseHeaders> headers( 135 scoped_refptr<HttpResponseHeaders> headers(
135 HeadersFromResponseText(headers_with_status_line)); 136 HeadersFromResponseText(headers_with_status_line));
136 137
137 SSLInfo null_ssl_info; 138 SSLInfo null_ssl_info;
138 std::unique_ptr<HttpAuthHandler> handler; 139 std::unique_ptr<HttpAuthHandler> handler;
139 HttpAuth::ChooseBestChallenge(http_auth_handler_factory.get(), *headers, 140 HttpAuth::ChooseBestChallenge(http_auth_handler_factory.get(), *headers,
140 null_ssl_info, HttpAuth::AUTH_SERVER, origin, 141 null_ssl_info, HttpAuth::AUTH_SERVER, origin,
141 disabled_schemes, BoundNetLog(), &handler); 142 disabled_schemes, NetLogWithSource(),
143 &handler);
142 144
143 if (handler.get()) { 145 if (handler.get()) {
144 EXPECT_EQ(tests[i].challenge_scheme, handler->auth_scheme()); 146 EXPECT_EQ(tests[i].challenge_scheme, handler->auth_scheme());
145 EXPECT_STREQ(tests[i].challenge_realm, handler->realm().c_str()); 147 EXPECT_STREQ(tests[i].challenge_realm, handler->realm().c_str());
146 } else { 148 } else {
147 EXPECT_EQ(HttpAuth::AUTH_SCHEME_MAX, tests[i].challenge_scheme); 149 EXPECT_EQ(HttpAuth::AUTH_SCHEME_MAX, tests[i].challenge_scheme);
148 EXPECT_STREQ("", tests[i].challenge_realm); 150 EXPECT_STREQ("", tests[i].challenge_realm);
149 } 151 }
150 } 152 }
151 } 153 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 std::string name; 257 std::string name;
256 258
257 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_SERVER); 259 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_SERVER);
258 EXPECT_STREQ("Authorization", name.c_str()); 260 EXPECT_STREQ("Authorization", name.c_str());
259 261
260 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_PROXY); 262 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_PROXY);
261 EXPECT_STREQ("Proxy-Authorization", name.c_str()); 263 EXPECT_STREQ("Proxy-Authorization", name.c_str());
262 } 264 }
263 265
264 } // namespace net 266 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698