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

Unified Diff: net/url_request/url_request_unittest.cc

Issue 1066613002: Revert of Don't process HSTS/HPKP headers when host is an IP address (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | net/websockets/websocket_end_to_end_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_unittest.cc
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index 3f0e184fad7e458889e6e149375cd74894532d89..cfcb54e368428e9c33b975b6fb5350ed83463133 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -2574,7 +2574,7 @@
TestDelegate d;
scoped_ptr<URLRequest> req(default_context_.CreateRequest(
test_server.GetURL("echoheader?Cookie"), DEFAULT_PRIORITY, &d));
- req->set_first_party_for_cookies(test_server.GetURL(std::string()));
+ req->set_first_party_for_cookies(test_server.GetURL(""));
req->Start();
base::RunLoop().Run();
@@ -2634,7 +2634,7 @@
TestDelegate d;
scoped_ptr<URLRequest> req(default_context_.CreateRequest(
test_server.GetURL("echoheader?Cookie"), DEFAULT_PRIORITY, &d));
- req->set_first_party_for_cookies(test_server.GetURL(std::string()));
+ req->set_first_party_for_cookies(test_server.GetURL(""));
req->Start();
base::RunLoop().Run();
@@ -5258,17 +5258,13 @@
}
TEST_F(URLRequestTestHTTP, ProcessSTS) {
- SpawnedTestServer::SSLOptions ssl_options(
- SpawnedTestServer::SSLOptions::CERT_OK_FOR_LOCALHOST);
+ SpawnedTestServer::SSLOptions ssl_options;
SpawnedTestServer https_test_server(
SpawnedTestServer::TYPE_HTTPS,
ssl_options,
base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")));
ASSERT_TRUE(https_test_server.Start());
- std::string test_server_hostname =
- https_test_server.GetURL(std::string()).host();
-
TestDelegate d;
scoped_ptr<URLRequest> request(default_context_.CreateRequest(
https_test_server.GetURL("files/hsts-headers.html"), DEFAULT_PRIORITY,
@@ -5279,8 +5275,8 @@
TransportSecurityState* security_state =
default_context_.transport_security_state();
TransportSecurityState::DomainState domain_state;
- EXPECT_TRUE(security_state->GetDynamicDomainState(test_server_hostname,
- &domain_state));
+ EXPECT_TRUE(security_state->GetDynamicDomainState(
+ SpawnedTestServer::kLocalhost, &domain_state));
EXPECT_EQ(TransportSecurityState::DomainState::MODE_FORCE_HTTPS,
domain_state.sts.upgrade_mode);
EXPECT_TRUE(domain_state.sts.include_subdomains);
@@ -5292,32 +5288,6 @@
#endif
}
-TEST_F(URLRequestTestHTTP, STSNotProcessedOnIP) {
- SpawnedTestServer https_test_server(
- SpawnedTestServer::TYPE_HTTPS, SpawnedTestServer::SSLOptions(),
- base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")));
- ASSERT_TRUE(https_test_server.Start());
-
- // Make sure this test fails if the test server is changed to not
- // listen on an IP by default.
- ASSERT_TRUE(https_test_server.GetURL(std::string()).HostIsIPAddress());
- std::string test_server_hostname =
- https_test_server.GetURL(std::string()).host();
-
- TestDelegate d;
- scoped_ptr<URLRequest> request(default_context_.CreateRequest(
- https_test_server.GetURL("files/hsts-headers.html"), DEFAULT_PRIORITY,
- &d));
- request->Start();
- base::RunLoop().Run();
-
- TransportSecurityState* security_state =
- default_context_.transport_security_state();
- TransportSecurityState::DomainState domain_state;
- EXPECT_FALSE(security_state->GetDynamicDomainState(test_server_hostname,
- &domain_state));
-}
-
// Android's CertVerifyProc does not (yet) handle pins. Therefore, it will
// reject HPKP headers, and a test setting only HPKP headers will fail (no
// DomainState present because header rejected).
@@ -5330,17 +5300,13 @@
// Tests that enabling HPKP on a domain does not affect the HSTS
// validity/expiration.
TEST_F(URLRequestTestHTTP, MAYBE_ProcessPKP) {
- SpawnedTestServer::SSLOptions ssl_options(
- SpawnedTestServer::SSLOptions::CERT_OK_FOR_LOCALHOST);
+ SpawnedTestServer::SSLOptions ssl_options;
SpawnedTestServer https_test_server(
SpawnedTestServer::TYPE_HTTPS,
ssl_options,
base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")));
ASSERT_TRUE(https_test_server.Start());
- std::string test_server_hostname =
- https_test_server.GetURL(std::string()).host();
-
TestDelegate d;
scoped_ptr<URLRequest> request(default_context_.CreateRequest(
https_test_server.GetURL("files/hpkp-headers.html"), DEFAULT_PRIORITY,
@@ -5351,8 +5317,8 @@
TransportSecurityState* security_state =
default_context_.transport_security_state();
TransportSecurityState::DomainState domain_state;
- EXPECT_TRUE(security_state->GetDynamicDomainState(test_server_hostname,
- &domain_state));
+ EXPECT_TRUE(security_state->GetDynamicDomainState(
+ SpawnedTestServer::kLocalhost, &domain_state));
EXPECT_EQ(TransportSecurityState::DomainState::MODE_DEFAULT,
domain_state.sts.upgrade_mode);
EXPECT_FALSE(domain_state.sts.include_subdomains);
@@ -5361,43 +5327,14 @@
EXPECT_NE(domain_state.sts.expiry, domain_state.pkp.expiry);
}
-TEST_F(URLRequestTestHTTP, PKPNotProcessedOnIP) {
- SpawnedTestServer https_test_server(
- SpawnedTestServer::TYPE_HTTPS, SpawnedTestServer::SSLOptions(),
- base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")));
- ASSERT_TRUE(https_test_server.Start());
- // Make sure this test fails if the test server is changed to not
- // listen on an IP by default.
- ASSERT_TRUE(https_test_server.GetURL(std::string()).HostIsIPAddress());
- std::string test_server_hostname =
- https_test_server.GetURL(std::string()).host();
-
- TestDelegate d;
- scoped_ptr<URLRequest> request(default_context_.CreateRequest(
- https_test_server.GetURL("files/hpkp-headers.html"), DEFAULT_PRIORITY,
- &d));
- request->Start();
- base::RunLoop().Run();
-
- TransportSecurityState* security_state =
- default_context_.transport_security_state();
- TransportSecurityState::DomainState domain_state;
- EXPECT_FALSE(security_state->GetDynamicDomainState(test_server_hostname,
- &domain_state));
-}
-
TEST_F(URLRequestTestHTTP, ProcessSTSOnce) {
- SpawnedTestServer::SSLOptions ssl_options(
- SpawnedTestServer::SSLOptions::CERT_OK_FOR_LOCALHOST);
+ SpawnedTestServer::SSLOptions ssl_options;
SpawnedTestServer https_test_server(
SpawnedTestServer::TYPE_HTTPS,
ssl_options,
base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")));
ASSERT_TRUE(https_test_server.Start());
- std::string test_server_hostname =
- https_test_server.GetURL(std::string()).host();
-
TestDelegate d;
scoped_ptr<URLRequest> request(default_context_.CreateRequest(
https_test_server.GetURL("files/hsts-multiple-headers.html"),
@@ -5409,8 +5346,8 @@
TransportSecurityState* security_state =
default_context_.transport_security_state();
TransportSecurityState::DomainState domain_state;
- EXPECT_TRUE(security_state->GetDynamicDomainState(test_server_hostname,
- &domain_state));
+ EXPECT_TRUE(security_state->GetDynamicDomainState(
+ SpawnedTestServer::kLocalhost, &domain_state));
EXPECT_EQ(TransportSecurityState::DomainState::MODE_FORCE_HTTPS,
domain_state.sts.upgrade_mode);
EXPECT_FALSE(domain_state.sts.include_subdomains);
@@ -5418,17 +5355,13 @@
}
TEST_F(URLRequestTestHTTP, ProcessSTSAndPKP) {
- SpawnedTestServer::SSLOptions ssl_options(
- SpawnedTestServer::SSLOptions::CERT_OK_FOR_LOCALHOST);
+ SpawnedTestServer::SSLOptions ssl_options;
SpawnedTestServer https_test_server(
SpawnedTestServer::TYPE_HTTPS,
ssl_options,
base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")));
ASSERT_TRUE(https_test_server.Start());
- std::string test_server_hostname =
- https_test_server.GetURL(std::string()).host();
-
TestDelegate d;
scoped_ptr<URLRequest> request(default_context_.CreateRequest(
https_test_server.GetURL("files/hsts-and-hpkp-headers.html"),
@@ -5440,8 +5373,8 @@
TransportSecurityState* security_state =
default_context_.transport_security_state();
TransportSecurityState::DomainState domain_state;
- EXPECT_TRUE(security_state->GetDynamicDomainState(test_server_hostname,
- &domain_state));
+ EXPECT_TRUE(security_state->GetDynamicDomainState(
+ SpawnedTestServer::kLocalhost, &domain_state));
EXPECT_EQ(TransportSecurityState::DomainState::MODE_FORCE_HTTPS,
domain_state.sts.upgrade_mode);
#if defined(OS_ANDROID)
@@ -5461,17 +5394,13 @@
// Tests that when multiple HPKP headers are present, asserting different
// policies, that only the first such policy is processed.
TEST_F(URLRequestTestHTTP, ProcessSTSAndPKP2) {
- SpawnedTestServer::SSLOptions ssl_options(
- SpawnedTestServer::SSLOptions::CERT_OK_FOR_LOCALHOST);
+ SpawnedTestServer::SSLOptions ssl_options;
SpawnedTestServer https_test_server(
SpawnedTestServer::TYPE_HTTPS,
ssl_options,
base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")));
ASSERT_TRUE(https_test_server.Start());
- std::string test_server_hostname =
- https_test_server.GetURL(std::string()).host();
-
TestDelegate d;
scoped_ptr<URLRequest> request(default_context_.CreateRequest(
https_test_server.GetURL("files/hsts-and-hpkp-headers2.html"),
@@ -5482,8 +5411,8 @@
TransportSecurityState* security_state =
default_context_.transport_security_state();
TransportSecurityState::DomainState domain_state;
- EXPECT_TRUE(security_state->GetDynamicDomainState(test_server_hostname,
- &domain_state));
+ EXPECT_TRUE(security_state->GetDynamicDomainState(
+ SpawnedTestServer::kLocalhost, &domain_state));
EXPECT_EQ(TransportSecurityState::DomainState::MODE_FORCE_HTTPS,
domain_state.sts.upgrade_mode);
#if defined(OS_ANDROID)
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | net/websockets/websocket_end_to_end_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698