| 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 <memory> | 5 #include <memory> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| (...skipping 8606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8617 std::string redirect_location; | 8617 std::string redirect_location; |
| 8618 EXPECT_TRUE(headers->EnumerateHeader(NULL, "Location", &redirect_location)); | 8618 EXPECT_TRUE(headers->EnumerateHeader(NULL, "Location", &redirect_location)); |
| 8619 EXPECT_EQ(hsts_https_url.spec(), redirect_location); | 8619 EXPECT_EQ(hsts_https_url.spec(), redirect_location); |
| 8620 | 8620 |
| 8621 std::string received_cors_header; | 8621 std::string received_cors_header; |
| 8622 EXPECT_TRUE(headers->EnumerateHeader(NULL, "Access-Control-Allow-Origin", | 8622 EXPECT_TRUE(headers->EnumerateHeader(NULL, "Access-Control-Allow-Origin", |
| 8623 &received_cors_header)); | 8623 &received_cors_header)); |
| 8624 EXPECT_EQ(kOriginHeaderValue, received_cors_header); | 8624 EXPECT_EQ(kOriginHeaderValue, received_cors_header); |
| 8625 } | 8625 } |
| 8626 | 8626 |
| 8627 // Test that DHE-only servers fail with the expected dedicated error code. |
| 8628 TEST_F(HTTPSRequestTest, DHE) { |
| 8629 SpawnedTestServer::SSLOptions ssl_options; |
| 8630 ssl_options.key_exchanges = |
| 8631 SpawnedTestServer::SSLOptions::KEY_EXCHANGE_DHE_RSA; |
| 8632 SpawnedTestServer test_server( |
| 8633 SpawnedTestServer::TYPE_HTTPS, ssl_options, |
| 8634 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); |
| 8635 ASSERT_TRUE(test_server.Start()); |
| 8636 |
| 8637 TestDelegate d; |
| 8638 { |
| 8639 std::unique_ptr<URLRequest> r(default_context_.CreateRequest( |
| 8640 test_server.GetURL("/defaultresponse"), DEFAULT_PRIORITY, &d)); |
| 8641 |
| 8642 r->Start(); |
| 8643 EXPECT_TRUE(r->is_pending()); |
| 8644 |
| 8645 base::RunLoop().Run(); |
| 8646 |
| 8647 EXPECT_EQ(1, d.response_started_count()); |
| 8648 EXPECT_FALSE(r->status().is_success()); |
| 8649 EXPECT_EQ(URLRequestStatus::FAILED, r->status().status()); |
| 8650 EXPECT_EQ(ERR_SSL_OBSOLETE_CIPHER, r->status().error()); |
| 8651 } |
| 8652 } |
| 8653 |
| 8627 // This just tests the behaviour of GetHSTSRedirect(). End-to-end tests of HSTS | 8654 // This just tests the behaviour of GetHSTSRedirect(). End-to-end tests of HSTS |
| 8628 // are performed in net/websockets/websocket_end_to_end_test.cc. | 8655 // are performed in net/websockets/websocket_end_to_end_test.cc. |
| 8629 TEST(WebSocketURLRequestTest, HSTSApplied) { | 8656 TEST(WebSocketURLRequestTest, HSTSApplied) { |
| 8630 TestNetworkDelegate network_delegate; | 8657 TestNetworkDelegate network_delegate; |
| 8631 TransportSecurityState transport_security_state; | 8658 TransportSecurityState transport_security_state; |
| 8632 base::Time expiry = base::Time::Now() + base::TimeDelta::FromDays(1); | 8659 base::Time expiry = base::Time::Now() + base::TimeDelta::FromDays(1); |
| 8633 bool include_subdomains = false; | 8660 bool include_subdomains = false; |
| 8634 transport_security_state.AddHSTS("example.net", expiry, include_subdomains); | 8661 transport_security_state.AddHSTS("example.net", expiry, include_subdomains); |
| 8635 TestURLRequestContext context(true); | 8662 TestURLRequestContext context(true); |
| 8636 context.set_transport_security_state(&transport_security_state); | 8663 context.set_transport_security_state(&transport_security_state); |
| (...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10099 AddTestInterceptor()->set_main_intercept_job(std::move(job)); | 10126 AddTestInterceptor()->set_main_intercept_job(std::move(job)); |
| 10100 | 10127 |
| 10101 req->Start(); | 10128 req->Start(); |
| 10102 req->Cancel(); | 10129 req->Cancel(); |
| 10103 base::RunLoop().RunUntilIdle(); | 10130 base::RunLoop().RunUntilIdle(); |
| 10104 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); | 10131 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); |
| 10105 EXPECT_EQ(0, d.received_redirect_count()); | 10132 EXPECT_EQ(0, d.received_redirect_count()); |
| 10106 } | 10133 } |
| 10107 | 10134 |
| 10108 } // namespace net | 10135 } // namespace net |
| OLD | NEW |