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

Side by Side Diff: net/http/transport_security_state_unittest.cc

Issue 2680933009: Add unittests for HSTS decoding. (Closed)
Patch Set: Comment rsleevi. Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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
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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 std::string serialized_report = reporter->latest_report(); 356 std::string serialized_report = reporter->latest_report();
347 EXPECT_NO_FATAL_FAILURE(CheckSerializedExpectStapleReport( 357 EXPECT_NO_FATAL_FAILURE(CheckSerializedExpectStapleReport(
348 serialized_report, host_port, ssl_info, ocsp_response, response_status, 358 serialized_report, host_port, ssl_info, ocsp_response, response_status,
349 cert_status)); 359 cert_status));
350 } 360 }
351 361
352 } // namespace 362 } // namespace
353 363
354 class TransportSecurityStateTest : public testing::Test { 364 class TransportSecurityStateTest : public testing::Test {
355 public: 365 public:
366 ~TransportSecurityStateTest() override {
367 SetTransportSecurityStateSourceForTesting(nullptr);
368 }
369
356 void SetUp() override { 370 void SetUp() override {
357 crypto::EnsureOpenSSLInit(); 371 crypto::EnsureOpenSSLInit();
358 } 372 }
359 373
360 static void DisableStaticPins(TransportSecurityState* state) { 374 static void DisableStaticPins(TransportSecurityState* state) {
361 state->enable_static_pins_ = false; 375 state->enable_static_pins_ = false;
362 } 376 }
363 377
364 static void EnableStaticPins(TransportSecurityState* state) { 378 static void EnableStaticPins(TransportSecurityState* state) {
365 state->enable_static_pins_ = true; 379 state->enable_static_pins_ = true;
366 } 380 }
367 381
368 static void EnableStaticExpectCT(TransportSecurityState* state) { 382 static void EnableStaticExpectCT(TransportSecurityState* state) {
369 state->enable_static_expect_ct_ = true; 383 state->enable_static_expect_ct_ = true;
370 } 384 }
371 385
372 static void SetEnableStaticExpectStaple(TransportSecurityState* state, 386 static void SetEnableStaticExpectStaple(TransportSecurityState* state,
373 bool enabled) { 387 bool enabled) {
374 state->enable_static_expect_staple_ = enabled; 388 state->enable_static_expect_staple_ = enabled;
375 } 389 }
376 390
377 static HashValueVector GetSampleSPKIHashes() { 391 static HashValueVector GetSampleSPKIHashes() {
378 HashValueVector spki_hashes; 392 HashValueVector spki_hashes;
379 HashValue hash(HASH_VALUE_SHA256); 393 HashValue hash(HASH_VALUE_SHA256);
380 memset(hash.data(), 0, hash.size()); 394 memset(hash.data(), 0, hash.size());
381 spki_hashes.push_back(hash); 395 spki_hashes.push_back(hash);
382 return spki_hashes; 396 return spki_hashes;
383 } 397 }
384 398
399 static HashValue GetSampleSPKIHash(uint8_t value) {
400 HashValue hash(HASH_VALUE_SHA256);
401 memset(hash.data(), value, hash.size());
402 return hash;
403 }
404
385 protected: 405 protected:
386 bool GetStaticDomainState(TransportSecurityState* state, 406 bool GetStaticDomainState(TransportSecurityState* state,
387 const std::string& host, 407 const std::string& host,
388 TransportSecurityState::STSState* sts_result, 408 TransportSecurityState::STSState* sts_result,
389 TransportSecurityState::PKPState* pkp_result) { 409 TransportSecurityState::PKPState* pkp_result) {
390 return state->GetStaticDomainState(host, sts_result, pkp_result); 410 return state->GetStaticDomainState(host, sts_result, pkp_result);
391 } 411 }
392 412
393 bool GetExpectCTState(TransportSecurityState* state, 413 bool GetExpectCTState(TransportSecurityState* state,
394 const std::string& host, 414 const std::string& host,
(...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after
1991 state.ProcessExpectCTHeader("preload", host_port, ssl_info); 2011 state.ProcessExpectCTHeader("preload", host_port, ssl_info);
1992 EXPECT_EQ(1u, reporter.num_failures()); 2012 EXPECT_EQ(1u, reporter.num_failures());
1993 EXPECT_TRUE(reporter.ssl_info().ct_compliance_details_available); 2013 EXPECT_TRUE(reporter.ssl_info().ct_compliance_details_available);
1994 EXPECT_EQ(ssl_info.ct_cert_policy_compliance, 2014 EXPECT_EQ(ssl_info.ct_cert_policy_compliance,
1995 reporter.ssl_info().ct_cert_policy_compliance); 2015 reporter.ssl_info().ct_cert_policy_compliance);
1996 EXPECT_EQ(host_port.host(), reporter.host_port_pair().host()); 2016 EXPECT_EQ(host_port.host(), reporter.host_port_pair().host());
1997 EXPECT_EQ(host_port.port(), reporter.host_port_pair().port()); 2017 EXPECT_EQ(host_port.port(), reporter.host_port_pair().port());
1998 EXPECT_EQ(GURL(kExpectCTStaticReportURI), reporter.report_uri()); 2018 EXPECT_EQ(GURL(kExpectCTStaticReportURI), reporter.report_uri());
1999 } 2019 }
2000 2020
2021 // Simple test for the HSTS preload process. The trie (generated from
2022 // transport_security_state_static_unittest1.json) contains 1 entry. Test that
2023 // the lookup methods can find the entry and correctly decode the different
2024 // preloaded states (HSTS, HPKP, Expect-CT, and Expect-Staple).
2025 TEST_F(TransportSecurityStateTest, DecodePreloadedSingle) {
2026 SetTransportSecurityStateSourceForTesting(&test1::kHSTSSource);
2027
2028 TransportSecurityState state;
2029 TransportSecurityStateTest::EnableStaticPins(&state);
2030 TransportSecurityStateTest::EnableStaticExpectCT(&state);
2031 TransportSecurityStateTest::SetEnableStaticExpectStaple(&state, true);
2032
2033 TransportSecurityState::STSState sts_state;
2034 TransportSecurityState::PKPState pkp_state;
2035 EXPECT_TRUE(
2036 GetStaticDomainState(&state, "hsts.example.com", &sts_state, &pkp_state));
2037 EXPECT_TRUE(sts_state.include_subdomains);
2038 EXPECT_EQ(TransportSecurityState::STSState::MODE_FORCE_HTTPS,
2039 sts_state.upgrade_mode);
2040 EXPECT_TRUE(pkp_state.include_subdomains);
2041 EXPECT_EQ(GURL(), pkp_state.report_uri);
2042 ASSERT_EQ(1u, pkp_state.spki_hashes.size());
2043 EXPECT_EQ(pkp_state.spki_hashes[0], GetSampleSPKIHash(0x1));
2044 ASSERT_EQ(1u, pkp_state.bad_spki_hashes.size());
2045 EXPECT_EQ(pkp_state.bad_spki_hashes[0], GetSampleSPKIHash(0x2));
2046
2047 TransportSecurityState::ExpectCTState ct_state;
2048 EXPECT_FALSE(GetExpectCTState(&state, "hsts.example.com", &ct_state));
2049
2050 TransportSecurityState::ExpectStapleState staple_state;
2051 EXPECT_FALSE(GetExpectStapleState(&state, "hsts.example.com", &staple_state));
2052 }
2053
2054 // More advanced test for the HSTS preload process where the trie (generated
2055 // from transport_security_state_static_unittest2.json) contains multiple
2056 // entries with a common prefix. Test that the lookup methods can find all
2057 // entries and correctly decode the different preloaded states (HSTS, HPKP,
2058 // Expect-CT, and Expect-Staple) for each entry.
2059 TEST_F(TransportSecurityStateTest, DecodePreloadedMultiplePrefix) {
2060 SetTransportSecurityStateSourceForTesting(&test2::kHSTSSource);
2061
2062 TransportSecurityState state;
2063 TransportSecurityStateTest::EnableStaticPins(&state);
2064 TransportSecurityStateTest::EnableStaticExpectCT(&state);
2065 TransportSecurityStateTest::SetEnableStaticExpectStaple(&state, true);
2066
2067 TransportSecurityState::STSState sts_state;
2068 TransportSecurityState::PKPState pkp_state;
2069 TransportSecurityState::ExpectCTState ct_state;
2070 TransportSecurityState::ExpectStapleState staple_state;
2071
2072 EXPECT_TRUE(
2073 GetStaticDomainState(&state, "hsts.example.com", &sts_state, &pkp_state));
2074 EXPECT_FALSE(sts_state.include_subdomains);
2075 EXPECT_EQ(TransportSecurityState::STSState::MODE_FORCE_HTTPS,
2076 sts_state.upgrade_mode);
2077 EXPECT_FALSE(pkp_state.include_subdomains);
2078 EXPECT_EQ(GURL(), pkp_state.report_uri);
2079 EXPECT_EQ(0U, pkp_state.spki_hashes.size());
2080 EXPECT_EQ(0U, pkp_state.bad_spki_hashes.size());
2081 EXPECT_FALSE(GetExpectCTState(&state, "hsts.example.com", &ct_state));
2082 EXPECT_FALSE(GetExpectStapleState(&state, "hsts.example.com", &staple_state));
2083
2084 sts_state = TransportSecurityState::STSState();
2085 pkp_state = TransportSecurityState::PKPState();
2086 ct_state = TransportSecurityState::ExpectCTState();
2087 staple_state = TransportSecurityState::ExpectStapleState();
2088 EXPECT_TRUE(
2089 GetStaticDomainState(&state, "hpkp.example.com", &sts_state, &pkp_state));
2090 EXPECT_FALSE(sts_state.include_subdomains);
2091 EXPECT_EQ(TransportSecurityState::STSState::MODE_DEFAULT,
2092 sts_state.upgrade_mode);
2093 EXPECT_TRUE(pkp_state.include_subdomains);
2094 EXPECT_EQ(GURL("https://report.example.com/hpkp-upload"),
2095 pkp_state.report_uri);
2096 EXPECT_EQ(1U, pkp_state.spki_hashes.size());
2097 EXPECT_EQ(pkp_state.spki_hashes[0], GetSampleSPKIHash(0x1));
2098 EXPECT_EQ(0U, pkp_state.bad_spki_hashes.size());
2099 EXPECT_FALSE(GetExpectCTState(&state, "hpkp.example.com", &ct_state));
2100 EXPECT_FALSE(GetExpectStapleState(&state, "hpkp.example.com", &staple_state));
2101
2102 sts_state = TransportSecurityState::STSState();
2103 pkp_state = TransportSecurityState::PKPState();
2104 ct_state = TransportSecurityState::ExpectCTState();
2105 staple_state = TransportSecurityState::ExpectStapleState();
2106 EXPECT_TRUE(GetStaticDomainState(&state, "expect-ct.example.com", &sts_state,
2107 &pkp_state));
2108 EXPECT_FALSE(sts_state.include_subdomains);
2109 EXPECT_EQ(TransportSecurityState::STSState::MODE_DEFAULT,
2110 sts_state.upgrade_mode);
2111 EXPECT_FALSE(pkp_state.include_subdomains);
2112 EXPECT_EQ(GURL(), pkp_state.report_uri);
2113 EXPECT_EQ(0U, pkp_state.spki_hashes.size());
2114 EXPECT_EQ(0U, pkp_state.bad_spki_hashes.size());
2115 EXPECT_TRUE(GetExpectCTState(&state, "expect-ct.example.com", &ct_state));
2116 EXPECT_EQ(GURL("https://report.example.com/ct-upload"), ct_state.report_uri);
2117 EXPECT_FALSE(
2118 GetExpectStapleState(&state, "expect-ct.example.com", &staple_state));
2119
2120 sts_state = TransportSecurityState::STSState();
2121 pkp_state = TransportSecurityState::PKPState();
2122 ct_state = TransportSecurityState::ExpectCTState();
2123 staple_state = TransportSecurityState::ExpectStapleState();
2124 EXPECT_TRUE(GetStaticDomainState(&state, "expect-staple.example.com",
2125 &sts_state, &pkp_state));
2126 EXPECT_FALSE(sts_state.include_subdomains);
2127 EXPECT_EQ(TransportSecurityState::STSState::MODE_DEFAULT,
2128 sts_state.upgrade_mode);
2129 EXPECT_FALSE(pkp_state.include_subdomains);
2130 EXPECT_EQ(GURL(), pkp_state.report_uri);
2131 EXPECT_EQ(0U, pkp_state.spki_hashes.size());
2132 EXPECT_EQ(0U, pkp_state.bad_spki_hashes.size());
2133 EXPECT_FALSE(
2134 GetExpectCTState(&state, "expect-staple.example.com", &ct_state));
2135 EXPECT_TRUE(
2136 GetExpectStapleState(&state, "expect-staple.example.com", &staple_state));
2137 EXPECT_FALSE(staple_state.include_subdomains);
2138 EXPECT_EQ(GURL("https://report.example.com/staple-upload"),
2139 staple_state.report_uri);
2140
2141 sts_state = TransportSecurityState::STSState();
2142 pkp_state = TransportSecurityState::PKPState();
2143 ct_state = TransportSecurityState::ExpectCTState();
2144 staple_state = TransportSecurityState::ExpectStapleState();
2145 EXPECT_TRUE(
2146 GetStaticDomainState(&state, "mix.example.com", &sts_state, &pkp_state));
2147 EXPECT_FALSE(sts_state.include_subdomains);
2148 EXPECT_EQ(TransportSecurityState::STSState::MODE_FORCE_HTTPS,
2149 sts_state.upgrade_mode);
2150 EXPECT_TRUE(pkp_state.include_subdomains);
2151 EXPECT_EQ(GURL(), pkp_state.report_uri);
2152 EXPECT_EQ(1U, pkp_state.spki_hashes.size());
2153 EXPECT_EQ(pkp_state.spki_hashes[0], GetSampleSPKIHash(0x2));
2154 EXPECT_EQ(1U, pkp_state.bad_spki_hashes.size());
2155 EXPECT_EQ(pkp_state.bad_spki_hashes[0], GetSampleSPKIHash(0x1));
2156 EXPECT_TRUE(GetExpectCTState(&state, "mix.example.com", &ct_state));
2157 EXPECT_EQ(GURL("https://report.example.com/ct-upload-alt"),
2158 ct_state.report_uri);
2159 EXPECT_TRUE(GetExpectStapleState(&state, "mix.example.com", &staple_state));
2160 EXPECT_TRUE(staple_state.include_subdomains);
2161 EXPECT_EQ(GURL("https://report.example.com/staple-upload-alt"),
2162 staple_state.report_uri);
2163 }
2164
2165 // More advanced test for the HSTS preload process where the trie (generated
2166 // from transport_security_state_static_unittest3.json) contains a mix of
2167 // entries. Some entries share a prefix with the prefix also having its own
2168 // preloaded state while others share no prefix. This results in a trie with
2169 // several different internal structures. Test that the lookup methods can find
2170 // all entries and correctly decode the different preloaded states (HSTS, HPKP,
2171 // Expect-CT, and Expect-Staple) for each entry.
2172 TEST_F(TransportSecurityStateTest, DecodePreloadedMultipleMix) {
2173 SetTransportSecurityStateSourceForTesting(&test3::kHSTSSource);
2174
2175 TransportSecurityState state;
2176 TransportSecurityStateTest::EnableStaticPins(&state);
2177 TransportSecurityStateTest::EnableStaticExpectCT(&state);
2178 TransportSecurityStateTest::SetEnableStaticExpectStaple(&state, true);
2179
2180 TransportSecurityState::STSState sts_state;
2181 TransportSecurityState::PKPState pkp_state;
2182 TransportSecurityState::ExpectCTState ct_state;
2183 TransportSecurityState::ExpectStapleState staple_state;
2184
2185 EXPECT_TRUE(
2186 GetStaticDomainState(&state, "example.com", &sts_state, &pkp_state));
2187 EXPECT_TRUE(sts_state.include_subdomains);
2188 EXPECT_EQ(TransportSecurityState::STSState::MODE_FORCE_HTTPS,
2189 sts_state.upgrade_mode);
2190 EXPECT_FALSE(pkp_state.include_subdomains);
2191 EXPECT_EQ(GURL(), pkp_state.report_uri);
2192 EXPECT_EQ(0U, pkp_state.spki_hashes.size());
2193 EXPECT_EQ(0U, pkp_state.bad_spki_hashes.size());
2194 EXPECT_FALSE(GetExpectCTState(&state, "example.com", &ct_state));
2195 EXPECT_EQ(GURL(), ct_state.report_uri);
2196 EXPECT_TRUE(GetExpectStapleState(&state, "example.com", &staple_state));
2197 EXPECT_FALSE(staple_state.include_subdomains);
2198 EXPECT_EQ(GURL("https://report.example.com/staple-upload"),
2199 staple_state.report_uri);
2200
2201 sts_state = TransportSecurityState::STSState();
2202 pkp_state = TransportSecurityState::PKPState();
2203 ct_state = TransportSecurityState::ExpectCTState();
2204 staple_state = TransportSecurityState::ExpectStapleState();
2205 EXPECT_TRUE(
2206 GetStaticDomainState(&state, "hpkp.example.com", &sts_state, &pkp_state));
2207 EXPECT_FALSE(sts_state.include_subdomains);
2208 EXPECT_EQ(TransportSecurityState::STSState::MODE_DEFAULT,
2209 sts_state.upgrade_mode);
2210 EXPECT_TRUE(pkp_state.include_subdomains);
2211 EXPECT_EQ(GURL("https://report.example.com/hpkp-upload"),
2212 pkp_state.report_uri);
2213 EXPECT_EQ(1U, pkp_state.spki_hashes.size());
2214 EXPECT_EQ(pkp_state.spki_hashes[0], GetSampleSPKIHash(0x1));
2215 EXPECT_EQ(0U, pkp_state.bad_spki_hashes.size());
2216 EXPECT_FALSE(GetExpectCTState(&state, "hpkp.example.com", &ct_state));
2217 EXPECT_EQ(GURL(), ct_state.report_uri);
2218 EXPECT_FALSE(GetExpectStapleState(&state, "hpkp.example.com", &staple_state));
2219 EXPECT_FALSE(staple_state.include_subdomains);
2220 EXPECT_EQ(GURL(), staple_state.report_uri);
2221
2222 sts_state = TransportSecurityState::STSState();
2223 pkp_state = TransportSecurityState::PKPState();
2224 ct_state = TransportSecurityState::ExpectCTState();
2225 staple_state = TransportSecurityState::ExpectStapleState();
2226 EXPECT_TRUE(
2227 GetStaticDomainState(&state, "example.org", &sts_state, &pkp_state));
2228 EXPECT_FALSE(sts_state.include_subdomains);
2229 EXPECT_EQ(TransportSecurityState::STSState::MODE_FORCE_HTTPS,
2230 sts_state.upgrade_mode);
2231 EXPECT_FALSE(pkp_state.include_subdomains);
2232 EXPECT_EQ(GURL(), pkp_state.report_uri);
2233 EXPECT_EQ(0U, pkp_state.spki_hashes.size());
2234 EXPECT_EQ(0U, pkp_state.bad_spki_hashes.size());
2235 EXPECT_TRUE(GetExpectCTState(&state, "example.org", &ct_state));
2236 EXPECT_EQ(GURL("https://report.example.org/ct-upload"), ct_state.report_uri);
2237 EXPECT_FALSE(GetExpectStapleState(&state, "example.org", &staple_state));
2238 EXPECT_FALSE(staple_state.include_subdomains);
2239 EXPECT_EQ(GURL(), staple_state.report_uri);
2240
2241 sts_state = TransportSecurityState::STSState();
2242 pkp_state = TransportSecurityState::PKPState();
2243 ct_state = TransportSecurityState::ExpectCTState();
2244 staple_state = TransportSecurityState::ExpectStapleState();
2245 EXPECT_TRUE(
2246 GetStaticDomainState(&state, "badssl.com", &sts_state, &pkp_state));
2247 EXPECT_TRUE(sts_state.include_subdomains);
2248 EXPECT_EQ(TransportSecurityState::STSState::MODE_DEFAULT,
2249 sts_state.upgrade_mode);
2250 EXPECT_TRUE(pkp_state.include_subdomains);
2251 EXPECT_EQ(GURL("https://report.example.com/hpkp-upload"),
2252 pkp_state.report_uri);
2253 EXPECT_EQ(1U, pkp_state.spki_hashes.size());
2254 EXPECT_EQ(pkp_state.spki_hashes[0], GetSampleSPKIHash(0x1));
2255 EXPECT_EQ(0U, pkp_state.bad_spki_hashes.size());
2256 EXPECT_FALSE(GetExpectCTState(&state, "badssl.com", &ct_state));
2257 EXPECT_EQ(GURL(), ct_state.report_uri);
2258 EXPECT_TRUE(GetExpectStapleState(&state, "badssl.com", &staple_state));
2259 EXPECT_TRUE(staple_state.include_subdomains);
2260 EXPECT_EQ(GURL("https://report.badssl.com/staple-upload"),
2261 staple_state.report_uri);
2262
2263 sts_state = TransportSecurityState::STSState();
2264 pkp_state = TransportSecurityState::PKPState();
2265 ct_state = TransportSecurityState::ExpectCTState();
2266 staple_state = TransportSecurityState::ExpectStapleState();
2267 EXPECT_TRUE(
2268 GetStaticDomainState(&state, "mix.badssl.com", &sts_state, &pkp_state));
2269 EXPECT_FALSE(sts_state.include_subdomains);
2270 EXPECT_EQ(TransportSecurityState::STSState::MODE_FORCE_HTTPS,
2271 sts_state.upgrade_mode);
2272 EXPECT_TRUE(pkp_state.include_subdomains);
2273 EXPECT_EQ(GURL(), pkp_state.report_uri);
2274 EXPECT_EQ(1U, pkp_state.spki_hashes.size());
2275 EXPECT_EQ(pkp_state.spki_hashes[0], GetSampleSPKIHash(0x2));
2276 EXPECT_EQ(1U, pkp_state.bad_spki_hashes.size());
2277 EXPECT_EQ(pkp_state.bad_spki_hashes[0], GetSampleSPKIHash(0x1));
2278 EXPECT_TRUE(GetExpectCTState(&state, "mix.badssl.com", &ct_state));
2279 EXPECT_EQ(GURL("https://report.example.com/ct-upload"), ct_state.report_uri);
2280 EXPECT_TRUE(GetExpectStapleState(&state, "mix.badssl.com", &staple_state));
2281 EXPECT_TRUE(staple_state.include_subdomains);
2282 EXPECT_EQ(GURL("https://report.badssl.com/staple-upload"),
2283 staple_state.report_uri);
2284 }
2285
2001 static const struct ExpectStapleErrorResponseData { 2286 static const struct ExpectStapleErrorResponseData {
2002 OCSPVerifyResult::ResponseStatus response_status; 2287 OCSPVerifyResult::ResponseStatus response_status;
2003 std::string response_status_string; 2288 std::string response_status_string;
2004 } kExpectStapleReportData[] = { 2289 } kExpectStapleReportData[] = {
2005 {OCSPVerifyResult::MISSING, "MISSING"}, 2290 {OCSPVerifyResult::MISSING, "MISSING"},
2006 {OCSPVerifyResult::ERROR_RESPONSE, "ERROR_RESPONSE"}, 2291 {OCSPVerifyResult::ERROR_RESPONSE, "ERROR_RESPONSE"},
2007 {OCSPVerifyResult::BAD_PRODUCED_AT, "BAD_PRODUCED_AT"}, 2292 {OCSPVerifyResult::BAD_PRODUCED_AT, "BAD_PRODUCED_AT"},
2008 {OCSPVerifyResult::NO_MATCHING_RESPONSE, "NO_MATCHING_RESPONSE"}, 2293 {OCSPVerifyResult::NO_MATCHING_RESPONSE, "NO_MATCHING_RESPONSE"},
2009 {OCSPVerifyResult::INVALID_DATE, "INVALID_DATE"}, 2294 {OCSPVerifyResult::INVALID_DATE, "INVALID_DATE"},
2010 {OCSPVerifyResult::PARSE_RESPONSE_ERROR, "PARSE_RESPONSE_ERROR"}, 2295 {OCSPVerifyResult::PARSE_RESPONSE_ERROR, "PARSE_RESPONSE_ERROR"},
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
2309 base::FieldTrialList::CreateFieldTrial("EnforceCTForProblematicRoots", 2594 base::FieldTrialList::CreateFieldTrial("EnforceCTForProblematicRoots",
2310 "disabled"); 2595 "disabled");
2311 2596
2312 EXPECT_FALSE( 2597 EXPECT_FALSE(
2313 state.ShouldRequireCT("www.example.com", before_cert.get(), hashes)); 2598 state.ShouldRequireCT("www.example.com", before_cert.get(), hashes));
2314 EXPECT_FALSE( 2599 EXPECT_FALSE(
2315 state.ShouldRequireCT("www.example.com", after_cert.get(), hashes)); 2600 state.ShouldRequireCT("www.example.com", after_cert.get(), hashes));
2316 } 2601 }
2317 2602
2318 } // namespace net 2603 } // namespace net
OLDNEW
« no previous file with comments | « net/http/transport_security_state_static_unittest3.json ('k') | net/tools/transport_security_state_generator/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698