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 6198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6209 request->Start(); | 6209 request->Start(); |
6210 base::RunLoop().Run(); | 6210 base::RunLoop().Run(); |
6211 | 6211 |
6212 TransportSecurityState* security_state = | 6212 TransportSecurityState* security_state = |
6213 default_context_.transport_security_state(); | 6213 default_context_.transport_security_state(); |
6214 TransportSecurityState::PKPState pkp_state; | 6214 TransportSecurityState::PKPState pkp_state; |
6215 EXPECT_FALSE( | 6215 EXPECT_FALSE( |
6216 security_state->GetDynamicPKPState(test_server_hostname, &pkp_state)); | 6216 security_state->GetDynamicPKPState(test_server_hostname, &pkp_state)); |
6217 } | 6217 } |
6218 | 6218 |
| 6219 TEST_F(URLRequestTestHTTP, PKPBypassRecorded) { |
| 6220 EmbeddedTestServer https_test_server(net::EmbeddedTestServer::TYPE_HTTPS); |
| 6221 https_test_server.SetSSLConfig( |
| 6222 net::EmbeddedTestServer::CERT_COMMON_NAME_IS_DOMAIN); |
| 6223 https_test_server.ServeFilesFromSourceDirectory( |
| 6224 base::FilePath(kTestFilePath)); |
| 6225 ASSERT_TRUE(https_test_server.Start()); |
| 6226 |
| 6227 // Set up a MockCertVerifier to be a local root that violates the pin |
| 6228 scoped_refptr<X509Certificate> cert = https_test_server.GetCertificate(); |
| 6229 ASSERT_TRUE(cert); |
| 6230 |
| 6231 MockCertVerifier cert_verifier; |
| 6232 CertVerifyResult verify_result; |
| 6233 verify_result.verified_cert = cert; |
| 6234 verify_result.is_issued_by_known_root = false; |
| 6235 verify_result.pkp_bypassed = true; |
| 6236 HashValue hash; |
| 6237 ASSERT_TRUE( |
| 6238 hash.FromString("sha256/1111111111111111111111111111111111111111111=")); |
| 6239 verify_result.public_key_hashes.push_back(hash); |
| 6240 cert_verifier.AddResultForCert(cert.get(), verify_result, OK); |
| 6241 cert_verifier.set_default_result(OK); |
| 6242 |
| 6243 TestNetworkDelegate network_delegate; |
| 6244 TransportSecurityState security_state; |
| 6245 TestURLRequestContext context(true); |
| 6246 context.set_transport_security_state(&security_state); |
| 6247 context.set_network_delegate(&network_delegate); |
| 6248 context.set_cert_verifier(&cert_verifier); |
| 6249 context.Init(); |
| 6250 |
| 6251 TestDelegate d; |
| 6252 std::unique_ptr<URLRequest> request(context.CreateRequest( |
| 6253 https_test_server.GetURL("/hpkp-headers.html"), DEFAULT_PRIORITY, &d)); |
| 6254 request->Start(); |
| 6255 base::RunLoop().Run(); |
| 6256 |
| 6257 std::string test_server_hostname = https_test_server.GetURL("/").host(); |
| 6258 |
| 6259 TransportSecurityState::PKPState pkp_state; |
| 6260 EXPECT_FALSE( |
| 6261 security_state.GetDynamicPKPState(test_server_hostname, &pkp_state)); |
| 6262 EXPECT_TRUE(request->ssl_info().pkp_bypassed); |
| 6263 } |
| 6264 |
6219 TEST_F(URLRequestTestHTTP, ProcessSTSOnce) { | 6265 TEST_F(URLRequestTestHTTP, ProcessSTSOnce) { |
6220 EmbeddedTestServer https_test_server(net::EmbeddedTestServer::TYPE_HTTPS); | 6266 EmbeddedTestServer https_test_server(net::EmbeddedTestServer::TYPE_HTTPS); |
6221 https_test_server.SetSSLConfig( | 6267 https_test_server.SetSSLConfig( |
6222 net::EmbeddedTestServer::CERT_COMMON_NAME_IS_DOMAIN); | 6268 net::EmbeddedTestServer::CERT_COMMON_NAME_IS_DOMAIN); |
6223 https_test_server.ServeFilesFromSourceDirectory( | 6269 https_test_server.ServeFilesFromSourceDirectory( |
6224 base::FilePath(kTestFilePath)); | 6270 base::FilePath(kTestFilePath)); |
6225 ASSERT_TRUE(https_test_server.Start()); | 6271 ASSERT_TRUE(https_test_server.Start()); |
6226 | 6272 |
6227 std::string test_server_hostname = https_test_server.GetURL("/").host(); | 6273 std::string test_server_hostname = https_test_server.GetURL("/").host(); |
6228 | 6274 |
(...skipping 3812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10041 AddTestInterceptor()->set_main_intercept_job(std::move(job)); | 10087 AddTestInterceptor()->set_main_intercept_job(std::move(job)); |
10042 | 10088 |
10043 req->Start(); | 10089 req->Start(); |
10044 req->Cancel(); | 10090 req->Cancel(); |
10045 base::RunLoop().RunUntilIdle(); | 10091 base::RunLoop().RunUntilIdle(); |
10046 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); | 10092 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); |
10047 EXPECT_EQ(0, d.received_redirect_count()); | 10093 EXPECT_EQ(0, d.received_redirect_count()); |
10048 } | 10094 } |
10049 | 10095 |
10050 } // namespace net | 10096 } // namespace net |
OLD | NEW |