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

Side by Side Diff: net/http/http_auth_controller_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_controller.h" 5 #include "net/http/http_auth_controller.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
9 #include "net/base/test_completion_callback.h" 9 #include "net/base/test_completion_callback.h"
10 #include "net/http/http_auth_cache.h" 10 #include "net/http/http_auth_cache.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // Runs an HttpAuthController with a single round mock auth handler 43 // Runs an HttpAuthController with a single round mock auth handler
44 // that returns |handler_rv| on token generation. The handler runs in 44 // that returns |handler_rv| on token generation. The handler runs in
45 // async if |run_mode| is RUN_HANDLER_ASYNC. Upon completion, the 45 // async if |run_mode| is RUN_HANDLER_ASYNC. Upon completion, the
46 // return value of the controller is tested against 46 // return value of the controller is tested against
47 // |expected_controller_rv|. |scheme_state| indicates whether the 47 // |expected_controller_rv|. |scheme_state| indicates whether the
48 // auth scheme used should be disabled after this run. 48 // auth scheme used should be disabled after this run.
49 void RunSingleRoundAuthTest(HandlerRunMode run_mode, 49 void RunSingleRoundAuthTest(HandlerRunMode run_mode,
50 int handler_rv, 50 int handler_rv,
51 int expected_controller_rv, 51 int expected_controller_rv,
52 SchemeState scheme_state) { 52 SchemeState scheme_state) {
53 BoundNetLog dummy_log; 53 NetLogWithSource dummy_log;
54 HttpAuthCache dummy_auth_cache; 54 HttpAuthCache dummy_auth_cache;
55 55
56 HttpRequestInfo request; 56 HttpRequestInfo request;
57 request.method = "GET"; 57 request.method = "GET";
58 request.url = GURL("http://example.com"); 58 request.url = GURL("http://example.com");
59 59
60 scoped_refptr<HttpResponseHeaders> headers(HeadersFromString( 60 scoped_refptr<HttpResponseHeaders> headers(HeadersFromString(
61 "HTTP/1.1 407\r\n" 61 "HTTP/1.1 407\r\n"
62 "Proxy-Authenticate: MOCK foo\r\n" 62 "Proxy-Authenticate: MOCK foo\r\n"
63 "\r\n")); 63 "\r\n"));
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 EXPECT_TRUE(result != OK || 157 EXPECT_TRUE(result != OK ||
158 !AllowsExplicitCredentials() || 158 !AllowsExplicitCredentials() ||
159 !credentials->Empty()); 159 !credentials->Empty());
160 return result; 160 return result;
161 } 161 }
162 162
163 private: 163 private:
164 HttpAuth::Scheme expected_scheme_; 164 HttpAuth::Scheme expected_scheme_;
165 }; 165 };
166 166
167 BoundNetLog dummy_log; 167 NetLogWithSource dummy_log;
168 HttpAuthCache dummy_auth_cache; 168 HttpAuthCache dummy_auth_cache;
169 HttpRequestInfo request; 169 HttpRequestInfo request;
170 request.method = "GET"; 170 request.method = "GET";
171 request.url = GURL("http://example.com"); 171 request.url = GURL("http://example.com");
172 172
173 HttpRequestHeaders request_headers; 173 HttpRequestHeaders request_headers;
174 scoped_refptr<HttpResponseHeaders> headers(HeadersFromString( 174 scoped_refptr<HttpResponseHeaders> headers(HeadersFromString(
175 "HTTP/1.1 401\r\n" 175 "HTTP/1.1 401\r\n"
176 "WWW-Authenticate: Mock\r\n" 176 "WWW-Authenticate: Mock\r\n"
177 "WWW-Authenticate: Basic\r\n" 177 "WWW-Authenticate: Basic\r\n"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 EXPECT_TRUE(controller->HaveAuth()); 234 EXPECT_TRUE(controller->HaveAuth());
235 EXPECT_TRUE(controller->IsAuthSchemeDisabled(HttpAuth::AUTH_SCHEME_MOCK)); 235 EXPECT_TRUE(controller->IsAuthSchemeDisabled(HttpAuth::AUTH_SCHEME_MOCK));
236 EXPECT_FALSE(controller->IsAuthSchemeDisabled(HttpAuth::AUTH_SCHEME_BASIC)); 236 EXPECT_FALSE(controller->IsAuthSchemeDisabled(HttpAuth::AUTH_SCHEME_BASIC));
237 237
238 // Should only succeed if we are using the AUTH_SCHEME_BASIC MockHandler. 238 // Should only succeed if we are using the AUTH_SCHEME_BASIC MockHandler.
239 EXPECT_EQ(OK, controller->MaybeGenerateAuthToken( 239 EXPECT_EQ(OK, controller->MaybeGenerateAuthToken(
240 &request, CompletionCallback(), dummy_log)); 240 &request, CompletionCallback(), dummy_log));
241 } 241 }
242 242
243 } // namespace net 243 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698