Chromium Code Reviews| 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 24 matching lines...) Expand all Loading... | |
| 35 #include "net/ssl/ssl_info.h" | 35 #include "net/ssl/ssl_info.h" |
| 36 #include "net/test/cert_test_util.h" | 36 #include "net/test/cert_test_util.h" |
| 37 #include "net/test/test_data_directory.h" | 37 #include "net/test/test_data_directory.h" |
| 38 #include "testing/gmock/include/gmock/gmock.h" | 38 #include "testing/gmock/include/gmock/gmock.h" |
| 39 #include "testing/gtest/include/gtest/gtest.h" | 39 #include "testing/gtest/include/gtest/gtest.h" |
| 40 | 40 |
| 41 namespace net { | 41 namespace net { |
| 42 | 42 |
| 43 namespace { | 43 namespace { |
| 44 | 44 |
| 45 namespace test1 { | |
| 46 #include "net/http/transport_security_state_static_unittest1.h" | |
| 47 } | |
| 48 namespace test2 { | |
| 49 #include "net/http/transport_security_state_static_unittest2.h" | |
| 50 } | |
| 51 namespace test3 { | |
| 52 #include "net/http/transport_security_state_static_unittest3.h" | |
| 53 } | |
| 54 | |
| 45 const char kHost[] = "example.test"; | 55 const char kHost[] = "example.test"; |
| 46 const char kSubdomain[] = "foo.example.test"; | 56 const char kSubdomain[] = "foo.example.test"; |
| 47 const uint16_t kPort = 443; | 57 const uint16_t kPort = 443; |
| 48 const char kReportUri[] = "http://report-example.test/test"; | 58 const char kReportUri[] = "http://report-example.test/test"; |
| 49 const char kExpectCTStaticHostname[] = "preloaded-expect-ct.badssl.com"; | 59 const char kExpectCTStaticHostname[] = "preloaded-expect-ct.badssl.com"; |
| 50 const char kExpectCTStaticReportURI[] = "https://clients3.google.com/ct_upload"; | 60 const char kExpectCTStaticReportURI[] = "https://clients3.google.com/ct_upload"; |
| 51 const char kExpectStapleStaticHostname[] = "preloaded-expect-staple.badssl.com"; | 61 const char kExpectStapleStaticHostname[] = "preloaded-expect-staple.badssl.com"; |
| 52 const char kExpectStapleStaticReportURI[] = | 62 const char kExpectStapleStaticReportURI[] = |
| 53 "https://report.badssl.com/expect-staple"; | 63 "https://report.badssl.com/expect-staple"; |
| 54 const char kExpectStapleStaticIncludeSubdomainsHostname[] = | 64 const char kExpectStapleStaticIncludeSubdomainsHostname[] = |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 } | 385 } |
| 376 | 386 |
| 377 static HashValueVector GetSampleSPKIHashes() { | 387 static HashValueVector GetSampleSPKIHashes() { |
| 378 HashValueVector spki_hashes; | 388 HashValueVector spki_hashes; |
| 379 HashValue hash(HASH_VALUE_SHA256); | 389 HashValue hash(HASH_VALUE_SHA256); |
| 380 memset(hash.data(), 0, hash.size()); | 390 memset(hash.data(), 0, hash.size()); |
| 381 spki_hashes.push_back(hash); | 391 spki_hashes.push_back(hash); |
| 382 return spki_hashes; | 392 return spki_hashes; |
| 383 } | 393 } |
| 384 | 394 |
| 395 static HashValue GetSampleSPKIHash(uint8_t value) { | |
| 396 HashValue hash(HASH_VALUE_SHA256); | |
| 397 memset(hash.data(), value, hash.size()); | |
| 398 return hash; | |
| 399 } | |
| 400 | |
| 385 protected: | 401 protected: |
| 386 bool GetStaticDomainState(TransportSecurityState* state, | 402 bool GetStaticDomainState(TransportSecurityState* state, |
| 387 const std::string& host, | 403 const std::string& host, |
| 388 TransportSecurityState::STSState* sts_result, | 404 TransportSecurityState::STSState* sts_result, |
| 389 TransportSecurityState::PKPState* pkp_result) { | 405 TransportSecurityState::PKPState* pkp_result) { |
| 390 return state->GetStaticDomainState(host, sts_result, pkp_result); | 406 return state->GetStaticDomainState(host, sts_result, pkp_result); |
| 391 } | 407 } |
| 392 | 408 |
| 393 bool GetExpectCTState(TransportSecurityState* state, | 409 bool GetExpectCTState(TransportSecurityState* state, |
| 394 const std::string& host, | 410 const std::string& host, |
| (...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1991 state.ProcessExpectCTHeader("preload", host_port, ssl_info); | 2007 state.ProcessExpectCTHeader("preload", host_port, ssl_info); |
| 1992 EXPECT_EQ(1u, reporter.num_failures()); | 2008 EXPECT_EQ(1u, reporter.num_failures()); |
| 1993 EXPECT_TRUE(reporter.ssl_info().ct_compliance_details_available); | 2009 EXPECT_TRUE(reporter.ssl_info().ct_compliance_details_available); |
| 1994 EXPECT_EQ(ssl_info.ct_cert_policy_compliance, | 2010 EXPECT_EQ(ssl_info.ct_cert_policy_compliance, |
| 1995 reporter.ssl_info().ct_cert_policy_compliance); | 2011 reporter.ssl_info().ct_cert_policy_compliance); |
| 1996 EXPECT_EQ(host_port.host(), reporter.host_port_pair().host()); | 2012 EXPECT_EQ(host_port.host(), reporter.host_port_pair().host()); |
| 1997 EXPECT_EQ(host_port.port(), reporter.host_port_pair().port()); | 2013 EXPECT_EQ(host_port.port(), reporter.host_port_pair().port()); |
| 1998 EXPECT_EQ(GURL(kExpectCTStaticReportURI), reporter.report_uri()); | 2014 EXPECT_EQ(GURL(kExpectCTStaticReportURI), reporter.report_uri()); |
| 1999 } | 2015 } |
| 2000 | 2016 |
| 2017 TEST_F(TransportSecurityStateTest, DecodePreloadedSingle) { | |
|
Ryan Sleevi
2017/03/17 22:17:37
Would you be willing to add prosaic definitions to
martijnc
2017/03/18 21:36:04
Added a comment to each test explaining what is be
| |
| 2018 SetTransportSecurityStateSourceForTesting(&test1::kHSTSSource); | |
| 2019 | |
| 2020 TransportSecurityState state; | |
| 2021 TransportSecurityStateTest::EnableStaticPins(&state); | |
| 2022 TransportSecurityStateTest::EnableStaticExpectCT(&state); | |
| 2023 TransportSecurityStateTest::SetEnableStaticExpectStaple(&state, true); | |
| 2024 | |
| 2025 TransportSecurityState::STSState sts_state; | |
| 2026 TransportSecurityState::PKPState pkp_state; | |
| 2027 EXPECT_TRUE( | |
| 2028 GetStaticDomainState(&state, "hsts.example.com", &sts_state, &pkp_state)); | |
| 2029 EXPECT_TRUE(sts_state.include_subdomains); | |
| 2030 EXPECT_EQ(TransportSecurityState::STSState::MODE_FORCE_HTTPS, | |
| 2031 sts_state.upgrade_mode); | |
| 2032 EXPECT_TRUE(pkp_state.include_subdomains); | |
| 2033 EXPECT_EQ(GURL(""), pkp_state.report_uri); | |
|
Ryan Sleevi
2017/03/17 22:17:37
Is GURL("") different than GURL()?
martijnc
2017/03/18 21:36:04
Changed.
| |
| 2034 ASSERT_EQ(1u, pkp_state.spki_hashes.size()); | |
| 2035 EXPECT_EQ(pkp_state.spki_hashes[0], GetSampleSPKIHash(0x1)); | |
| 2036 ASSERT_EQ(1u, pkp_state.bad_spki_hashes.size()); | |
| 2037 EXPECT_EQ(pkp_state.bad_spki_hashes[0], GetSampleSPKIHash(0x2)); | |
| 2038 | |
| 2039 TransportSecurityState::ExpectCTState ct_state; | |
| 2040 EXPECT_FALSE(GetExpectCTState(&state, "hsts.example.com", &ct_state)); | |
| 2041 | |
| 2042 TransportSecurityState::ExpectStapleState staple_state; | |
| 2043 EXPECT_FALSE(GetExpectStapleState(&state, "hsts.example.com", &staple_state)); | |
| 2044 | |
| 2045 SetTransportSecurityStateSourceForTesting(nullptr); | |
|
Ryan Sleevi
2017/03/17 22:17:37
This won't reset if any of the ASSERT_EQ's fail (e
martijnc
2017/03/18 21:36:04
Moved it to the test harness but placed it in test
Ryan Sleevi
2017/03/21 03:24:36
Prefer DTOR - https://github.com/google/googletest
martijnc
2017/03/21 17:19:18
Changed.
I had only read the item about SetUp and
| |
| 2046 } | |
| 2047 | |
| 2048 TEST_F(TransportSecurityStateTest, DecodePreloadedMultiplePrefix) { | |
| 2049 SetTransportSecurityStateSourceForTesting(&test2::kHSTSSource); | |
| 2050 | |
| 2051 TransportSecurityState state; | |
| 2052 TransportSecurityStateTest::EnableStaticPins(&state); | |
| 2053 TransportSecurityStateTest::EnableStaticExpectCT(&state); | |
| 2054 TransportSecurityStateTest::SetEnableStaticExpectStaple(&state, true); | |
| 2055 | |
| 2056 TransportSecurityState::STSState sts_state; | |
| 2057 TransportSecurityState::PKPState pkp_state; | |
| 2058 TransportSecurityState::ExpectCTState ct_state; | |
| 2059 TransportSecurityState::ExpectStapleState staple_state; | |
| 2060 | |
| 2061 EXPECT_TRUE( | |
| 2062 GetStaticDomainState(&state, "hsts.example.com", &sts_state, &pkp_state)); | |
| 2063 EXPECT_FALSE(sts_state.include_subdomains); | |
| 2064 EXPECT_EQ(TransportSecurityState::STSState::MODE_FORCE_HTTPS, | |
| 2065 sts_state.upgrade_mode); | |
| 2066 EXPECT_FALSE(pkp_state.include_subdomains); | |
| 2067 EXPECT_EQ(GURL(""), pkp_state.report_uri); | |
| 2068 EXPECT_EQ(0U, pkp_state.spki_hashes.size()); | |
| 2069 EXPECT_EQ(0U, pkp_state.bad_spki_hashes.size()); | |
| 2070 EXPECT_FALSE(GetExpectCTState(&state, "hsts.example.com", &ct_state)); | |
| 2071 EXPECT_FALSE(GetExpectStapleState(&state, "hsts.example.com", &staple_state)); | |
| 2072 | |
| 2073 sts_state = TransportSecurityState::STSState(); | |
| 2074 pkp_state = TransportSecurityState::PKPState(); | |
| 2075 ct_state = TransportSecurityState::ExpectCTState(); | |
| 2076 staple_state = TransportSecurityState::ExpectStapleState(); | |
| 2077 EXPECT_TRUE( | |
| 2078 GetStaticDomainState(&state, "hpkp.example.com", &sts_state, &pkp_state)); | |
| 2079 EXPECT_FALSE(sts_state.include_subdomains); | |
| 2080 EXPECT_EQ(TransportSecurityState::STSState::MODE_DEFAULT, | |
| 2081 sts_state.upgrade_mode); | |
| 2082 EXPECT_TRUE(pkp_state.include_subdomains); | |
| 2083 EXPECT_EQ(GURL("https://report.example.com/hpkp-upload"), | |
| 2084 pkp_state.report_uri); | |
| 2085 EXPECT_EQ(1U, pkp_state.spki_hashes.size()); | |
| 2086 EXPECT_EQ(pkp_state.spki_hashes[0], GetSampleSPKIHash(0x1)); | |
| 2087 EXPECT_EQ(0U, pkp_state.bad_spki_hashes.size()); | |
| 2088 EXPECT_FALSE(GetExpectCTState(&state, "hpkp.example.com", &ct_state)); | |
| 2089 EXPECT_FALSE(GetExpectStapleState(&state, "hpkp.example.com", &staple_state)); | |
| 2090 | |
| 2091 sts_state = TransportSecurityState::STSState(); | |
| 2092 pkp_state = TransportSecurityState::PKPState(); | |
| 2093 ct_state = TransportSecurityState::ExpectCTState(); | |
| 2094 staple_state = TransportSecurityState::ExpectStapleState(); | |
| 2095 EXPECT_TRUE(GetStaticDomainState(&state, "expect-ct.example.com", &sts_state, | |
| 2096 &pkp_state)); | |
| 2097 EXPECT_FALSE(sts_state.include_subdomains); | |
| 2098 EXPECT_EQ(TransportSecurityState::STSState::MODE_DEFAULT, | |
| 2099 sts_state.upgrade_mode); | |
| 2100 EXPECT_FALSE(pkp_state.include_subdomains); | |
| 2101 EXPECT_EQ(GURL(""), pkp_state.report_uri); | |
| 2102 EXPECT_EQ(0U, pkp_state.spki_hashes.size()); | |
| 2103 EXPECT_EQ(0U, pkp_state.bad_spki_hashes.size()); | |
| 2104 EXPECT_TRUE(GetExpectCTState(&state, "expect-ct.example.com", &ct_state)); | |
| 2105 EXPECT_EQ(GURL("https://report.example.com/ct-upload"), ct_state.report_uri); | |
| 2106 EXPECT_FALSE( | |
| 2107 GetExpectStapleState(&state, "expect-ct.example.com", &staple_state)); | |
| 2108 | |
| 2109 sts_state = TransportSecurityState::STSState(); | |
| 2110 pkp_state = TransportSecurityState::PKPState(); | |
| 2111 ct_state = TransportSecurityState::ExpectCTState(); | |
| 2112 staple_state = TransportSecurityState::ExpectStapleState(); | |
| 2113 EXPECT_TRUE(GetStaticDomainState(&state, "expect-staple.example.com", | |
| 2114 &sts_state, &pkp_state)); | |
| 2115 EXPECT_FALSE(sts_state.include_subdomains); | |
| 2116 EXPECT_EQ(TransportSecurityState::STSState::MODE_DEFAULT, | |
| 2117 sts_state.upgrade_mode); | |
| 2118 EXPECT_FALSE(pkp_state.include_subdomains); | |
| 2119 EXPECT_EQ(GURL(""), pkp_state.report_uri); | |
| 2120 EXPECT_EQ(0U, pkp_state.spki_hashes.size()); | |
| 2121 EXPECT_EQ(0U, pkp_state.bad_spki_hashes.size()); | |
| 2122 EXPECT_FALSE( | |
| 2123 GetExpectCTState(&state, "expect-staple.example.com", &ct_state)); | |
| 2124 EXPECT_TRUE( | |
| 2125 GetExpectStapleState(&state, "expect-staple.example.com", &staple_state)); | |
| 2126 EXPECT_FALSE(staple_state.include_subdomains); | |
| 2127 EXPECT_EQ(GURL("https://report.example.com/staple-upload"), | |
| 2128 staple_state.report_uri); | |
| 2129 | |
| 2130 sts_state = TransportSecurityState::STSState(); | |
| 2131 pkp_state = TransportSecurityState::PKPState(); | |
| 2132 ct_state = TransportSecurityState::ExpectCTState(); | |
| 2133 staple_state = TransportSecurityState::ExpectStapleState(); | |
| 2134 EXPECT_TRUE( | |
| 2135 GetStaticDomainState(&state, "mix.example.com", &sts_state, &pkp_state)); | |
| 2136 EXPECT_FALSE(sts_state.include_subdomains); | |
| 2137 EXPECT_EQ(TransportSecurityState::STSState::MODE_FORCE_HTTPS, | |
| 2138 sts_state.upgrade_mode); | |
| 2139 EXPECT_TRUE(pkp_state.include_subdomains); | |
| 2140 EXPECT_EQ(GURL(""), pkp_state.report_uri); | |
| 2141 EXPECT_EQ(1U, pkp_state.spki_hashes.size()); | |
| 2142 EXPECT_EQ(pkp_state.spki_hashes[0], GetSampleSPKIHash(0x2)); | |
| 2143 EXPECT_EQ(1U, pkp_state.bad_spki_hashes.size()); | |
| 2144 EXPECT_EQ(pkp_state.bad_spki_hashes[0], GetSampleSPKIHash(0x1)); | |
| 2145 EXPECT_TRUE(GetExpectCTState(&state, "mix.example.com", &ct_state)); | |
| 2146 EXPECT_EQ(GURL("https://report.example.com/ct-upload-alt"), | |
| 2147 ct_state.report_uri); | |
| 2148 EXPECT_TRUE(GetExpectStapleState(&state, "mix.example.com", &staple_state)); | |
| 2149 EXPECT_TRUE(staple_state.include_subdomains); | |
| 2150 EXPECT_EQ(GURL("https://report.example.com/staple-upload-alt"), | |
| 2151 staple_state.report_uri); | |
| 2152 | |
| 2153 SetTransportSecurityStateSourceForTesting(nullptr); | |
| 2154 } | |
| 2155 | |
| 2156 TEST_F(TransportSecurityStateTest, DecodePreloadedMultipleMix) { | |
| 2157 SetTransportSecurityStateSourceForTesting(&test3::kHSTSSource); | |
| 2158 | |
| 2159 TransportSecurityState state; | |
| 2160 TransportSecurityStateTest::EnableStaticPins(&state); | |
| 2161 TransportSecurityStateTest::EnableStaticExpectCT(&state); | |
| 2162 TransportSecurityStateTest::SetEnableStaticExpectStaple(&state, true); | |
| 2163 | |
| 2164 TransportSecurityState::STSState sts_state; | |
| 2165 TransportSecurityState::PKPState pkp_state; | |
| 2166 TransportSecurityState::ExpectCTState ct_state; | |
| 2167 TransportSecurityState::ExpectStapleState staple_state; | |
| 2168 | |
| 2169 EXPECT_TRUE( | |
| 2170 GetStaticDomainState(&state, "example.com", &sts_state, &pkp_state)); | |
| 2171 EXPECT_TRUE(sts_state.include_subdomains); | |
| 2172 EXPECT_EQ(TransportSecurityState::STSState::MODE_FORCE_HTTPS, | |
| 2173 sts_state.upgrade_mode); | |
| 2174 EXPECT_FALSE(pkp_state.include_subdomains); | |
| 2175 EXPECT_EQ(GURL(""), pkp_state.report_uri); | |
| 2176 EXPECT_EQ(0U, pkp_state.spki_hashes.size()); | |
| 2177 EXPECT_EQ(0U, pkp_state.bad_spki_hashes.size()); | |
| 2178 EXPECT_FALSE(GetExpectCTState(&state, "example.com", &ct_state)); | |
| 2179 EXPECT_EQ(GURL(""), ct_state.report_uri); | |
| 2180 EXPECT_TRUE(GetExpectStapleState(&state, "example.com", &staple_state)); | |
| 2181 EXPECT_FALSE(staple_state.include_subdomains); | |
| 2182 EXPECT_EQ(GURL("https://report.example.com/staple-upload"), | |
| 2183 staple_state.report_uri); | |
| 2184 | |
| 2185 sts_state = TransportSecurityState::STSState(); | |
| 2186 pkp_state = TransportSecurityState::PKPState(); | |
| 2187 ct_state = TransportSecurityState::ExpectCTState(); | |
| 2188 staple_state = TransportSecurityState::ExpectStapleState(); | |
| 2189 EXPECT_TRUE( | |
| 2190 GetStaticDomainState(&state, "hpkp.example.com", &sts_state, &pkp_state)); | |
| 2191 EXPECT_FALSE(sts_state.include_subdomains); | |
| 2192 EXPECT_EQ(TransportSecurityState::STSState::MODE_DEFAULT, | |
| 2193 sts_state.upgrade_mode); | |
| 2194 EXPECT_TRUE(pkp_state.include_subdomains); | |
| 2195 EXPECT_EQ(GURL("https://report.example.com/hpkp-upload"), | |
| 2196 pkp_state.report_uri); | |
| 2197 EXPECT_EQ(1U, pkp_state.spki_hashes.size()); | |
| 2198 EXPECT_EQ(pkp_state.spki_hashes[0], GetSampleSPKIHash(0x1)); | |
| 2199 EXPECT_EQ(0U, pkp_state.bad_spki_hashes.size()); | |
| 2200 EXPECT_FALSE(GetExpectCTState(&state, "hpkp.example.com", &ct_state)); | |
| 2201 EXPECT_EQ(GURL(""), ct_state.report_uri); | |
| 2202 EXPECT_FALSE(GetExpectStapleState(&state, "hpkp.example.com", &staple_state)); | |
| 2203 EXPECT_FALSE(staple_state.include_subdomains); | |
| 2204 EXPECT_EQ(GURL(""), staple_state.report_uri); | |
| 2205 | |
| 2206 sts_state = TransportSecurityState::STSState(); | |
| 2207 pkp_state = TransportSecurityState::PKPState(); | |
| 2208 ct_state = TransportSecurityState::ExpectCTState(); | |
| 2209 staple_state = TransportSecurityState::ExpectStapleState(); | |
| 2210 EXPECT_TRUE( | |
| 2211 GetStaticDomainState(&state, "example.org", &sts_state, &pkp_state)); | |
| 2212 EXPECT_FALSE(sts_state.include_subdomains); | |
| 2213 EXPECT_EQ(TransportSecurityState::STSState::MODE_FORCE_HTTPS, | |
| 2214 sts_state.upgrade_mode); | |
| 2215 EXPECT_FALSE(pkp_state.include_subdomains); | |
| 2216 EXPECT_EQ(GURL(""), pkp_state.report_uri); | |
| 2217 EXPECT_EQ(0U, pkp_state.spki_hashes.size()); | |
| 2218 EXPECT_EQ(0U, pkp_state.bad_spki_hashes.size()); | |
| 2219 EXPECT_TRUE(GetExpectCTState(&state, "example.org", &ct_state)); | |
| 2220 EXPECT_EQ(GURL("https://report.example.org/ct-upload"), ct_state.report_uri); | |
| 2221 EXPECT_FALSE(GetExpectStapleState(&state, "example.org", &staple_state)); | |
| 2222 EXPECT_FALSE(staple_state.include_subdomains); | |
| 2223 EXPECT_EQ(GURL(""), staple_state.report_uri); | |
| 2224 | |
| 2225 sts_state = TransportSecurityState::STSState(); | |
| 2226 pkp_state = TransportSecurityState::PKPState(); | |
| 2227 ct_state = TransportSecurityState::ExpectCTState(); | |
| 2228 staple_state = TransportSecurityState::ExpectStapleState(); | |
| 2229 EXPECT_TRUE( | |
| 2230 GetStaticDomainState(&state, "badssl.com", &sts_state, &pkp_state)); | |
| 2231 EXPECT_TRUE(sts_state.include_subdomains); | |
| 2232 EXPECT_EQ(TransportSecurityState::STSState::MODE_DEFAULT, | |
| 2233 sts_state.upgrade_mode); | |
| 2234 EXPECT_TRUE(pkp_state.include_subdomains); | |
| 2235 EXPECT_EQ(GURL("https://report.example.com/hpkp-upload"), | |
| 2236 pkp_state.report_uri); | |
| 2237 EXPECT_EQ(1U, pkp_state.spki_hashes.size()); | |
| 2238 EXPECT_EQ(pkp_state.spki_hashes[0], GetSampleSPKIHash(0x1)); | |
| 2239 EXPECT_EQ(0U, pkp_state.bad_spki_hashes.size()); | |
| 2240 EXPECT_FALSE(GetExpectCTState(&state, "badssl.com", &ct_state)); | |
| 2241 EXPECT_EQ(GURL(""), ct_state.report_uri); | |
| 2242 EXPECT_TRUE(GetExpectStapleState(&state, "badssl.com", &staple_state)); | |
| 2243 EXPECT_TRUE(staple_state.include_subdomains); | |
| 2244 EXPECT_EQ(GURL("https://report.badssl.com/staple-upload"), | |
| 2245 staple_state.report_uri); | |
| 2246 | |
| 2247 sts_state = TransportSecurityState::STSState(); | |
| 2248 pkp_state = TransportSecurityState::PKPState(); | |
| 2249 ct_state = TransportSecurityState::ExpectCTState(); | |
| 2250 staple_state = TransportSecurityState::ExpectStapleState(); | |
| 2251 EXPECT_TRUE( | |
| 2252 GetStaticDomainState(&state, "mix.badssl.com", &sts_state, &pkp_state)); | |
| 2253 EXPECT_FALSE(sts_state.include_subdomains); | |
| 2254 EXPECT_EQ(TransportSecurityState::STSState::MODE_FORCE_HTTPS, | |
| 2255 sts_state.upgrade_mode); | |
| 2256 EXPECT_TRUE(pkp_state.include_subdomains); | |
| 2257 EXPECT_EQ(GURL(""), pkp_state.report_uri); | |
| 2258 EXPECT_EQ(1U, pkp_state.spki_hashes.size()); | |
| 2259 EXPECT_EQ(pkp_state.spki_hashes[0], GetSampleSPKIHash(0x2)); | |
| 2260 EXPECT_EQ(1U, pkp_state.bad_spki_hashes.size()); | |
| 2261 EXPECT_EQ(pkp_state.bad_spki_hashes[0], GetSampleSPKIHash(0x1)); | |
| 2262 EXPECT_TRUE(GetExpectCTState(&state, "mix.badssl.com", &ct_state)); | |
| 2263 EXPECT_EQ(GURL("https://report.example.com/ct-upload"), ct_state.report_uri); | |
| 2264 EXPECT_TRUE(GetExpectStapleState(&state, "mix.badssl.com", &staple_state)); | |
| 2265 EXPECT_TRUE(staple_state.include_subdomains); | |
| 2266 EXPECT_EQ(GURL("https://report.badssl.com/staple-upload"), | |
| 2267 staple_state.report_uri); | |
| 2268 | |
| 2269 SetTransportSecurityStateSourceForTesting(nullptr); | |
| 2270 } | |
| 2271 | |
| 2001 static const struct ExpectStapleErrorResponseData { | 2272 static const struct ExpectStapleErrorResponseData { |
| 2002 OCSPVerifyResult::ResponseStatus response_status; | 2273 OCSPVerifyResult::ResponseStatus response_status; |
| 2003 std::string response_status_string; | 2274 std::string response_status_string; |
| 2004 } kExpectStapleReportData[] = { | 2275 } kExpectStapleReportData[] = { |
| 2005 {OCSPVerifyResult::MISSING, "MISSING"}, | 2276 {OCSPVerifyResult::MISSING, "MISSING"}, |
| 2006 {OCSPVerifyResult::ERROR_RESPONSE, "ERROR_RESPONSE"}, | 2277 {OCSPVerifyResult::ERROR_RESPONSE, "ERROR_RESPONSE"}, |
| 2007 {OCSPVerifyResult::BAD_PRODUCED_AT, "BAD_PRODUCED_AT"}, | 2278 {OCSPVerifyResult::BAD_PRODUCED_AT, "BAD_PRODUCED_AT"}, |
| 2008 {OCSPVerifyResult::NO_MATCHING_RESPONSE, "NO_MATCHING_RESPONSE"}, | 2279 {OCSPVerifyResult::NO_MATCHING_RESPONSE, "NO_MATCHING_RESPONSE"}, |
| 2009 {OCSPVerifyResult::INVALID_DATE, "INVALID_DATE"}, | 2280 {OCSPVerifyResult::INVALID_DATE, "INVALID_DATE"}, |
| 2010 {OCSPVerifyResult::PARSE_RESPONSE_ERROR, "PARSE_RESPONSE_ERROR"}, | 2281 {OCSPVerifyResult::PARSE_RESPONSE_ERROR, "PARSE_RESPONSE_ERROR"}, |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2309 base::FieldTrialList::CreateFieldTrial("EnforceCTForProblematicRoots", | 2580 base::FieldTrialList::CreateFieldTrial("EnforceCTForProblematicRoots", |
| 2310 "disabled"); | 2581 "disabled"); |
| 2311 | 2582 |
| 2312 EXPECT_FALSE( | 2583 EXPECT_FALSE( |
| 2313 state.ShouldRequireCT("www.example.com", before_cert.get(), hashes)); | 2584 state.ShouldRequireCT("www.example.com", before_cert.get(), hashes)); |
| 2314 EXPECT_FALSE( | 2585 EXPECT_FALSE( |
| 2315 state.ShouldRequireCT("www.example.com", after_cert.get(), hashes)); | 2586 state.ShouldRequireCT("www.example.com", after_cert.get(), hashes)); |
| 2316 } | 2587 } |
| 2317 | 2588 |
| 2318 } // namespace net | 2589 } // namespace net |
| OLD | NEW |