| OLD | NEW |
| 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" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 typedef ::testing::TestWithParam<HttpProxyType> TestWithHttpParam; | 42 typedef ::testing::TestWithParam<HttpProxyType> TestWithHttpParam; |
| 43 | 43 |
| 44 } // namespace | 44 } // namespace |
| 45 | 45 |
| 46 class HttpProxyClientSocketPoolSpdy3Test : public TestWithHttpParam { | 46 class HttpProxyClientSocketPoolSpdy3Test : public TestWithHttpParam { |
| 47 protected: | 47 protected: |
| 48 HttpProxyClientSocketPoolSpdy3Test() | 48 HttpProxyClientSocketPoolSpdy3Test() |
| 49 : ssl_config_(), | 49 : ssl_config_(), |
| 50 ignored_transport_socket_params_(new TransportSocketParams( | 50 ignored_transport_socket_params_( |
| 51 HostPortPair("proxy", 80), LOWEST, false, false, | 51 new TransportSocketParams(HostPortPair("proxy", 80), |
| 52 OnHostResolutionCallback())), | 52 LOWEST, |
| 53 ignored_ssl_socket_params_(new SSLSocketParams( | 53 false, |
| 54 ignored_transport_socket_params_, NULL, NULL, | 54 false, |
| 55 ProxyServer::SCHEME_DIRECT, HostPortPair("www.google.com", 443), | 55 OnHostResolutionCallback())), |
| 56 ssl_config_, 0, false, false)), | 56 ignored_ssl_socket_params_( |
| 57 new SSLSocketParams(ignored_transport_socket_params_, |
| 58 NULL, |
| 59 NULL, |
| 60 ProxyServer::SCHEME_DIRECT, |
| 61 HostPortPair("www.google.com", 443), |
| 62 ssl_config_, |
| 63 0, |
| 64 false, |
| 65 false)), |
| 57 tcp_histograms_("MockTCP"), | 66 tcp_histograms_("MockTCP"), |
| 58 transport_socket_pool_( | 67 transport_socket_pool_( |
| 59 kMaxSockets, kMaxSocketsPerGroup, | 68 kMaxSockets, |
| 69 kMaxSocketsPerGroup, |
| 60 &tcp_histograms_, | 70 &tcp_histograms_, |
| 61 session_deps_.deterministic_socket_factory.get()), | 71 session_deps_.deterministic_socket_factory.get()), |
| 62 ssl_histograms_("MockSSL"), | 72 ssl_histograms_("MockSSL"), |
| 63 ssl_socket_pool_(kMaxSockets, kMaxSocketsPerGroup, | 73 ssl_socket_pool_(kMaxSockets, |
| 74 kMaxSocketsPerGroup, |
| 64 &ssl_histograms_, | 75 &ssl_histograms_, |
| 65 session_deps_.host_resolver.get(), | 76 session_deps_.host_resolver.get(), |
| 66 session_deps_.cert_verifier.get(), | 77 session_deps_.cert_verifier.get(), |
| 67 NULL /* server_bound_cert_store */, | 78 NULL /* server_bound_cert_store */, |
| 68 NULL /* transport_security_state */, | 79 NULL /* transport_security_state */, |
| 69 "" /* ssl_session_cache_shard */, | 80 std::string() /* ssl_session_cache_shard */, |
| 70 session_deps_.deterministic_socket_factory.get(), | 81 session_deps_.deterministic_socket_factory.get(), |
| 71 &transport_socket_pool_, | 82 &transport_socket_pool_, |
| 72 NULL, | 83 NULL, |
| 73 NULL, | 84 NULL, |
| 74 session_deps_.ssl_config_service.get(), | 85 session_deps_.ssl_config_service.get(), |
| 75 BoundNetLog().net_log()), | 86 BoundNetLog().net_log()), |
| 76 session_(CreateNetworkSession()), | 87 session_(CreateNetworkSession()), |
| 77 http_proxy_histograms_("HttpProxyUnitTest"), | 88 http_proxy_histograms_("HttpProxyUnitTest"), |
| 78 ssl_data_(NULL), | 89 ssl_data_(NULL), |
| 79 data_(NULL), | 90 data_(NULL), |
| 80 pool_(kMaxSockets, kMaxSocketsPerGroup, | 91 pool_(kMaxSockets, |
| 92 kMaxSocketsPerGroup, |
| 81 &http_proxy_histograms_, | 93 &http_proxy_histograms_, |
| 82 NULL, | 94 NULL, |
| 83 &transport_socket_pool_, | 95 &transport_socket_pool_, |
| 84 &ssl_socket_pool_, | 96 &ssl_socket_pool_, |
| 85 NULL) { | 97 NULL) {} |
| 86 } | |
| 87 | 98 |
| 88 virtual ~HttpProxyClientSocketPoolSpdy3Test() { | 99 virtual ~HttpProxyClientSocketPoolSpdy3Test() { |
| 89 } | 100 } |
| 90 | 101 |
| 91 void AddAuthToCache() { | 102 void AddAuthToCache() { |
| 92 const base::string16 kFoo(ASCIIToUTF16("foo")); | 103 const base::string16 kFoo(ASCIIToUTF16("foo")); |
| 93 const base::string16 kBar(ASCIIToUTF16("bar")); | 104 const base::string16 kBar(ASCIIToUTF16("bar")); |
| 94 GURL proxy_url(GetParam() == HTTP ? "http://proxy" : "https://proxy:80"); | 105 GURL proxy_url(GetParam() == HTTP ? "http://proxy" : "https://proxy:80"); |
| 95 session_->http_auth_cache()->Add(proxy_url, | 106 session_->http_auth_cache()->Add(proxy_url, |
| 96 "MyRealm1", | 107 "MyRealm1", |
| (...skipping 11 matching lines...) Expand all Loading... |
| 108 | 119 |
| 109 scoped_refptr<SSLSocketParams> GetSslParams() { | 120 scoped_refptr<SSLSocketParams> GetSslParams() { |
| 110 if (GetParam() == HTTP) | 121 if (GetParam() == HTTP) |
| 111 return scoped_refptr<SSLSocketParams>(); | 122 return scoped_refptr<SSLSocketParams>(); |
| 112 return ignored_ssl_socket_params_; | 123 return ignored_ssl_socket_params_; |
| 113 } | 124 } |
| 114 | 125 |
| 115 // Returns the a correctly constructed HttpProxyParms | 126 // Returns the a correctly constructed HttpProxyParms |
| 116 // for the HTTP or HTTPS proxy. | 127 // for the HTTP or HTTPS proxy. |
| 117 scoped_refptr<HttpProxySocketParams> GetParams(bool tunnel) { | 128 scoped_refptr<HttpProxySocketParams> GetParams(bool tunnel) { |
| 118 return scoped_refptr<HttpProxySocketParams>( | 129 return scoped_refptr<HttpProxySocketParams>(new HttpProxySocketParams( |
| 119 new HttpProxySocketParams( | 130 GetTcpParams(), |
| 120 GetTcpParams(), | 131 GetSslParams(), |
| 121 GetSslParams(), | 132 GURL(tunnel ? "https://www.google.com/" : "http://www.google.com"), |
| 122 GURL(tunnel ? "https://www.google.com/" : "http://www.google.com"), | 133 std::string(), |
| 123 "", | 134 HostPortPair("www.google.com", tunnel ? 443 : 80), |
| 124 HostPortPair("www.google.com", tunnel ? 443 : 80), | 135 session_->http_auth_cache(), |
| 125 session_->http_auth_cache(), | 136 session_->http_auth_handler_factory(), |
| 126 session_->http_auth_handler_factory(), | 137 session_->spdy_session_pool(), |
| 127 session_->spdy_session_pool(), | 138 tunnel)); |
| 128 tunnel)); | |
| 129 } | 139 } |
| 130 | 140 |
| 131 scoped_refptr<HttpProxySocketParams> GetTunnelParams() { | 141 scoped_refptr<HttpProxySocketParams> GetTunnelParams() { |
| 132 return GetParams(true); | 142 return GetParams(true); |
| 133 } | 143 } |
| 134 | 144 |
| 135 scoped_refptr<HttpProxySocketParams> GetNoTunnelParams() { | 145 scoped_refptr<HttpProxySocketParams> GetNoTunnelParams() { |
| 136 return GetParams(false); | 146 return GetParams(false); |
| 137 } | 147 } |
| 138 | 148 |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 // Make sure Location header was included and correct. | 600 // Make sure Location header was included and correct. |
| 591 std::string location; | 601 std::string location; |
| 592 EXPECT_TRUE(headers->IsRedirect(&location)); | 602 EXPECT_TRUE(headers->IsRedirect(&location)); |
| 593 EXPECT_EQ(location, redirectTarget); | 603 EXPECT_EQ(location, redirectTarget); |
| 594 } | 604 } |
| 595 } | 605 } |
| 596 | 606 |
| 597 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. | 607 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. |
| 598 | 608 |
| 599 } // namespace net | 609 } // namespace net |
| OLD | NEW |