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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 bool include_subdomains = false; | 142 bool include_subdomains = false; |
143 state.AddHSTS("yahoo.com", expiry, include_subdomains); | 143 state.AddHSTS("yahoo.com", expiry, include_subdomains); |
144 | 144 |
145 EXPECT_TRUE(state.GetDomainState("yahoo.com", true, &domain_state)); | 145 EXPECT_TRUE(state.GetDomainState("yahoo.com", true, &domain_state)); |
146 EXPECT_FALSE(state.GetDomainState("example.com", true, &domain_state)); | 146 EXPECT_FALSE(state.GetDomainState("example.com", true, &domain_state)); |
147 EXPECT_TRUE(state.DeleteDynamicDataForHost("yahoo.com")); | 147 EXPECT_TRUE(state.DeleteDynamicDataForHost("yahoo.com")); |
148 EXPECT_FALSE(state.GetDomainState("yahoo.com", true, &domain_state)); | 148 EXPECT_FALSE(state.GetDomainState("yahoo.com", true, &domain_state)); |
149 } | 149 } |
150 | 150 |
151 TEST_F(TransportSecurityStateTest, IsPreloaded) { | 151 TEST_F(TransportSecurityStateTest, IsPreloaded) { |
152 const std::string paypal = | 152 const std::string paypal = CanonicalizeHost("paypal.com"); |
153 CanonicalizeHost("paypal.com"); | 153 const std::string www_paypal = CanonicalizeHost("www.paypal.com"); |
154 const std::string www_paypal = | 154 const std::string a_www_paypal = CanonicalizeHost("a.www.paypal.com"); |
155 CanonicalizeHost("www.paypal.com"); | 155 const std::string abc_paypal = CanonicalizeHost("a.b.c.paypal.com"); |
156 const std::string a_www_paypal = | 156 const std::string example = CanonicalizeHost("example.com"); |
157 CanonicalizeHost("a.www.paypal.com"); | 157 const std::string aypal = CanonicalizeHost("aypal.com"); |
158 const std::string abc_paypal = | |
159 CanonicalizeHost("a.b.c.paypal.com"); | |
160 const std::string example = | |
161 CanonicalizeHost("example.com"); | |
162 const std::string aypal = | |
163 CanonicalizeHost("aypal.com"); | |
164 | 158 |
165 TransportSecurityState state; | 159 TransportSecurityState state; |
166 TransportSecurityState::DomainState domain_state; | 160 TransportSecurityState::DomainState domain_state; |
167 | 161 |
168 EXPECT_FALSE(GetStaticDomainState(&state, paypal, true, &domain_state)); | 162 EXPECT_FALSE(GetStaticDomainState(&state, paypal, true, &domain_state)); |
169 EXPECT_TRUE(GetStaticDomainState(&state, www_paypal, true, &domain_state)); | 163 EXPECT_TRUE(GetStaticDomainState(&state, www_paypal, true, &domain_state)); |
170 EXPECT_FALSE(domain_state.include_subdomains); | 164 EXPECT_FALSE(domain_state.include_subdomains); |
171 EXPECT_FALSE(GetStaticDomainState(&state, a_www_paypal, true, &domain_state)); | 165 EXPECT_FALSE(GetStaticDomainState(&state, a_www_paypal, true, &domain_state)); |
172 EXPECT_FALSE(GetStaticDomainState(&state, abc_paypal, true, &domain_state)); | 166 EXPECT_FALSE(GetStaticDomainState(&state, abc_paypal, true, &domain_state)); |
173 EXPECT_FALSE(GetStaticDomainState(&state, example, true, &domain_state)); | 167 EXPECT_FALSE(GetStaticDomainState(&state, example, true, &domain_state)); |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 // Expect to fail for SNI hosts when not searching the SNI list: | 830 // Expect to fail for SNI hosts when not searching the SNI list: |
837 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( | 831 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( |
838 "gmail.com", false)); | 832 "gmail.com", false)); |
839 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( | 833 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( |
840 "googlegroups.com", false)); | 834 "googlegroups.com", false)); |
841 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( | 835 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( |
842 "www.googlegroups.com", false)); | 836 "www.googlegroups.com", false)); |
843 } | 837 } |
844 | 838 |
845 } // namespace net | 839 } // namespace net |
OLD | NEW |