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

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

Issue 9582034: Fork SPDY/2 and SPDY/3 versions of our SPDY tests, in preparation for landing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix merge bug Created 8 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "net/base/ssl_config_service_defaults.h" 13 #include "net/base/ssl_config_service_defaults.h"
14 #include "net/base/test_completion_callback.h" 14 #include "net/base/test_completion_callback.h"
15 #include "net/http/http_auth_handler_factory.h" 15 #include "net/http/http_auth_handler_factory.h"
16 #include "net/http/http_network_session.h" 16 #include "net/http/http_network_session.h"
17 #include "net/http/http_proxy_client_socket.h" 17 #include "net/http/http_proxy_client_socket.h"
18 #include "net/http/http_server_properties_impl.h" 18 #include "net/http/http_server_properties_impl.h"
19 #include "net/proxy/proxy_service.h" 19 #include "net/proxy/proxy_service.h"
20 #include "net/socket/client_socket_handle.h" 20 #include "net/socket/client_socket_handle.h"
21 #include "net/socket/client_socket_pool_histograms.h" 21 #include "net/socket/client_socket_pool_histograms.h"
22 #include "net/socket/socket_test_util.h" 22 #include "net/socket/socket_test_util.h"
23 #include "net/spdy/spdy_protocol.h" 23 #include "net/spdy/spdy_protocol.h"
24 #include "net/spdy/spdy_test_util.h" 24 #include "net/spdy/spdy_test_util_spdy2.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 26
27 using namespace net::test_spdy2;
28
27 namespace net { 29 namespace net {
28 30
29 namespace { 31 namespace {
30 32
31 const int kMaxSockets = 32; 33 const int kMaxSockets = 32;
32 const int kMaxSocketsPerGroup = 6; 34 const int kMaxSocketsPerGroup = 6;
33 const char * const kAuthHeaders[] = { 35 const char * const kAuthHeaders[] = {
34 "proxy-authorization", "Basic Zm9vOmJhcg==" 36 "proxy-authorization", "Basic Zm9vOmJhcg=="
35 }; 37 };
36 const int kAuthHeadersSize = arraysize(kAuthHeaders) / 2; 38 const int kAuthHeadersSize = arraysize(kAuthHeaders) / 2;
37 39
38 enum HttpProxyType { 40 enum HttpProxyType {
39 HTTP, 41 HTTP,
40 HTTPS, 42 HTTPS,
41 SPDY 43 SPDY
42 }; 44 };
43 45
44 typedef ::testing::TestWithParam<HttpProxyType> TestWithHttpParam; 46 typedef ::testing::TestWithParam<HttpProxyType> TestWithHttpParam;
45 47
46 } // namespace 48 } // namespace
47 49
48 class HttpProxyClientSocketPoolTest : public TestWithHttpParam { 50 class HttpProxyClientSocketPoolSpdy2Test : public TestWithHttpParam {
49 protected: 51 protected:
50 HttpProxyClientSocketPoolTest() 52 HttpProxyClientSocketPoolSpdy2Test()
51 : ssl_config_(), 53 : ssl_config_(),
52 ignored_transport_socket_params_(new TransportSocketParams( 54 ignored_transport_socket_params_(new TransportSocketParams(
53 HostPortPair("proxy", 80), LOWEST, false, false)), 55 HostPortPair("proxy", 80), LOWEST, false, false)),
54 ignored_ssl_socket_params_(new SSLSocketParams( 56 ignored_ssl_socket_params_(new SSLSocketParams(
55 ignored_transport_socket_params_, NULL, NULL, 57 ignored_transport_socket_params_, NULL, NULL,
56 ProxyServer::SCHEME_DIRECT, HostPortPair("www.google.com", 443), 58 ProxyServer::SCHEME_DIRECT, HostPortPair("www.google.com", 443),
57 ssl_config_, 0, false, false)), 59 ssl_config_, 0, false, false)),
58 tcp_histograms_("MockTCP"), 60 tcp_histograms_("MockTCP"),
59 transport_socket_pool_( 61 transport_socket_pool_(
60 kMaxSockets, kMaxSocketsPerGroup, 62 kMaxSockets, kMaxSocketsPerGroup,
(...skipping 23 matching lines...) Expand all
84 ssl_data_(NULL), 86 ssl_data_(NULL),
85 data_(NULL), 87 data_(NULL),
86 pool_(kMaxSockets, kMaxSocketsPerGroup, 88 pool_(kMaxSockets, kMaxSocketsPerGroup,
87 &http_proxy_histograms_, 89 &http_proxy_histograms_,
88 NULL, 90 NULL,
89 &transport_socket_pool_, 91 &transport_socket_pool_,
90 &ssl_socket_pool_, 92 &ssl_socket_pool_,
91 NULL) { 93 NULL) {
92 } 94 }
93 95
94 virtual ~HttpProxyClientSocketPoolTest() { 96 virtual ~HttpProxyClientSocketPoolSpdy2Test() {
95 } 97 }
96 98
97 void AddAuthToCache() { 99 void AddAuthToCache() {
98 const string16 kFoo(ASCIIToUTF16("foo")); 100 const string16 kFoo(ASCIIToUTF16("foo"));
99 const string16 kBar(ASCIIToUTF16("bar")); 101 const string16 kBar(ASCIIToUTF16("bar"));
100 GURL proxy_url(GetParam() == HTTP ? "http://proxy" : "https://proxy:80"); 102 GURL proxy_url(GetParam() == HTTP ? "http://proxy" : "https://proxy:80");
101 session_->http_auth_cache()->Add(proxy_url, 103 session_->http_auth_cache()->Add(proxy_url,
102 "MyRealm1", 104 "MyRealm1",
103 HttpAuth::AUTH_SCHEME_BASIC, 105 HttpAuth::AUTH_SCHEME_BASIC,
104 "Basic realm=MyRealm1", 106 "Basic realm=MyRealm1",
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 ssl_data_.reset(new SSLSocketDataProvider(SYNCHRONOUS, OK)); 168 ssl_data_.reset(new SSLSocketDataProvider(SYNCHRONOUS, OK));
167 if (GetParam() == SPDY) { 169 if (GetParam() == SPDY) {
168 InitializeSpdySsl(); 170 InitializeSpdySsl();
169 } 171 }
170 socket_factory_.AddSSLSocketDataProvider(ssl_data_.get()); 172 socket_factory_.AddSSLSocketDataProvider(ssl_data_.get());
171 } 173 }
172 } 174 }
173 175
174 void InitializeSpdySsl() { 176 void InitializeSpdySsl() {
175 spdy::SpdyFramer::set_enable_compression_default(false); 177 spdy::SpdyFramer::set_enable_compression_default(false);
176 ssl_data_->SetNextProto(SSLClientSocket::kProtoSPDY21); 178 ssl_data_->SetNextProto(SSLClientSocket::kProtoSPDY2);
177 } 179 }
178 180
179 HttpNetworkSession* CreateNetworkSession() { 181 HttpNetworkSession* CreateNetworkSession() {
180 HttpNetworkSession::Params params; 182 HttpNetworkSession::Params params;
181 params.host_resolver = &host_resolver_; 183 params.host_resolver = &host_resolver_;
182 params.cert_verifier = &cert_verifier_; 184 params.cert_verifier = &cert_verifier_;
183 params.proxy_service = proxy_service_.get(); 185 params.proxy_service = proxy_service_.get();
184 params.client_socket_factory = &socket_factory_; 186 params.client_socket_factory = &socket_factory_;
185 params.ssl_config_service = ssl_config_service_; 187 params.ssl_config_service = ssl_config_service_;
186 params.http_auth_handler_factory = http_auth_handler_factory_.get(); 188 params.http_auth_handler_factory = http_auth_handler_factory_.get();
(...skipping 25 matching lines...) Expand all
212 scoped_ptr<SSLSocketDataProvider> ssl_data_; 214 scoped_ptr<SSLSocketDataProvider> ssl_data_;
213 scoped_refptr<DeterministicSocketData> data_; 215 scoped_refptr<DeterministicSocketData> data_;
214 HttpProxyClientSocketPool pool_; 216 HttpProxyClientSocketPool pool_;
215 ClientSocketHandle handle_; 217 ClientSocketHandle handle_;
216 TestCompletionCallback callback_; 218 TestCompletionCallback callback_;
217 }; 219 };
218 220
219 //----------------------------------------------------------------------------- 221 //-----------------------------------------------------------------------------
220 // All tests are run with three different proxy types: HTTP, HTTPS (non-SPDY) 222 // All tests are run with three different proxy types: HTTP, HTTPS (non-SPDY)
221 // and SPDY. 223 // and SPDY.
222 INSTANTIATE_TEST_CASE_P(HttpProxyClientSocketPoolTests, 224 INSTANTIATE_TEST_CASE_P(HttpProxyClientSocketPoolSpdy2Tests,
223 HttpProxyClientSocketPoolTest, 225 HttpProxyClientSocketPoolSpdy2Test,
224 ::testing::Values(HTTP, HTTPS, SPDY)); 226 ::testing::Values(HTTP, HTTPS, SPDY));
225 227
226 TEST_P(HttpProxyClientSocketPoolTest, NoTunnel) { 228 TEST_P(HttpProxyClientSocketPoolSpdy2Test, NoTunnel) {
227 Initialize(NULL, 0, NULL, 0, NULL, 0, NULL, 0); 229 Initialize(NULL, 0, NULL, 0, NULL, 0, NULL, 0);
228 230
229 int rv = handle_.Init("a", GetNoTunnelParams(), LOW, CompletionCallback(), 231 int rv = handle_.Init("a", GetNoTunnelParams(), LOW, CompletionCallback(),
230 &pool_, BoundNetLog()); 232 &pool_, BoundNetLog());
231 EXPECT_EQ(OK, rv); 233 EXPECT_EQ(OK, rv);
232 EXPECT_TRUE(handle_.is_initialized()); 234 EXPECT_TRUE(handle_.is_initialized());
233 ASSERT_TRUE(handle_.socket()); 235 ASSERT_TRUE(handle_.socket());
234 HttpProxyClientSocket* tunnel_socket = 236 HttpProxyClientSocket* tunnel_socket =
235 static_cast<HttpProxyClientSocket*>(handle_.socket()); 237 static_cast<HttpProxyClientSocket*>(handle_.socket());
236 EXPECT_TRUE(tunnel_socket->IsConnected()); 238 EXPECT_TRUE(tunnel_socket->IsConnected());
237 } 239 }
238 240
239 TEST_P(HttpProxyClientSocketPoolTest, NeedAuth) { 241 TEST_P(HttpProxyClientSocketPoolSpdy2Test, NeedAuth) {
240 MockWrite writes[] = { 242 MockWrite writes[] = {
241 MockWrite(ASYNC, 0, "CONNECT www.google.com:443 HTTP/1.1\r\n" 243 MockWrite(ASYNC, 0, "CONNECT www.google.com:443 HTTP/1.1\r\n"
242 "Host: www.google.com\r\n" 244 "Host: www.google.com\r\n"
243 "Proxy-Connection: keep-alive\r\n\r\n"), 245 "Proxy-Connection: keep-alive\r\n\r\n"),
244 }; 246 };
245 MockRead reads[] = { 247 MockRead reads[] = {
246 // No credentials. 248 // No credentials.
247 MockRead(ASYNC, 1, "HTTP/1.1 407 Proxy Authentication Required\r\n"), 249 MockRead(ASYNC, 1, "HTTP/1.1 407 Proxy Authentication Required\r\n"),
248 MockRead(ASYNC, 2, "Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), 250 MockRead(ASYNC, 2, "Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"),
249 MockRead(ASYNC, 3, "Content-Length: 10\r\n\r\n"), 251 MockRead(ASYNC, 3, "Content-Length: 10\r\n\r\n"),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 if (GetParam() == SPDY) { 299 if (GetParam() == SPDY) {
298 EXPECT_TRUE(tunnel_socket->IsConnected()); 300 EXPECT_TRUE(tunnel_socket->IsConnected());
299 EXPECT_TRUE(tunnel_socket->IsUsingSpdy()); 301 EXPECT_TRUE(tunnel_socket->IsUsingSpdy());
300 } else { 302 } else {
301 EXPECT_FALSE(tunnel_socket->IsConnected()); 303 EXPECT_FALSE(tunnel_socket->IsConnected());
302 EXPECT_FALSE(tunnel_socket->IsUsingSpdy()); 304 EXPECT_FALSE(tunnel_socket->IsUsingSpdy());
303 EXPECT_FALSE(tunnel_socket->IsUsingSpdy()); 305 EXPECT_FALSE(tunnel_socket->IsUsingSpdy());
304 } 306 }
305 } 307 }
306 308
307 TEST_P(HttpProxyClientSocketPoolTest, HaveAuth) { 309 TEST_P(HttpProxyClientSocketPoolSpdy2Test, HaveAuth) {
308 // It's pretty much impossible to make the SPDY case behave synchronously 310 // It's pretty much impossible to make the SPDY case behave synchronously
309 // so we skip this test for SPDY 311 // so we skip this test for SPDY
310 if (GetParam() == SPDY) 312 if (GetParam() == SPDY)
311 return; 313 return;
312 MockWrite writes[] = { 314 MockWrite writes[] = {
313 MockWrite(SYNCHRONOUS, 0, 315 MockWrite(SYNCHRONOUS, 0,
314 "CONNECT www.google.com:443 HTTP/1.1\r\n" 316 "CONNECT www.google.com:443 HTTP/1.1\r\n"
315 "Host: www.google.com\r\n" 317 "Host: www.google.com\r\n"
316 "Proxy-Connection: keep-alive\r\n" 318 "Proxy-Connection: keep-alive\r\n"
317 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), 319 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"),
318 }; 320 };
319 MockRead reads[] = { 321 MockRead reads[] = {
320 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 Connection Established\r\n\r\n"), 322 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 Connection Established\r\n\r\n"),
321 }; 323 };
322 324
323 Initialize(reads, arraysize(reads), writes, arraysize(writes), NULL, 0, 325 Initialize(reads, arraysize(reads), writes, arraysize(writes), NULL, 0,
324 NULL, 0); 326 NULL, 0);
325 AddAuthToCache(); 327 AddAuthToCache();
326 328
327 int rv = handle_.Init("a", GetTunnelParams(), LOW, callback_.callback(), 329 int rv = handle_.Init("a", GetTunnelParams(), LOW, callback_.callback(),
328 &pool_, BoundNetLog()); 330 &pool_, BoundNetLog());
329 EXPECT_EQ(OK, rv); 331 EXPECT_EQ(OK, rv);
330 EXPECT_TRUE(handle_.is_initialized()); 332 EXPECT_TRUE(handle_.is_initialized());
331 ASSERT_TRUE(handle_.socket()); 333 ASSERT_TRUE(handle_.socket());
332 HttpProxyClientSocket* tunnel_socket = 334 HttpProxyClientSocket* tunnel_socket =
333 static_cast<HttpProxyClientSocket*>(handle_.socket()); 335 static_cast<HttpProxyClientSocket*>(handle_.socket());
334 EXPECT_TRUE(tunnel_socket->IsConnected()); 336 EXPECT_TRUE(tunnel_socket->IsConnected());
335 } 337 }
336 338
337 TEST_P(HttpProxyClientSocketPoolTest, AsyncHaveAuth) { 339 TEST_P(HttpProxyClientSocketPoolSpdy2Test, AsyncHaveAuth) {
338 MockWrite writes[] = { 340 MockWrite writes[] = {
339 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" 341 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n"
340 "Host: www.google.com\r\n" 342 "Host: www.google.com\r\n"
341 "Proxy-Connection: keep-alive\r\n" 343 "Proxy-Connection: keep-alive\r\n"
342 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), 344 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"),
343 }; 345 };
344 MockRead reads[] = { 346 MockRead reads[] = {
345 MockRead(SYNCHRONOUS, "HTTP/1.1 200 Connection Established\r\n\r\n"), 347 MockRead(SYNCHRONOUS, "HTTP/1.1 200 Connection Established\r\n\r\n"),
346 }; 348 };
347 349
(...skipping 21 matching lines...) Expand all
369 371
370 data_->RunFor(2); 372 data_->RunFor(2);
371 EXPECT_EQ(OK, callback_.WaitForResult()); 373 EXPECT_EQ(OK, callback_.WaitForResult());
372 EXPECT_TRUE(handle_.is_initialized()); 374 EXPECT_TRUE(handle_.is_initialized());
373 ASSERT_TRUE(handle_.socket()); 375 ASSERT_TRUE(handle_.socket());
374 HttpProxyClientSocket* tunnel_socket = 376 HttpProxyClientSocket* tunnel_socket =
375 static_cast<HttpProxyClientSocket*>(handle_.socket()); 377 static_cast<HttpProxyClientSocket*>(handle_.socket());
376 EXPECT_TRUE(tunnel_socket->IsConnected()); 378 EXPECT_TRUE(tunnel_socket->IsConnected());
377 } 379 }
378 380
379 TEST_P(HttpProxyClientSocketPoolTest, TCPError) { 381 TEST_P(HttpProxyClientSocketPoolSpdy2Test, TCPError) {
380 if (GetParam() == SPDY) return; 382 if (GetParam() == SPDY) return;
381 data_ = new DeterministicSocketData(NULL, 0, NULL, 0); 383 data_ = new DeterministicSocketData(NULL, 0, NULL, 0);
382 data_->set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_CLOSED)); 384 data_->set_connect_data(MockConnect(ASYNC, ERR_CONNECTION_CLOSED));
383 385
384 socket_factory().AddSocketDataProvider(data_.get()); 386 socket_factory().AddSocketDataProvider(data_.get());
385 387
386 int rv = handle_.Init("a", GetTunnelParams(), LOW, callback_.callback(), 388 int rv = handle_.Init("a", GetTunnelParams(), LOW, callback_.callback(),
387 &pool_, BoundNetLog()); 389 &pool_, BoundNetLog());
388 EXPECT_EQ(ERR_IO_PENDING, rv); 390 EXPECT_EQ(ERR_IO_PENDING, rv);
389 EXPECT_FALSE(handle_.is_initialized()); 391 EXPECT_FALSE(handle_.is_initialized());
390 EXPECT_FALSE(handle_.socket()); 392 EXPECT_FALSE(handle_.socket());
391 393
392 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, callback_.WaitForResult()); 394 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, callback_.WaitForResult());
393 395
394 EXPECT_FALSE(handle_.is_initialized()); 396 EXPECT_FALSE(handle_.is_initialized());
395 EXPECT_FALSE(handle_.socket()); 397 EXPECT_FALSE(handle_.socket());
396 } 398 }
397 399
398 TEST_P(HttpProxyClientSocketPoolTest, SSLError) { 400 TEST_P(HttpProxyClientSocketPoolSpdy2Test, SSLError) {
399 if (GetParam() == HTTP) return; 401 if (GetParam() == HTTP) return;
400 data_ = new DeterministicSocketData(NULL, 0, NULL, 0); 402 data_ = new DeterministicSocketData(NULL, 0, NULL, 0);
401 data_->set_connect_data(MockConnect(ASYNC, OK)); 403 data_->set_connect_data(MockConnect(ASYNC, OK));
402 socket_factory().AddSocketDataProvider(data_.get()); 404 socket_factory().AddSocketDataProvider(data_.get());
403 405
404 ssl_data_.reset(new SSLSocketDataProvider(ASYNC, 406 ssl_data_.reset(new SSLSocketDataProvider(ASYNC,
405 ERR_CERT_AUTHORITY_INVALID)); 407 ERR_CERT_AUTHORITY_INVALID));
406 if (GetParam() == SPDY) { 408 if (GetParam() == SPDY) {
407 InitializeSpdySsl(); 409 InitializeSpdySsl();
408 } 410 }
409 socket_factory().AddSSLSocketDataProvider(ssl_data_.get()); 411 socket_factory().AddSSLSocketDataProvider(ssl_data_.get());
410 412
411 int rv = handle_.Init("a", GetTunnelParams(), LOW, callback_.callback(), 413 int rv = handle_.Init("a", GetTunnelParams(), LOW, callback_.callback(),
412 &pool_, BoundNetLog()); 414 &pool_, BoundNetLog());
413 EXPECT_EQ(ERR_IO_PENDING, rv); 415 EXPECT_EQ(ERR_IO_PENDING, rv);
414 EXPECT_FALSE(handle_.is_initialized()); 416 EXPECT_FALSE(handle_.is_initialized());
415 EXPECT_FALSE(handle_.socket()); 417 EXPECT_FALSE(handle_.socket());
416 418
417 EXPECT_EQ(ERR_PROXY_CERTIFICATE_INVALID, callback_.WaitForResult()); 419 EXPECT_EQ(ERR_PROXY_CERTIFICATE_INVALID, callback_.WaitForResult());
418 420
419 EXPECT_FALSE(handle_.is_initialized()); 421 EXPECT_FALSE(handle_.is_initialized());
420 EXPECT_FALSE(handle_.socket()); 422 EXPECT_FALSE(handle_.socket());
421 } 423 }
422 424
423 TEST_P(HttpProxyClientSocketPoolTest, SslClientAuth) { 425 TEST_P(HttpProxyClientSocketPoolSpdy2Test, SslClientAuth) {
424 if (GetParam() == HTTP) return; 426 if (GetParam() == HTTP) return;
425 data_ = new DeterministicSocketData(NULL, 0, NULL, 0); 427 data_ = new DeterministicSocketData(NULL, 0, NULL, 0);
426 data_->set_connect_data(MockConnect(ASYNC, OK)); 428 data_->set_connect_data(MockConnect(ASYNC, OK));
427 socket_factory().AddSocketDataProvider(data_.get()); 429 socket_factory().AddSocketDataProvider(data_.get());
428 430
429 ssl_data_.reset(new SSLSocketDataProvider(ASYNC, 431 ssl_data_.reset(new SSLSocketDataProvider(ASYNC,
430 ERR_SSL_CLIENT_AUTH_CERT_NEEDED)); 432 ERR_SSL_CLIENT_AUTH_CERT_NEEDED));
431 if (GetParam() == SPDY) { 433 if (GetParam() == SPDY) {
432 InitializeSpdySsl(); 434 InitializeSpdySsl();
433 } 435 }
434 socket_factory().AddSSLSocketDataProvider(ssl_data_.get()); 436 socket_factory().AddSSLSocketDataProvider(ssl_data_.get());
435 437
436 int rv = handle_.Init("a", GetTunnelParams(), LOW, callback_.callback(), 438 int rv = handle_.Init("a", GetTunnelParams(), LOW, callback_.callback(),
437 &pool_, BoundNetLog()); 439 &pool_, BoundNetLog());
438 EXPECT_EQ(ERR_IO_PENDING, rv); 440 EXPECT_EQ(ERR_IO_PENDING, rv);
439 EXPECT_FALSE(handle_.is_initialized()); 441 EXPECT_FALSE(handle_.is_initialized());
440 EXPECT_FALSE(handle_.socket()); 442 EXPECT_FALSE(handle_.socket());
441 443
442 EXPECT_EQ(ERR_SSL_CLIENT_AUTH_CERT_NEEDED, callback_.WaitForResult()); 444 EXPECT_EQ(ERR_SSL_CLIENT_AUTH_CERT_NEEDED, callback_.WaitForResult());
443 445
444 EXPECT_FALSE(handle_.is_initialized()); 446 EXPECT_FALSE(handle_.is_initialized());
445 EXPECT_FALSE(handle_.socket()); 447 EXPECT_FALSE(handle_.socket());
446 } 448 }
447 449
448 TEST_P(HttpProxyClientSocketPoolTest, TunnelUnexpectedClose) { 450 TEST_P(HttpProxyClientSocketPoolSpdy2Test, TunnelUnexpectedClose) {
449 MockWrite writes[] = { 451 MockWrite writes[] = {
450 MockWrite(ASYNC, 0, 452 MockWrite(ASYNC, 0,
451 "CONNECT www.google.com:443 HTTP/1.1\r\n" 453 "CONNECT www.google.com:443 HTTP/1.1\r\n"
452 "Host: www.google.com\r\n" 454 "Host: www.google.com\r\n"
453 "Proxy-Connection: keep-alive\r\n" 455 "Proxy-Connection: keep-alive\r\n"
454 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), 456 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"),
455 }; 457 };
456 MockRead reads[] = { 458 MockRead reads[] = {
457 MockRead(ASYNC, 1, "HTTP/1.1 200 Conn"), 459 MockRead(ASYNC, 1, "HTTP/1.1 200 Conn"),
458 MockRead(ASYNC, ERR_CONNECTION_CLOSED, 2), 460 MockRead(ASYNC, ERR_CONNECTION_CLOSED, 2),
(...skipping 17 matching lines...) Expand all
476 EXPECT_EQ(ERR_IO_PENDING, rv); 478 EXPECT_EQ(ERR_IO_PENDING, rv);
477 EXPECT_FALSE(handle_.is_initialized()); 479 EXPECT_FALSE(handle_.is_initialized());
478 EXPECT_FALSE(handle_.socket()); 480 EXPECT_FALSE(handle_.socket());
479 481
480 data_->RunFor(3); 482 data_->RunFor(3);
481 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback_.WaitForResult()); 483 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback_.WaitForResult());
482 EXPECT_FALSE(handle_.is_initialized()); 484 EXPECT_FALSE(handle_.is_initialized());
483 EXPECT_FALSE(handle_.socket()); 485 EXPECT_FALSE(handle_.socket());
484 } 486 }
485 487
486 TEST_P(HttpProxyClientSocketPoolTest, TunnelSetupError) { 488 TEST_P(HttpProxyClientSocketPoolSpdy2Test, TunnelSetupError) {
487 MockWrite writes[] = { 489 MockWrite writes[] = {
488 MockWrite(ASYNC, 0, 490 MockWrite(ASYNC, 0,
489 "CONNECT www.google.com:443 HTTP/1.1\r\n" 491 "CONNECT www.google.com:443 HTTP/1.1\r\n"
490 "Host: www.google.com\r\n" 492 "Host: www.google.com\r\n"
491 "Proxy-Connection: keep-alive\r\n" 493 "Proxy-Connection: keep-alive\r\n"
492 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), 494 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"),
493 }; 495 };
494 MockRead reads[] = { 496 MockRead reads[] = {
495 MockRead(ASYNC, 1, "HTTP/1.1 304 Not Modified\r\n\r\n"), 497 MockRead(ASYNC, 1, "HTTP/1.1 304 Not Modified\r\n\r\n"),
496 }; 498 };
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 // HTTPS or SPDY Proxy CONNECT responses are trustworthy 532 // HTTPS or SPDY Proxy CONNECT responses are trustworthy
531 EXPECT_EQ(ERR_HTTPS_PROXY_TUNNEL_RESPONSE, rv); 533 EXPECT_EQ(ERR_HTTPS_PROXY_TUNNEL_RESPONSE, rv);
532 EXPECT_TRUE(handle_.is_initialized()); 534 EXPECT_TRUE(handle_.is_initialized());
533 EXPECT_TRUE(handle_.socket()); 535 EXPECT_TRUE(handle_.socket());
534 } 536 }
535 } 537 }
536 538
537 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. 539 // It would be nice to also test the timeouts in HttpProxyClientSocketPool.
538 540
539 } // namespace net 541 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_proxy_client_socket_pool_spdy21_unittest.cc ('k') | net/http/http_proxy_client_socket_pool_spdy3_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698