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/transport_security_state.h" | 5 #include "net/http/transport_security_state.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 | 1281 |
1282 EXPECT_TRUE(state.CheckPublicKeyPins( | 1282 EXPECT_TRUE(state.CheckPublicKeyPins( |
1283 host_port_pair, true, good_hashes, cert1.get(), cert2.get(), | 1283 host_port_pair, true, good_hashes, cert1.get(), cert2.get(), |
1284 TransportSecurityState::ENABLE_PIN_REPORTS, &failure_log)); | 1284 TransportSecurityState::ENABLE_PIN_REPORTS, &failure_log)); |
1285 | 1285 |
1286 // No report should have been sent because there was no violation. | 1286 // No report should have been sent because there was no violation. |
1287 EXPECT_EQ(GURL(), mock_report_sender.latest_report_uri()); | 1287 EXPECT_EQ(GURL(), mock_report_sender.latest_report_uri()); |
1288 EXPECT_EQ(std::string(), mock_report_sender.latest_report()); | 1288 EXPECT_EQ(std::string(), mock_report_sender.latest_report()); |
1289 | 1289 |
1290 EXPECT_FALSE(state.CheckPublicKeyPins( | 1290 EXPECT_FALSE(state.CheckPublicKeyPins( |
| 1291 host_port_pair, false, bad_hashes, cert1.get(), cert2.get(), |
| 1292 TransportSecurityState::ENABLE_PIN_REPORTS, &failure_log)); |
| 1293 |
| 1294 // No report should have been sent because the certificate chained to a |
| 1295 // non-public root |
| 1296 EXPECT_EQ(GURL(), mock_report_sender.latest_report_uri()); |
| 1297 EXPECT_EQ(std::string(), mock_report_sender.latest_report()); |
| 1298 |
| 1299 EXPECT_TRUE(state.CheckPublicKeyPins( |
| 1300 host_port_pair, false, good_hashes, cert1.get(), cert2.get(), |
| 1301 TransportSecurityState::ENABLE_PIN_REPORTS, &failure_log)); |
| 1302 |
| 1303 // No report should have been sent because there was no violation, even though |
| 1304 // the certificate chained to a local trust anchor. |
| 1305 EXPECT_EQ(GURL(), mock_report_sender.latest_report_uri()); |
| 1306 EXPECT_EQ(std::string(), mock_report_sender.latest_report()); |
| 1307 |
| 1308 EXPECT_FALSE(state.CheckPublicKeyPins( |
1291 host_port_pair, true, bad_hashes, cert1.get(), cert2.get(), | 1309 host_port_pair, true, bad_hashes, cert1.get(), cert2.get(), |
1292 TransportSecurityState::ENABLE_PIN_REPORTS, &failure_log)); | 1310 TransportSecurityState::ENABLE_PIN_REPORTS, &failure_log)); |
1293 | 1311 |
1294 // Now a report should have been sent. Check that it contains the | 1312 // Now a report should have been sent. Check that it contains the |
1295 // right information. | 1313 // right information. |
1296 EXPECT_EQ(report_uri, mock_report_sender.latest_report_uri()); | 1314 EXPECT_EQ(report_uri, mock_report_sender.latest_report_uri()); |
1297 std::string report = mock_report_sender.latest_report(); | 1315 std::string report = mock_report_sender.latest_report(); |
1298 ASSERT_FALSE(report.empty()); | 1316 ASSERT_FALSE(report.empty()); |
1299 ASSERT_NO_FATAL_FAILURE(CheckHPKPReport(report, host_port_pair, true, kHost, | 1317 ASSERT_NO_FATAL_FAILURE(CheckHPKPReport(report, host_port_pair, true, kHost, |
1300 cert1.get(), cert2.get(), | 1318 cert1.get(), cert2.get(), |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1845 EXPECT_EQ(1u, reporter.num_failures()); | 1863 EXPECT_EQ(1u, reporter.num_failures()); |
1846 EXPECT_TRUE(reporter.ssl_info().ct_compliance_details_available); | 1864 EXPECT_TRUE(reporter.ssl_info().ct_compliance_details_available); |
1847 EXPECT_EQ(ssl_info.ct_cert_policy_compliance, | 1865 EXPECT_EQ(ssl_info.ct_cert_policy_compliance, |
1848 reporter.ssl_info().ct_cert_policy_compliance); | 1866 reporter.ssl_info().ct_cert_policy_compliance); |
1849 EXPECT_EQ(host_port.host(), reporter.host_port_pair().host()); | 1867 EXPECT_EQ(host_port.host(), reporter.host_port_pair().host()); |
1850 EXPECT_EQ(host_port.port(), reporter.host_port_pair().port()); | 1868 EXPECT_EQ(host_port.port(), reporter.host_port_pair().port()); |
1851 EXPECT_EQ(GURL(kExpectCTStaticReportURI), reporter.report_uri()); | 1869 EXPECT_EQ(GURL(kExpectCTStaticReportURI), reporter.report_uri()); |
1852 } | 1870 } |
1853 | 1871 |
1854 } // namespace net | 1872 } // namespace net |
OLD | NEW |