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

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

Issue 54623005: net: allow invalid TransportSecurityState to process invalid DNS names. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix browser tests. Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « net/http/transport_security_state.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 bool include_subdomains = true; 110 bool include_subdomains = true;
111 state.AddHSTS("yahoo.com", expiry, include_subdomains); 111 state.AddHSTS("yahoo.com", expiry, include_subdomains);
112 EXPECT_TRUE(state.GetDomainState("yahoo.com", true, &domain_state)); 112 EXPECT_TRUE(state.GetDomainState("yahoo.com", true, &domain_state));
113 EXPECT_TRUE(state.GetDomainState("foo.yahoo.com", true, &domain_state)); 113 EXPECT_TRUE(state.GetDomainState("foo.yahoo.com", true, &domain_state));
114 EXPECT_TRUE(state.GetDomainState("foo.bar.yahoo.com", true, &domain_state)); 114 EXPECT_TRUE(state.GetDomainState("foo.bar.yahoo.com", true, &domain_state));
115 EXPECT_TRUE(state.GetDomainState("foo.bar.baz.yahoo.com", true, 115 EXPECT_TRUE(state.GetDomainState("foo.bar.baz.yahoo.com", true,
116 &domain_state)); 116 &domain_state));
117 EXPECT_FALSE(state.GetDomainState("com", true, &domain_state)); 117 EXPECT_FALSE(state.GetDomainState("com", true, &domain_state));
118 } 118 }
119 119
120 TEST_F(TransportSecurityStateTest, InvalidDomains) {
121 TransportSecurityState state;
122 TransportSecurityState::DomainState domain_state;
123 const base::Time current_time(base::Time::Now());
124 const base::Time expiry = current_time + base::TimeDelta::FromSeconds(1000);
125
126 EXPECT_FALSE(state.GetDomainState("yahoo.com", true, &domain_state));
127 bool include_subdomains = true;
128 state.AddHSTS("yahoo.com", expiry, include_subdomains);
129 EXPECT_TRUE(state.GetDomainState("www-.foo.yahoo.com", true, &domain_state));
130 EXPECT_TRUE(state.GetDomainState("2\x01.foo.yahoo.com", true, &domain_state));
131 }
132
120 TEST_F(TransportSecurityStateTest, DeleteAllDynamicDataSince) { 133 TEST_F(TransportSecurityStateTest, DeleteAllDynamicDataSince) {
121 TransportSecurityState state; 134 TransportSecurityState state;
122 TransportSecurityState::DomainState domain_state; 135 TransportSecurityState::DomainState domain_state;
123 const base::Time current_time(base::Time::Now()); 136 const base::Time current_time(base::Time::Now());
124 const base::Time expiry = current_time + base::TimeDelta::FromSeconds(1000); 137 const base::Time expiry = current_time + base::TimeDelta::FromSeconds(1000);
125 const base::Time older = current_time - base::TimeDelta::FromSeconds(1000); 138 const base::Time older = current_time - base::TimeDelta::FromSeconds(1000);
126 139
127 EXPECT_FALSE(state.GetDomainState("yahoo.com", true, &domain_state)); 140 EXPECT_FALSE(state.GetDomainState("yahoo.com", true, &domain_state));
128 bool include_subdomains = false; 141 bool include_subdomains = false;
129 state.AddHSTS("yahoo.com", expiry, include_subdomains); 142 state.AddHSTS("yahoo.com", expiry, include_subdomains);
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 // Expect to fail for SNI hosts when not searching the SNI list: 814 // Expect to fail for SNI hosts when not searching the SNI list:
802 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( 815 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty(
803 "gmail.com", false)); 816 "gmail.com", false));
804 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( 817 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty(
805 "googlegroups.com", false)); 818 "googlegroups.com", false));
806 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty( 819 EXPECT_FALSE(TransportSecurityState::IsGooglePinnedProperty(
807 "www.googlegroups.com", false)); 820 "www.googlegroups.com", false));
808 } 821 }
809 822
810 } // namespace net 823 } // namespace net
OLDNEW
« no previous file with comments | « net/http/transport_security_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698