| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = CanonicalizeHost("paypal.com"); | 152 const std::string paypal = CanonicalizeHost("paypal.com"); |
| 153 const std::string www_paypal = CanonicalizeHost("www.paypal.com"); | 153 const std::string www_paypal = CanonicalizeHost("www.paypal.com"); |
| 154 const std::string foo_paypal = CanonicalizeHost("foo.paypal.com"); |
| 154 const std::string a_www_paypal = CanonicalizeHost("a.www.paypal.com"); | 155 const std::string a_www_paypal = CanonicalizeHost("a.www.paypal.com"); |
| 155 const std::string abc_paypal = CanonicalizeHost("a.b.c.paypal.com"); | 156 const std::string abc_paypal = CanonicalizeHost("a.b.c.paypal.com"); |
| 156 const std::string example = CanonicalizeHost("example.com"); | 157 const std::string example = CanonicalizeHost("example.com"); |
| 157 const std::string aypal = CanonicalizeHost("aypal.com"); | 158 const std::string aypal = CanonicalizeHost("aypal.com"); |
| 158 | 159 |
| 159 TransportSecurityState state; | 160 TransportSecurityState state; |
| 160 TransportSecurityState::DomainState domain_state; | 161 TransportSecurityState::DomainState domain_state; |
| 161 | 162 |
| 162 EXPECT_FALSE(GetStaticDomainState(&state, paypal, true, &domain_state)); | 163 EXPECT_TRUE(GetStaticDomainState(&state, paypal, true, &domain_state)); |
| 163 EXPECT_TRUE(GetStaticDomainState(&state, www_paypal, true, &domain_state)); | 164 EXPECT_TRUE(GetStaticDomainState(&state, www_paypal, true, &domain_state)); |
| 165 EXPECT_FALSE(GetStaticDomainState(&state, foo_paypal, true, &domain_state)); |
| 164 EXPECT_FALSE(domain_state.include_subdomains); | 166 EXPECT_FALSE(domain_state.include_subdomains); |
| 165 EXPECT_FALSE(GetStaticDomainState(&state, a_www_paypal, true, &domain_state)); | 167 EXPECT_FALSE(GetStaticDomainState(&state, a_www_paypal, true, &domain_state)); |
| 166 EXPECT_FALSE(GetStaticDomainState(&state, abc_paypal, true, &domain_state)); | 168 EXPECT_FALSE(GetStaticDomainState(&state, abc_paypal, true, &domain_state)); |
| 167 EXPECT_FALSE(GetStaticDomainState(&state, example, true, &domain_state)); | 169 EXPECT_FALSE(GetStaticDomainState(&state, example, true, &domain_state)); |
| 168 EXPECT_FALSE(GetStaticDomainState(&state, aypal, true, &domain_state)); | 170 EXPECT_FALSE(GetStaticDomainState(&state, aypal, true, &domain_state)); |
| 169 } | 171 } |
| 170 | 172 |
| 171 TEST_F(TransportSecurityStateTest, PreloadedDomainSet) { | 173 TEST_F(TransportSecurityStateTest, PreloadedDomainSet) { |
| 172 TransportSecurityState state; | 174 TransportSecurityState state; |
| 173 TransportSecurityState::DomainState domain_state; | 175 TransportSecurityState::DomainState domain_state; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 TEST_F(TransportSecurityStateTest, Preloaded) { | 224 TEST_F(TransportSecurityStateTest, Preloaded) { |
| 223 TransportSecurityState state; | 225 TransportSecurityState state; |
| 224 TransportSecurityState::DomainState domain_state; | 226 TransportSecurityState::DomainState domain_state; |
| 225 | 227 |
| 226 // We do more extensive checks for the first domain. | 228 // We do more extensive checks for the first domain. |
| 227 EXPECT_TRUE(state.GetDomainState("www.paypal.com", true, &domain_state)); | 229 EXPECT_TRUE(state.GetDomainState("www.paypal.com", true, &domain_state)); |
| 228 EXPECT_EQ(domain_state.upgrade_mode, | 230 EXPECT_EQ(domain_state.upgrade_mode, |
| 229 TransportSecurityState::DomainState::MODE_FORCE_HTTPS); | 231 TransportSecurityState::DomainState::MODE_FORCE_HTTPS); |
| 230 EXPECT_FALSE(domain_state.include_subdomains); | 232 EXPECT_FALSE(domain_state.include_subdomains); |
| 231 | 233 |
| 232 EXPECT_FALSE(HasState("paypal.com")); | 234 EXPECT_TRUE(HasState("paypal.com")); |
| 233 EXPECT_FALSE(HasState("www2.paypal.com")); | 235 EXPECT_FALSE(HasState("www2.paypal.com")); |
| 234 EXPECT_FALSE(HasState("www2.paypal.com")); | 236 EXPECT_FALSE(HasState("www2.paypal.com")); |
| 235 | 237 |
| 236 // Google hosts: | 238 // Google hosts: |
| 237 | 239 |
| 238 EXPECT_TRUE(ShouldRedirect("chrome.google.com")); | 240 EXPECT_TRUE(ShouldRedirect("chrome.google.com")); |
| 239 EXPECT_TRUE(ShouldRedirect("checkout.google.com")); | 241 EXPECT_TRUE(ShouldRedirect("checkout.google.com")); |
| 240 EXPECT_TRUE(ShouldRedirect("health.google.com")); | 242 EXPECT_TRUE(ShouldRedirect("health.google.com")); |
| 241 EXPECT_TRUE(ShouldRedirect("docs.google.com")); | 243 EXPECT_TRUE(ShouldRedirect("docs.google.com")); |
| 242 EXPECT_TRUE(ShouldRedirect("sites.google.com")); | 244 EXPECT_TRUE(ShouldRedirect("sites.google.com")); |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 // Expect to fail for SNI hosts when not searching the SNI list: | 832 // Expect to fail for SNI hosts when not searching the SNI list: |
| 831 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( | 833 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( |
| 832 "gmail.com", false)); | 834 "gmail.com", false)); |
| 833 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( | 835 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( |
| 834 "googlegroups.com", false)); | 836 "googlegroups.com", false)); |
| 835 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( | 837 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( |
| 836 "www.googlegroups.com", false)); | 838 "www.googlegroups.com", false)); |
| 837 } | 839 } |
| 838 | 840 |
| 839 } // namespace net | 841 } // namespace net |
| OLD | NEW |