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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shlobj.h> | 9 #include <shlobj.h> |
10 #endif | 10 #endif |
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 // TODO(droger): Support TestServer on iOS (see http://crbug.com/148666). | 1407 // TODO(droger): Support TestServer on iOS (see http://crbug.com/148666). |
1408 #if !defined(OS_IOS) | 1408 #if !defined(OS_IOS) |
1409 // A subclass of TestServer that uses a statically-configured hostname. This is | 1409 // A subclass of TestServer that uses a statically-configured hostname. This is |
1410 // to work around mysterious failures in chrome_frame_net_tests. See: | 1410 // to work around mysterious failures in chrome_frame_net_tests. See: |
1411 // http://crbug.com/114369 | 1411 // http://crbug.com/114369 |
1412 class LocalHttpTestServer : public TestServer { | 1412 class LocalHttpTestServer : public TestServer { |
1413 public: | 1413 public: |
1414 explicit LocalHttpTestServer(const base::FilePath& document_root) | 1414 explicit LocalHttpTestServer(const base::FilePath& document_root) |
1415 : TestServer(TestServer::TYPE_HTTP, | 1415 : TestServer(TestServer::TYPE_HTTP, |
1416 ScopedCustomUrlRequestTestHttpHost::value(), | 1416 ScopedCustomUrlRequestTestHttpHost::value(), |
1417 document_root) {} | 1417 GetSourceRelativePath(document_root)) {} |
1418 LocalHttpTestServer() | 1418 LocalHttpTestServer() |
1419 : TestServer(TestServer::TYPE_HTTP, | 1419 : TestServer(TestServer::TYPE_HTTP, |
1420 ScopedCustomUrlRequestTestHttpHost::value(), | 1420 ScopedCustomUrlRequestTestHttpHost::value(), |
1421 base::FilePath()) {} | 1421 GetSourcePath()) {} |
1422 }; | 1422 }; |
1423 | 1423 |
1424 TEST_F(URLRequestTest, DelayedCookieCallback) { | 1424 TEST_F(URLRequestTest, DelayedCookieCallback) { |
1425 LocalHttpTestServer test_server; | 1425 LocalHttpTestServer test_server; |
1426 ASSERT_TRUE(test_server.Start()); | 1426 ASSERT_TRUE(test_server.Start()); |
1427 | 1427 |
1428 TestURLRequestContext context; | 1428 TestURLRequestContext context; |
1429 scoped_refptr<DelayedCookieMonster> delayed_cm = | 1429 scoped_refptr<DelayedCookieMonster> delayed_cm = |
1430 new DelayedCookieMonster(); | 1430 new DelayedCookieMonster(); |
1431 scoped_refptr<CookieStore> cookie_store = delayed_cm; | 1431 scoped_refptr<CookieStore> cookie_store = delayed_cm; |
(...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2942 } | 2942 } |
2943 } | 2943 } |
2944 | 2944 |
2945 // This test was disabled because it made chrome_frame_net_tests hang | 2945 // This test was disabled because it made chrome_frame_net_tests hang |
2946 // (see bug 102991). | 2946 // (see bug 102991). |
2947 TEST_F(URLRequestTestHTTP, DISABLED_HTTPSToHTTPRedirectNoRefererTest) { | 2947 TEST_F(URLRequestTestHTTP, DISABLED_HTTPSToHTTPRedirectNoRefererTest) { |
2948 ASSERT_TRUE(test_server_.Start()); | 2948 ASSERT_TRUE(test_server_.Start()); |
2949 | 2949 |
2950 TestServer https_test_server( | 2950 TestServer https_test_server( |
2951 TestServer::TYPE_HTTPS, TestServer::kLocalhost, | 2951 TestServer::TYPE_HTTPS, TestServer::kLocalhost, |
2952 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 2952 TestServer::GetSourceRelativePath( |
| 2953 base::FilePath(FILE_PATH_LITERAL("net/data/ssl")))); |
2953 ASSERT_TRUE(https_test_server.Start()); | 2954 ASSERT_TRUE(https_test_server.Start()); |
2954 | 2955 |
2955 // An https server is sent a request with an https referer, | 2956 // An https server is sent a request with an https referer, |
2956 // and responds with a redirect to an http url. The http | 2957 // and responds with a redirect to an http url. The http |
2957 // server should not be sent the referer. | 2958 // server should not be sent the referer. |
2958 GURL http_destination = test_server_.GetURL(""); | 2959 GURL http_destination = test_server_.GetURL(""); |
2959 TestDelegate d; | 2960 TestDelegate d; |
2960 URLRequest req(https_test_server.GetURL( | 2961 URLRequest req(https_test_server.GetURL( |
2961 "server-redirect?" + http_destination.spec()), &d, &default_context_); | 2962 "server-redirect?" + http_destination.spec()), &d, &default_context_); |
2962 req.set_referrer("https://www.referrer.com/"); | 2963 req.set_referrer("https://www.referrer.com/"); |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3386 header.clear(); | 3387 header.clear(); |
3387 EXPECT_TRUE(headers->GetNormalizedHeader("x-multiple-entries", &header)); | 3388 EXPECT_TRUE(headers->GetNormalizedHeader("x-multiple-entries", &header)); |
3388 EXPECT_EQ("a, b", header); | 3389 EXPECT_EQ("a, b", header); |
3389 } | 3390 } |
3390 | 3391 |
3391 TEST_F(URLRequestTestHTTP, ProcessSTS) { | 3392 TEST_F(URLRequestTestHTTP, ProcessSTS) { |
3392 TestServer::SSLOptions ssl_options; | 3393 TestServer::SSLOptions ssl_options; |
3393 TestServer https_test_server( | 3394 TestServer https_test_server( |
3394 TestServer::TYPE_HTTPS, | 3395 TestServer::TYPE_HTTPS, |
3395 ssl_options, | 3396 ssl_options, |
3396 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); | 3397 TestServer::GetSourceRelativePath( |
| 3398 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")))); |
3397 ASSERT_TRUE(https_test_server.Start()); | 3399 ASSERT_TRUE(https_test_server.Start()); |
3398 | 3400 |
3399 TestDelegate d; | 3401 TestDelegate d; |
3400 URLRequest request( | 3402 URLRequest request( |
3401 https_test_server.GetURL("files/hsts-headers.html"), | 3403 https_test_server.GetURL("files/hsts-headers.html"), |
3402 &d, | 3404 &d, |
3403 &default_context_); | 3405 &default_context_); |
3404 request.Start(); | 3406 request.Start(); |
3405 MessageLoop::current()->Run(); | 3407 MessageLoop::current()->Run(); |
3406 | 3408 |
3407 TransportSecurityState* security_state = | 3409 TransportSecurityState* security_state = |
3408 default_context_.transport_security_state(); | 3410 default_context_.transport_security_state(); |
3409 bool sni_available = true; | 3411 bool sni_available = true; |
3410 TransportSecurityState::DomainState domain_state; | 3412 TransportSecurityState::DomainState domain_state; |
3411 EXPECT_TRUE(security_state->GetDomainState( | 3413 EXPECT_TRUE(security_state->GetDomainState( |
3412 TestServer::kLocalhost, sni_available, &domain_state)); | 3414 TestServer::kLocalhost, sni_available, &domain_state)); |
3413 EXPECT_EQ(TransportSecurityState::DomainState::MODE_FORCE_HTTPS, | 3415 EXPECT_EQ(TransportSecurityState::DomainState::MODE_FORCE_HTTPS, |
3414 domain_state.upgrade_mode); | 3416 domain_state.upgrade_mode); |
3415 EXPECT_TRUE(domain_state.include_subdomains); | 3417 EXPECT_TRUE(domain_state.include_subdomains); |
3416 } | 3418 } |
3417 | 3419 |
3418 TEST_F(URLRequestTestHTTP, ProcessSTSOnce) { | 3420 TEST_F(URLRequestTestHTTP, ProcessSTSOnce) { |
3419 TestServer::SSLOptions ssl_options; | 3421 TestServer::SSLOptions ssl_options; |
3420 TestServer https_test_server( | 3422 TestServer https_test_server( |
3421 TestServer::TYPE_HTTPS, | 3423 TestServer::TYPE_HTTPS, |
3422 ssl_options, | 3424 ssl_options, |
3423 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); | 3425 TestServer::GetSourceRelativePath( |
| 3426 base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")))); |
3424 ASSERT_TRUE(https_test_server.Start()); | 3427 ASSERT_TRUE(https_test_server.Start()); |
3425 | 3428 |
3426 TestDelegate d; | 3429 TestDelegate d; |
3427 URLRequest request( | 3430 URLRequest request( |
3428 https_test_server.GetURL("files/hsts-multiple-headers.html"), | 3431 https_test_server.GetURL("files/hsts-multiple-headers.html"), |
3429 &d, | 3432 &d, |
3430 &default_context_); | 3433 &default_context_); |
3431 request.Start(); | 3434 request.Start(); |
3432 MessageLoop::current()->Run(); | 3435 MessageLoop::current()->Run(); |
3433 | 3436 |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4139 protected: | 4142 protected: |
4140 TestNetworkDelegate default_network_delegate_; // Must outlive URLRequest. | 4143 TestNetworkDelegate default_network_delegate_; // Must outlive URLRequest. |
4141 TestURLRequestContext default_context_; | 4144 TestURLRequestContext default_context_; |
4142 }; | 4145 }; |
4143 | 4146 |
4144 // This test was disabled because it made chrome_frame_net_tests hang | 4147 // This test was disabled because it made chrome_frame_net_tests hang |
4145 // (see bug 102991). | 4148 // (see bug 102991). |
4146 TEST_F(HTTPSRequestTest, DISABLED_HTTPSGetTest) { | 4149 TEST_F(HTTPSRequestTest, DISABLED_HTTPSGetTest) { |
4147 TestServer test_server(TestServer::TYPE_HTTPS, | 4150 TestServer test_server(TestServer::TYPE_HTTPS, |
4148 TestServer::kLocalhost, | 4151 TestServer::kLocalhost, |
4149 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 4152 TestServer::GetSourceRelativePath(base::FilePath( |
| 4153 FILE_PATH_LITERAL("net/data/ssl")))); |
4150 ASSERT_TRUE(test_server.Start()); | 4154 ASSERT_TRUE(test_server.Start()); |
4151 | 4155 |
4152 TestDelegate d; | 4156 TestDelegate d; |
4153 { | 4157 { |
4154 URLRequest r(test_server.GetURL(""), &d, &default_context_); | 4158 URLRequest r(test_server.GetURL(""), &d, &default_context_); |
4155 r.Start(); | 4159 r.Start(); |
4156 EXPECT_TRUE(r.is_pending()); | 4160 EXPECT_TRUE(r.is_pending()); |
4157 | 4161 |
4158 MessageLoop::current()->Run(); | 4162 MessageLoop::current()->Run(); |
4159 | 4163 |
4160 EXPECT_EQ(1, d.response_started_count()); | 4164 EXPECT_EQ(1, d.response_started_count()); |
4161 EXPECT_FALSE(d.received_data_before_response()); | 4165 EXPECT_FALSE(d.received_data_before_response()); |
4162 EXPECT_NE(0, d.bytes_received()); | 4166 EXPECT_NE(0, d.bytes_received()); |
4163 CheckSSLInfo(r.ssl_info()); | 4167 CheckSSLInfo(r.ssl_info()); |
4164 EXPECT_EQ(test_server.host_port_pair().host(), | 4168 EXPECT_EQ(test_server.host_port_pair().host(), |
4165 r.GetSocketAddress().host()); | 4169 r.GetSocketAddress().host()); |
4166 EXPECT_EQ(test_server.host_port_pair().port(), | 4170 EXPECT_EQ(test_server.host_port_pair().port(), |
4167 r.GetSocketAddress().port()); | 4171 r.GetSocketAddress().port()); |
4168 } | 4172 } |
4169 } | 4173 } |
4170 | 4174 |
4171 TEST_F(HTTPSRequestTest, HTTPSMismatchedTest) { | 4175 TEST_F(HTTPSRequestTest, HTTPSMismatchedTest) { |
4172 TestServer::SSLOptions ssl_options( | 4176 TestServer::SSLOptions ssl_options( |
4173 TestServer::SSLOptions::CERT_MISMATCHED_NAME); | 4177 TestServer::SSLOptions::CERT_MISMATCHED_NAME); |
4174 TestServer test_server(TestServer::TYPE_HTTPS, | 4178 TestServer test_server(TestServer::TYPE_HTTPS, |
4175 ssl_options, | 4179 ssl_options, |
4176 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 4180 TestServer::GetSourceRelativePath(base::FilePath( |
| 4181 FILE_PATH_LITERAL("net/data/ssl")))); |
4177 ASSERT_TRUE(test_server.Start()); | 4182 ASSERT_TRUE(test_server.Start()); |
4178 | 4183 |
4179 bool err_allowed = true; | 4184 bool err_allowed = true; |
4180 for (int i = 0; i < 2 ; i++, err_allowed = !err_allowed) { | 4185 for (int i = 0; i < 2 ; i++, err_allowed = !err_allowed) { |
4181 TestDelegate d; | 4186 TestDelegate d; |
4182 { | 4187 { |
4183 d.set_allow_certificate_errors(err_allowed); | 4188 d.set_allow_certificate_errors(err_allowed); |
4184 URLRequest r(test_server.GetURL(""), &d, &default_context_); | 4189 URLRequest r(test_server.GetURL(""), &d, &default_context_); |
4185 | 4190 |
4186 r.Start(); | 4191 r.Start(); |
(...skipping 12 matching lines...) Expand all Loading... |
4199 } | 4204 } |
4200 } | 4205 } |
4201 } | 4206 } |
4202 } | 4207 } |
4203 | 4208 |
4204 TEST_F(HTTPSRequestTest, HTTPSExpiredTest) { | 4209 TEST_F(HTTPSRequestTest, HTTPSExpiredTest) { |
4205 TestServer::SSLOptions ssl_options( | 4210 TestServer::SSLOptions ssl_options( |
4206 TestServer::SSLOptions::CERT_EXPIRED); | 4211 TestServer::SSLOptions::CERT_EXPIRED); |
4207 TestServer test_server(TestServer::TYPE_HTTPS, | 4212 TestServer test_server(TestServer::TYPE_HTTPS, |
4208 ssl_options, | 4213 ssl_options, |
4209 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 4214 TestServer::GetSourceRelativePath(base::FilePath( |
| 4215 FILE_PATH_LITERAL("net/data/ssl")))); |
4210 ASSERT_TRUE(test_server.Start()); | 4216 ASSERT_TRUE(test_server.Start()); |
4211 | 4217 |
4212 // Iterate from false to true, just so that we do the opposite of the | 4218 // Iterate from false to true, just so that we do the opposite of the |
4213 // previous test in order to increase test coverage. | 4219 // previous test in order to increase test coverage. |
4214 bool err_allowed = false; | 4220 bool err_allowed = false; |
4215 for (int i = 0; i < 2 ; i++, err_allowed = !err_allowed) { | 4221 for (int i = 0; i < 2 ; i++, err_allowed = !err_allowed) { |
4216 TestDelegate d; | 4222 TestDelegate d; |
4217 { | 4223 { |
4218 d.set_allow_certificate_errors(err_allowed); | 4224 d.set_allow_certificate_errors(err_allowed); |
4219 URLRequest r(test_server.GetURL(""), &d, &default_context_); | 4225 URLRequest r(test_server.GetURL(""), &d, &default_context_); |
(...skipping 26 matching lines...) Expand all Loading... |
4246 #endif | 4252 #endif |
4247 if (default_version_max <= SSL_PROTOCOL_VERSION_TLS1) | 4253 if (default_version_max <= SSL_PROTOCOL_VERSION_TLS1) |
4248 return; | 4254 return; |
4249 | 4255 |
4250 TestServer::SSLOptions ssl_options( | 4256 TestServer::SSLOptions ssl_options( |
4251 TestServer::SSLOptions::CERT_OK); | 4257 TestServer::SSLOptions::CERT_OK); |
4252 ssl_options.tls_intolerant = | 4258 ssl_options.tls_intolerant = |
4253 TestServer::SSLOptions::TLS_INTOLERANT_TLS1_1; | 4259 TestServer::SSLOptions::TLS_INTOLERANT_TLS1_1; |
4254 TestServer test_server(TestServer::TYPE_HTTPS, | 4260 TestServer test_server(TestServer::TYPE_HTTPS, |
4255 ssl_options, | 4261 ssl_options, |
4256 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 4262 TestServer::GetSourceRelativePath(base::FilePath( |
| 4263 FILE_PATH_LITERAL("net/data/ssl")))); |
4257 ASSERT_TRUE(test_server.Start()); | 4264 ASSERT_TRUE(test_server.Start()); |
4258 | 4265 |
4259 TestDelegate d; | 4266 TestDelegate d; |
4260 TestURLRequestContext context(true); | 4267 TestURLRequestContext context(true); |
4261 context.Init(); | 4268 context.Init(); |
4262 d.set_allow_certificate_errors(true); | 4269 d.set_allow_certificate_errors(true); |
4263 URLRequest r(test_server.GetURL(""), &d, &context); | 4270 URLRequest r(test_server.GetURL(""), &d, &context); |
4264 r.Start(); | 4271 r.Start(); |
4265 | 4272 |
4266 MessageLoop::current()->Run(); | 4273 MessageLoop::current()->Run(); |
4267 | 4274 |
4268 EXPECT_EQ(1, d.response_started_count()); | 4275 EXPECT_EQ(1, d.response_started_count()); |
4269 EXPECT_NE(0, d.bytes_received()); | 4276 EXPECT_NE(0, d.bytes_received()); |
4270 EXPECT_EQ(static_cast<int>(SSL_CONNECTION_VERSION_TLS1), | 4277 EXPECT_EQ(static_cast<int>(SSL_CONNECTION_VERSION_TLS1), |
4271 SSLConnectionStatusToVersion(r.ssl_info().connection_status)); | 4278 SSLConnectionStatusToVersion(r.ssl_info().connection_status)); |
4272 EXPECT_TRUE(r.ssl_info().connection_status & SSL_CONNECTION_VERSION_FALLBACK); | 4279 EXPECT_TRUE(r.ssl_info().connection_status & SSL_CONNECTION_VERSION_FALLBACK); |
4273 } | 4280 } |
4274 | 4281 |
4275 // This tests that a load of www.google.com with a certificate error sets | 4282 // This tests that a load of www.google.com with a certificate error sets |
4276 // the |certificate_errors_are_fatal| flag correctly. This flag will cause | 4283 // the |certificate_errors_are_fatal| flag correctly. This flag will cause |
4277 // the interstitial to be fatal. | 4284 // the interstitial to be fatal. |
4278 TEST_F(HTTPSRequestTest, HTTPSPreloadedHSTSTest) { | 4285 TEST_F(HTTPSRequestTest, HTTPSPreloadedHSTSTest) { |
4279 TestServer::SSLOptions ssl_options( | 4286 TestServer::SSLOptions ssl_options( |
4280 TestServer::SSLOptions::CERT_MISMATCHED_NAME); | 4287 TestServer::SSLOptions::CERT_MISMATCHED_NAME); |
4281 TestServer test_server(TestServer::TYPE_HTTPS, | 4288 TestServer test_server(TestServer::TYPE_HTTPS, |
4282 ssl_options, | 4289 ssl_options, |
4283 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 4290 TestServer::GetSourceRelativePath(base::FilePath( |
| 4291 FILE_PATH_LITERAL("net/data/ssl")))); |
4284 ASSERT_TRUE(test_server.Start()); | 4292 ASSERT_TRUE(test_server.Start()); |
4285 | 4293 |
4286 // We require that the URL be www.google.com in order to pick up the | 4294 // We require that the URL be www.google.com in order to pick up the |
4287 // preloaded HSTS entries in the TransportSecurityState. This means that we | 4295 // preloaded HSTS entries in the TransportSecurityState. This means that we |
4288 // have to use a MockHostResolver in order to direct www.google.com to the | 4296 // have to use a MockHostResolver in order to direct www.google.com to the |
4289 // testserver. By default, MockHostResolver maps all hosts to 127.0.0.1. | 4297 // testserver. By default, MockHostResolver maps all hosts to 127.0.0.1. |
4290 | 4298 |
4291 MockHostResolver host_resolver; | 4299 MockHostResolver host_resolver; |
4292 TestNetworkDelegate network_delegate; // Must outlive URLRequest. | 4300 TestNetworkDelegate network_delegate; // Must outlive URLRequest. |
4293 TestURLRequestContext context(true); | 4301 TestURLRequestContext context(true); |
(...skipping 22 matching lines...) Expand all Loading... |
4316 | 4324 |
4317 // This tests that cached HTTPS page loads do not cause any updates to the | 4325 // This tests that cached HTTPS page loads do not cause any updates to the |
4318 // TransportSecurityState. | 4326 // TransportSecurityState. |
4319 TEST_F(HTTPSRequestTest, HTTPSErrorsNoClobberTSSTest) { | 4327 TEST_F(HTTPSRequestTest, HTTPSErrorsNoClobberTSSTest) { |
4320 // The actual problem -- CERT_MISMATCHED_NAME in this case -- doesn't | 4328 // The actual problem -- CERT_MISMATCHED_NAME in this case -- doesn't |
4321 // matter. It just has to be any error. | 4329 // matter. It just has to be any error. |
4322 TestServer::SSLOptions ssl_options( | 4330 TestServer::SSLOptions ssl_options( |
4323 TestServer::SSLOptions::CERT_MISMATCHED_NAME); | 4331 TestServer::SSLOptions::CERT_MISMATCHED_NAME); |
4324 TestServer test_server(TestServer::TYPE_HTTPS, | 4332 TestServer test_server(TestServer::TYPE_HTTPS, |
4325 ssl_options, | 4333 ssl_options, |
4326 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 4334 TestServer::GetSourceRelativePath(base::FilePath( |
| 4335 FILE_PATH_LITERAL("net/data/ssl")))); |
4327 ASSERT_TRUE(test_server.Start()); | 4336 ASSERT_TRUE(test_server.Start()); |
4328 | 4337 |
4329 // We require that the URL be www.google.com in order to pick up the | 4338 // We require that the URL be www.google.com in order to pick up the |
4330 // preloaded and dynamic HSTS and public key pin entries in the | 4339 // preloaded and dynamic HSTS and public key pin entries in the |
4331 // TransportSecurityState. This means that we have to use a | 4340 // TransportSecurityState. This means that we have to use a |
4332 // MockHostResolver in order to direct www.google.com to the testserver. | 4341 // MockHostResolver in order to direct www.google.com to the testserver. |
4333 // By default, MockHostResolver maps all hosts to 127.0.0.1. | 4342 // By default, MockHostResolver maps all hosts to 127.0.0.1. |
4334 | 4343 |
4335 MockHostResolver host_resolver; | 4344 MockHostResolver host_resolver; |
4336 TestNetworkDelegate network_delegate; // Must outlive URLRequest. | 4345 TestNetworkDelegate network_delegate; // Must outlive URLRequest. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4375 domain_state.bad_static_spki_hashes)); | 4384 domain_state.bad_static_spki_hashes)); |
4376 } | 4385 } |
4377 | 4386 |
4378 // Make sure HSTS preserves a POST request's method and body. | 4387 // Make sure HSTS preserves a POST request's method and body. |
4379 TEST_F(HTTPSRequestTest, HSTSPreservesPosts) { | 4388 TEST_F(HTTPSRequestTest, HSTSPreservesPosts) { |
4380 static const char kData[] = "hello world"; | 4389 static const char kData[] = "hello world"; |
4381 | 4390 |
4382 TestServer::SSLOptions ssl_options(TestServer::SSLOptions::CERT_OK); | 4391 TestServer::SSLOptions ssl_options(TestServer::SSLOptions::CERT_OK); |
4383 TestServer test_server(TestServer::TYPE_HTTPS, | 4392 TestServer test_server(TestServer::TYPE_HTTPS, |
4384 ssl_options, | 4393 ssl_options, |
4385 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 4394 TestServer::GetSourceRelativePath(base::FilePath( |
| 4395 FILE_PATH_LITERAL("net/data/ssl")))); |
4386 ASSERT_TRUE(test_server.Start()); | 4396 ASSERT_TRUE(test_server.Start()); |
4387 | 4397 |
4388 | 4398 |
4389 // Per spec, TransportSecurityState expects a domain name, rather than an IP | 4399 // Per spec, TransportSecurityState expects a domain name, rather than an IP |
4390 // address, so a MockHostResolver is needed to redirect www.somewhere.com to | 4400 // address, so a MockHostResolver is needed to redirect www.somewhere.com to |
4391 // the TestServer. By default, MockHostResolver maps all hosts to 127.0.0.1. | 4401 // the TestServer. By default, MockHostResolver maps all hosts to 127.0.0.1. |
4392 MockHostResolver host_resolver; | 4402 MockHostResolver host_resolver; |
4393 | 4403 |
4394 // Force https for www.somewhere.com. | 4404 // Force https for www.somewhere.com. |
4395 TransportSecurityState transport_security_state; | 4405 TransportSecurityState transport_security_state; |
(...skipping 29 matching lines...) Expand all Loading... |
4425 EXPECT_EQ("POST", req.method()); | 4435 EXPECT_EQ("POST", req.method()); |
4426 EXPECT_EQ(kData, d.data_received()); | 4436 EXPECT_EQ(kData, d.data_received()); |
4427 } | 4437 } |
4428 | 4438 |
4429 TEST_F(HTTPSRequestTest, SSLv3Fallback) { | 4439 TEST_F(HTTPSRequestTest, SSLv3Fallback) { |
4430 TestServer::SSLOptions ssl_options( | 4440 TestServer::SSLOptions ssl_options( |
4431 TestServer::SSLOptions::CERT_OK); | 4441 TestServer::SSLOptions::CERT_OK); |
4432 ssl_options.tls_intolerant = TestServer::SSLOptions::TLS_INTOLERANT_ALL; | 4442 ssl_options.tls_intolerant = TestServer::SSLOptions::TLS_INTOLERANT_ALL; |
4433 TestServer test_server(TestServer::TYPE_HTTPS, | 4443 TestServer test_server(TestServer::TYPE_HTTPS, |
4434 ssl_options, | 4444 ssl_options, |
4435 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 4445 TestServer::GetSourceRelativePath(base::FilePath( |
| 4446 FILE_PATH_LITERAL("net/data/ssl")))); |
4436 ASSERT_TRUE(test_server.Start()); | 4447 ASSERT_TRUE(test_server.Start()); |
4437 | 4448 |
4438 TestDelegate d; | 4449 TestDelegate d; |
4439 TestURLRequestContext context(true); | 4450 TestURLRequestContext context(true); |
4440 context.Init(); | 4451 context.Init(); |
4441 d.set_allow_certificate_errors(true); | 4452 d.set_allow_certificate_errors(true); |
4442 URLRequest r(test_server.GetURL(""), &d, &context); | 4453 URLRequest r(test_server.GetURL(""), &d, &context); |
4443 r.Start(); | 4454 r.Start(); |
4444 | 4455 |
4445 MessageLoop::current()->Run(); | 4456 MessageLoop::current()->Run(); |
(...skipping 29 matching lines...) Expand all Loading... |
4475 // TODO(davidben): Test the rest of the code. Specifically, | 4486 // TODO(davidben): Test the rest of the code. Specifically, |
4476 // - Filtering which certificates to select. | 4487 // - Filtering which certificates to select. |
4477 // - Sending a certificate back. | 4488 // - Sending a certificate back. |
4478 // - Getting a certificate request in an SSL renegotiation sending the | 4489 // - Getting a certificate request in an SSL renegotiation sending the |
4479 // HTTP request. | 4490 // HTTP request. |
4480 TEST_F(HTTPSRequestTest, ClientAuthTest) { | 4491 TEST_F(HTTPSRequestTest, ClientAuthTest) { |
4481 TestServer::SSLOptions ssl_options; | 4492 TestServer::SSLOptions ssl_options; |
4482 ssl_options.request_client_certificate = true; | 4493 ssl_options.request_client_certificate = true; |
4483 TestServer test_server(TestServer::TYPE_HTTPS, | 4494 TestServer test_server(TestServer::TYPE_HTTPS, |
4484 ssl_options, | 4495 ssl_options, |
4485 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 4496 TestServer::GetSourceRelativePath(base::FilePath( |
| 4497 FILE_PATH_LITERAL("net/data/ssl")))); |
4486 ASSERT_TRUE(test_server.Start()); | 4498 ASSERT_TRUE(test_server.Start()); |
4487 | 4499 |
4488 SSLClientAuthTestDelegate d; | 4500 SSLClientAuthTestDelegate d; |
4489 { | 4501 { |
4490 URLRequest r(test_server.GetURL(""), &d, &default_context_); | 4502 URLRequest r(test_server.GetURL(""), &d, &default_context_); |
4491 | 4503 |
4492 r.Start(); | 4504 r.Start(); |
4493 EXPECT_TRUE(r.is_pending()); | 4505 EXPECT_TRUE(r.is_pending()); |
4494 | 4506 |
4495 MessageLoop::current()->Run(); | 4507 MessageLoop::current()->Run(); |
(...skipping 15 matching lines...) Expand all Loading... |
4511 } | 4523 } |
4512 } | 4524 } |
4513 | 4525 |
4514 TEST_F(HTTPSRequestTest, ResumeTest) { | 4526 TEST_F(HTTPSRequestTest, ResumeTest) { |
4515 // Test that we attempt a session resume when making two connections to the | 4527 // Test that we attempt a session resume when making two connections to the |
4516 // same host. | 4528 // same host. |
4517 TestServer::SSLOptions ssl_options; | 4529 TestServer::SSLOptions ssl_options; |
4518 ssl_options.record_resume = true; | 4530 ssl_options.record_resume = true; |
4519 TestServer test_server(TestServer::TYPE_HTTPS, | 4531 TestServer test_server(TestServer::TYPE_HTTPS, |
4520 ssl_options, | 4532 ssl_options, |
4521 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 4533 TestServer::GetSourceRelativePath(base::FilePath( |
| 4534 FILE_PATH_LITERAL("net/data/ssl")))); |
4522 ASSERT_TRUE(test_server.Start()); | 4535 ASSERT_TRUE(test_server.Start()); |
4523 | 4536 |
4524 SSLClientSocket::ClearSessionCache(); | 4537 SSLClientSocket::ClearSessionCache(); |
4525 | 4538 |
4526 { | 4539 { |
4527 TestDelegate d; | 4540 TestDelegate d; |
4528 URLRequest r( | 4541 URLRequest r( |
4529 test_server.GetURL("ssl-session-cache"), &d, &default_context_); | 4542 test_server.GetURL("ssl-session-cache"), &d, &default_context_); |
4530 | 4543 |
4531 r.Start(); | 4544 r.Start(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4579 } | 4592 } |
4580 } | 4593 } |
4581 | 4594 |
4582 TEST_F(HTTPSRequestTest, SSLSessionCacheShardTest) { | 4595 TEST_F(HTTPSRequestTest, SSLSessionCacheShardTest) { |
4583 // Test that sessions aren't resumed when the value of ssl_session_cache_shard | 4596 // Test that sessions aren't resumed when the value of ssl_session_cache_shard |
4584 // differs. | 4597 // differs. |
4585 TestServer::SSLOptions ssl_options; | 4598 TestServer::SSLOptions ssl_options; |
4586 ssl_options.record_resume = true; | 4599 ssl_options.record_resume = true; |
4587 TestServer test_server(TestServer::TYPE_HTTPS, | 4600 TestServer test_server(TestServer::TYPE_HTTPS, |
4588 ssl_options, | 4601 ssl_options, |
4589 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 4602 TestServer::GetSourceRelativePath(base::FilePath( |
| 4603 FILE_PATH_LITERAL("net/data/ssl")))); |
4590 ASSERT_TRUE(test_server.Start()); | 4604 ASSERT_TRUE(test_server.Start()); |
4591 | 4605 |
4592 SSLClientSocket::ClearSessionCache(); | 4606 SSLClientSocket::ClearSessionCache(); |
4593 | 4607 |
4594 { | 4608 { |
4595 TestDelegate d; | 4609 TestDelegate d; |
4596 URLRequest r( | 4610 URLRequest r( |
4597 test_server.GetURL("ssl-session-cache"), &d, &default_context_); | 4611 test_server.GetURL("ssl-session-cache"), &d, &default_context_); |
4598 | 4612 |
4599 r.Start(); | 4613 r.Start(); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4715 EnsureNSSHttpIOInit(); | 4729 EnsureNSSHttpIOInit(); |
4716 #endif | 4730 #endif |
4717 } | 4731 } |
4718 | 4732 |
4719 void DoConnection(const TestServer::SSLOptions& ssl_options, | 4733 void DoConnection(const TestServer::SSLOptions& ssl_options, |
4720 CertStatus* out_cert_status) { | 4734 CertStatus* out_cert_status) { |
4721 // We always overwrite out_cert_status. | 4735 // We always overwrite out_cert_status. |
4722 *out_cert_status = 0; | 4736 *out_cert_status = 0; |
4723 TestServer test_server(TestServer::TYPE_HTTPS, | 4737 TestServer test_server(TestServer::TYPE_HTTPS, |
4724 ssl_options, | 4738 ssl_options, |
4725 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 4739 TestServer::GetSourceRelativePath(base::FilePath( |
| 4740 FILE_PATH_LITERAL("net/data/ssl")))); |
4726 ASSERT_TRUE(test_server.Start()); | 4741 ASSERT_TRUE(test_server.Start()); |
4727 | 4742 |
4728 TestDelegate d; | 4743 TestDelegate d; |
4729 d.set_allow_certificate_errors(true); | 4744 d.set_allow_certificate_errors(true); |
4730 URLRequest r(test_server.GetURL(""), &d, &context_); | 4745 URLRequest r(test_server.GetURL(""), &d, &context_); |
4731 r.Start(); | 4746 r.Start(); |
4732 | 4747 |
4733 MessageLoop::current()->Run(); | 4748 MessageLoop::current()->Run(); |
4734 | 4749 |
4735 EXPECT_EQ(1, d.response_started_count()); | 4750 EXPECT_EQ(1, d.response_started_count()); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5009 EXPECT_FALSE(cert_status & CERT_STATUS_IS_EV); | 5024 EXPECT_FALSE(cert_status & CERT_STATUS_IS_EV); |
5010 EXPECT_FALSE(cert_status & CERT_STATUS_REV_CHECKING_ENABLED); | 5025 EXPECT_FALSE(cert_status & CERT_STATUS_REV_CHECKING_ENABLED); |
5011 } | 5026 } |
5012 #endif // !defined(OS_IOS) | 5027 #endif // !defined(OS_IOS) |
5013 | 5028 |
5014 #if !defined(DISABLE_FTP_SUPPORT) | 5029 #if !defined(DISABLE_FTP_SUPPORT) |
5015 class URLRequestTestFTP : public URLRequestTest { | 5030 class URLRequestTestFTP : public URLRequestTest { |
5016 public: | 5031 public: |
5017 URLRequestTestFTP() | 5032 URLRequestTestFTP() |
5018 : test_server_(TestServer::TYPE_FTP, TestServer::kLocalhost, | 5033 : test_server_(TestServer::TYPE_FTP, TestServer::kLocalhost, |
5019 base::FilePath()) { | 5034 TestServer::GetSourcePath()) { |
5020 } | 5035 } |
5021 | 5036 |
5022 protected: | 5037 protected: |
5023 TestServer test_server_; | 5038 TestServer test_server_; |
5024 }; | 5039 }; |
5025 | 5040 |
5026 // Make sure an FTP request using an unsafe ports fails. | 5041 // Make sure an FTP request using an unsafe ports fails. |
5027 TEST_F(URLRequestTestFTP, UnsafePort) { | 5042 TEST_F(URLRequestTestFTP, UnsafePort) { |
5028 ASSERT_TRUE(test_server_.Start()); | 5043 ASSERT_TRUE(test_server_.Start()); |
5029 | 5044 |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5367 | 5382 |
5368 EXPECT_FALSE(r.is_pending()); | 5383 EXPECT_FALSE(r.is_pending()); |
5369 EXPECT_EQ(1, d->response_started_count()); | 5384 EXPECT_EQ(1, d->response_started_count()); |
5370 EXPECT_FALSE(d->received_data_before_response()); | 5385 EXPECT_FALSE(d->received_data_before_response()); |
5371 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 5386 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
5372 } | 5387 } |
5373 } | 5388 } |
5374 #endif // !defined(DISABLE_FTP_SUPPORT) | 5389 #endif // !defined(DISABLE_FTP_SUPPORT) |
5375 | 5390 |
5376 } // namespace net | 5391 } // namespace net |
OLD | NEW |