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

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

Issue 9316101: Revert 118950 - Allow chrome to handle 407 auth challenges to CONNECT requests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_proxy_client_socket_pool.cc ('k') | net/http/http_proxy_utils.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) 2012 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_proxy_client_socket_pool.h" 5 #include "net/http/http_proxy_client_socket_pool.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.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"
11 #include "net/base/mock_host_resolver.h" 11 #include "net/base/mock_host_resolver.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 return scoped_refptr<HttpProxySocketParams>( 124 return scoped_refptr<HttpProxySocketParams>(
125 new HttpProxySocketParams( 125 new HttpProxySocketParams(
126 GetTcpParams(), 126 GetTcpParams(),
127 GetSslParams(), 127 GetSslParams(),
128 GURL(tunnel ? "https://www.google.com/" : "http://www.google.com"), 128 GURL(tunnel ? "https://www.google.com/" : "http://www.google.com"),
129 "", 129 "",
130 HostPortPair("www.google.com", tunnel ? 443 : 80), 130 HostPortPair("www.google.com", tunnel ? 443 : 80),
131 session_->http_auth_cache(), 131 session_->http_auth_cache(),
132 session_->http_auth_handler_factory(), 132 session_->http_auth_handler_factory(),
133 session_->spdy_session_pool(), 133 session_->spdy_session_pool(),
134 tunnel, 134 tunnel));
135 base::Bind(&HttpProxyClientSocketPoolTest::OnNeedsProxyAuthCallback,
136 base::Unretained(this))));
137 } 135 }
138 136
139 scoped_refptr<HttpProxySocketParams> GetTunnelParams() { 137 scoped_refptr<HttpProxySocketParams> GetTunnelParams() {
140 return GetParams(true); 138 return GetParams(true);
141 } 139 }
142 140
143 scoped_refptr<HttpProxySocketParams> GetNoTunnelParams() { 141 scoped_refptr<HttpProxySocketParams> GetNoTunnelParams() {
144 return GetParams(false); 142 return GetParams(false);
145 } 143 }
146 144
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 params.host_resolver = &host_resolver_; 184 params.host_resolver = &host_resolver_;
187 params.cert_verifier = &cert_verifier_; 185 params.cert_verifier = &cert_verifier_;
188 params.proxy_service = proxy_service_.get(); 186 params.proxy_service = proxy_service_.get();
189 params.client_socket_factory = &socket_factory_; 187 params.client_socket_factory = &socket_factory_;
190 params.ssl_config_service = ssl_config_service_; 188 params.ssl_config_service = ssl_config_service_;
191 params.http_auth_handler_factory = http_auth_handler_factory_.get(); 189 params.http_auth_handler_factory = http_auth_handler_factory_.get();
192 params.http_server_properties = &http_server_properties_; 190 params.http_server_properties = &http_server_properties_;
193 return new HttpNetworkSession(params); 191 return new HttpNetworkSession(params);
194 } 192 }
195 193
196 void OnNeedsProxyAuthCallback(const HttpResponseInfo& response_info,
197 HttpAuthController* auth_controller,
198 CompletionCallback cb) {
199 // Don't add any auth, just run the callback
200 cb.Run(OK);
201 }
202
203
204 private: 194 private:
205 SSLConfig ssl_config_; 195 SSLConfig ssl_config_;
206 196
207 scoped_refptr<TransportSocketParams> ignored_transport_socket_params_; 197 scoped_refptr<TransportSocketParams> ignored_transport_socket_params_;
208 scoped_refptr<SSLSocketParams> ignored_ssl_socket_params_; 198 scoped_refptr<SSLSocketParams> ignored_ssl_socket_params_;
209 ClientSocketPoolHistograms tcp_histograms_; 199 ClientSocketPoolHistograms tcp_histograms_;
210 DeterministicMockClientSocketFactory socket_factory_; 200 DeterministicMockClientSocketFactory socket_factory_;
211 MockTransportClientSocketPool transport_socket_pool_; 201 MockTransportClientSocketPool transport_socket_pool_;
212 ClientSocketPoolHistograms ssl_histograms_; 202 ClientSocketPoolHistograms ssl_histograms_;
213 MockHostResolver host_resolver_; 203 MockHostResolver host_resolver_;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 MockRead(true, 2, "Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), 251 MockRead(true, 2, "Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"),
262 MockRead(true, 3, "Content-Length: 10\r\n\r\n"), 252 MockRead(true, 3, "Content-Length: 10\r\n\r\n"),
263 MockRead(true, 4, "0123456789"), 253 MockRead(true, 4, "0123456789"),
264 }; 254 };
265 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyConnect(NULL, 0, 1)); 255 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyConnect(NULL, 0, 1));
266 scoped_ptr<spdy::SpdyFrame> rst(ConstructSpdyRstStream(1, spdy::CANCEL)); 256 scoped_ptr<spdy::SpdyFrame> rst(ConstructSpdyRstStream(1, spdy::CANCEL));
267 MockWrite spdy_writes[] = { 257 MockWrite spdy_writes[] = {
268 CreateMockWrite(*req, 0, true), 258 CreateMockWrite(*req, 0, true),
269 CreateMockWrite(*rst, 2, true), 259 CreateMockWrite(*rst, 2, true),
270 }; 260 };
271 static const char* const kAuthChallenge[] = {
272 "status", "407 Proxy Authentication Required",
273 "version", "HTTP/1.1",
274 "proxy-authenticate", "Basic realm=\"MyRealm1\"",
275 };
276 scoped_ptr<spdy::SpdyFrame> resp( 261 scoped_ptr<spdy::SpdyFrame> resp(
277 ConstructSpdyControlFrame(NULL, 262 ConstructSpdySynReplyError(
278 0, 263 "407 Proxy Authentication Required", NULL, 0, 1));
279 false,
280 1,
281 LOWEST,
282 spdy::SYN_REPLY,
283 spdy::CONTROL_FLAG_NONE,
284 kAuthChallenge,
285 arraysize(kAuthChallenge)));
286 MockRead spdy_reads[] = { 264 MockRead spdy_reads[] = {
287 CreateMockWrite(*resp, 1, true), 265 CreateMockWrite(*resp, 1, true),
288 MockRead(true, 0, 3) 266 MockRead(true, 0, 3)
289 }; 267 };
290 268
291 Initialize(false, reads, arraysize(reads), writes, arraysize(writes), 269 Initialize(false, reads, arraysize(reads), writes, arraysize(writes),
292 spdy_reads, arraysize(spdy_reads), spdy_writes, 270 spdy_reads, arraysize(spdy_reads), spdy_writes,
293 arraysize(spdy_writes)); 271 arraysize(spdy_writes));
294 272
295 data_->StopAfter(4); 273 data_->StopAfter(4);
296 int rv = handle_.Init("a", GetTunnelParams(), LOW, callback_.callback(), 274 int rv = handle_.Init("a", GetTunnelParams(), LOW, callback_.callback(),
297 &pool_, BoundNetLog()); 275 &pool_, BoundNetLog());
298 EXPECT_EQ(ERR_IO_PENDING, rv); 276 EXPECT_EQ(ERR_IO_PENDING, rv);
299 EXPECT_FALSE(handle_.is_initialized()); 277 EXPECT_FALSE(handle_.is_initialized());
300 EXPECT_FALSE(handle_.socket()); 278 EXPECT_FALSE(handle_.socket());
301 279
302 data_->RunFor(GetParam() == SPDY ? 2 : 4); 280 data_->RunFor(4);
303 rv = callback_.WaitForResult(); 281 rv = callback_.WaitForResult();
304 EXPECT_EQ(ERR_PROXY_AUTH_REQUESTED, rv);
305 EXPECT_TRUE(handle_.is_initialized());
306 ASSERT_TRUE(handle_.socket());
307 if (GetParam() != SPDY) { 282 if (GetParam() != SPDY) {
283 EXPECT_EQ(ERR_PROXY_AUTH_REQUESTED, rv);
284 EXPECT_TRUE(handle_.is_initialized());
285 ASSERT_TRUE(handle_.socket());
308 HttpProxyClientSocket* tunnel_socket = 286 HttpProxyClientSocket* tunnel_socket =
309 static_cast<HttpProxyClientSocket*>(handle_.socket()); 287 static_cast<HttpProxyClientSocket*>(handle_.socket());
310 EXPECT_FALSE(tunnel_socket->IsConnected()); 288 EXPECT_FALSE(tunnel_socket->IsConnected());
311 EXPECT_FALSE(tunnel_socket->using_spdy()); 289 EXPECT_FALSE(tunnel_socket->using_spdy());
290 } else {
291 // Proxy auth is not really implemented for SPDY yet
292 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv);
293 EXPECT_FALSE(handle_.is_initialized());
294 EXPECT_FALSE(handle_.socket());
312 } 295 }
313 } 296 }
314 297
315 TEST_P(HttpProxyClientSocketPoolTest, HaveAuth) { 298 TEST_P(HttpProxyClientSocketPoolTest, HaveAuth) {
316 // It's pretty much impossible to make the SPDY case behave synchronously 299 // It's pretty much impossible to make the SPDY case behave synchronously
317 // so we skip this test for SPDY 300 // so we skip this test for SPDY
318 if (GetParam() == SPDY) 301 if (GetParam() == SPDY)
319 return; 302 return;
320 MockWrite writes[] = { 303 MockWrite writes[] = {
321 MockWrite(false, 0, 304 MockWrite(false, 0,
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 // HTTPS or SPDY Proxy CONNECT responses are trustworthy 521 // HTTPS or SPDY Proxy CONNECT responses are trustworthy
539 EXPECT_EQ(ERR_HTTPS_PROXY_TUNNEL_RESPONSE, rv); 522 EXPECT_EQ(ERR_HTTPS_PROXY_TUNNEL_RESPONSE, rv);
540 EXPECT_TRUE(handle_.is_initialized()); 523 EXPECT_TRUE(handle_.is_initialized());
541 EXPECT_TRUE(handle_.socket()); 524 EXPECT_TRUE(handle_.socket());
542 } 525 }
543 } 526 }
544 527
545 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. 528 // It would be nice to also test the timeouts in HttpProxyClientSocketPool.
546 529
547 } // namespace net 530 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_proxy_client_socket_pool.cc ('k') | net/http/http_proxy_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698