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

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

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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
« no previous file with comments | « net/http/transport_security_state_static.json ('k') | net/http/url_security_manager_win.cc » ('j') | 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // We do more extensive checks for the first domain. 292 // We do more extensive checks for the first domain.
293 EXPECT_TRUE( 293 EXPECT_TRUE(
294 state.GetStaticDomainState("www.paypal.com", &domain_state)); 294 state.GetStaticDomainState("www.paypal.com", &domain_state));
295 EXPECT_EQ(domain_state.sts.upgrade_mode, 295 EXPECT_EQ(domain_state.sts.upgrade_mode,
296 TransportSecurityState::DomainState::MODE_FORCE_HTTPS); 296 TransportSecurityState::DomainState::MODE_FORCE_HTTPS);
297 EXPECT_FALSE(domain_state.sts.include_subdomains); 297 EXPECT_FALSE(domain_state.sts.include_subdomains);
298 EXPECT_FALSE(domain_state.pkp.include_subdomains); 298 EXPECT_FALSE(domain_state.pkp.include_subdomains);
299 299
300 EXPECT_TRUE(HasStaticState("paypal.com")); 300 EXPECT_TRUE(HasStaticState("paypal.com"));
301 EXPECT_FALSE(HasStaticState("www2.paypal.com")); 301 EXPECT_FALSE(HasStaticState("www2.paypal.com"));
302 EXPECT_FALSE(HasStaticState("www2.paypal.com"));
303 302
304 // Google hosts: 303 // Google hosts:
305 304
306 EXPECT_TRUE(StaticShouldRedirect("chrome.google.com")); 305 EXPECT_TRUE(StaticShouldRedirect("chrome.google.com"));
307 EXPECT_TRUE(StaticShouldRedirect("checkout.google.com")); 306 EXPECT_TRUE(StaticShouldRedirect("checkout.google.com"));
308 EXPECT_TRUE(StaticShouldRedirect("wallet.google.com")); 307 EXPECT_TRUE(StaticShouldRedirect("wallet.google.com"));
309 EXPECT_TRUE(StaticShouldRedirect("docs.google.com")); 308 EXPECT_TRUE(StaticShouldRedirect("docs.google.com"));
310 EXPECT_TRUE(StaticShouldRedirect("sites.google.com")); 309 EXPECT_TRUE(StaticShouldRedirect("sites.google.com"));
311 EXPECT_TRUE(StaticShouldRedirect("drive.google.com")); 310 EXPECT_TRUE(StaticShouldRedirect("drive.google.com"));
312 EXPECT_TRUE(StaticShouldRedirect("spreadsheets.google.com")); 311 EXPECT_TRUE(StaticShouldRedirect("spreadsheets.google.com"));
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 EXPECT_FALSE(domain_state.pkp.spki_hashes.empty()); 527 EXPECT_FALSE(domain_state.pkp.spki_hashes.empty());
529 EXPECT_TRUE(state.GetStaticDomainState("www.torproject.org", &domain_state)); 528 EXPECT_TRUE(state.GetStaticDomainState("www.torproject.org", &domain_state));
530 EXPECT_FALSE(domain_state.pkp.spki_hashes.empty()); 529 EXPECT_FALSE(domain_state.pkp.spki_hashes.empty());
531 EXPECT_TRUE( 530 EXPECT_TRUE(
532 state.GetStaticDomainState("check.torproject.org", &domain_state)); 531 state.GetStaticDomainState("check.torproject.org", &domain_state));
533 EXPECT_FALSE(domain_state.pkp.spki_hashes.empty()); 532 EXPECT_FALSE(domain_state.pkp.spki_hashes.empty());
534 EXPECT_TRUE(state.GetStaticDomainState("blog.torproject.org", &domain_state)); 533 EXPECT_TRUE(state.GetStaticDomainState("blog.torproject.org", &domain_state));
535 EXPECT_FALSE(domain_state.pkp.spki_hashes.empty()); 534 EXPECT_FALSE(domain_state.pkp.spki_hashes.empty());
536 535
537 EXPECT_TRUE(HasStaticPublicKeyPins("www.twitter.com")); 536 EXPECT_TRUE(HasStaticPublicKeyPins("www.twitter.com"));
537
538 // Check that Facebook subdomains have pinning but not HSTS.
539 EXPECT_TRUE(state.GetStaticDomainState("facebook.com", &domain_state));
540 EXPECT_FALSE(domain_state.pkp.spki_hashes.empty());
541 EXPECT_TRUE(StaticShouldRedirect("facebook.com"));
542
543 EXPECT_TRUE(state.GetStaticDomainState("foo.facebook.com", &domain_state));
544 EXPECT_FALSE(domain_state.pkp.spki_hashes.empty());
545 EXPECT_FALSE(StaticShouldRedirect("foo.facebook.com"));
546
547 EXPECT_TRUE(state.GetStaticDomainState("www.facebook.com", &domain_state));
548 EXPECT_FALSE(domain_state.pkp.spki_hashes.empty());
549 EXPECT_TRUE(StaticShouldRedirect("www.facebook.com"));
550
551 EXPECT_TRUE(
552 state.GetStaticDomainState("foo.www.facebook.com", &domain_state));
553 EXPECT_FALSE(domain_state.pkp.spki_hashes.empty());
554 EXPECT_TRUE(StaticShouldRedirect("foo.www.facebook.com"));
538 } 555 }
539 556
540 TEST_F(TransportSecurityStateTest, LongNames) { 557 TEST_F(TransportSecurityStateTest, LongNames) {
541 TransportSecurityState state; 558 TransportSecurityState state;
542 const char kLongName[] = 559 const char kLongName[] =
543 "lookupByWaveIdHashAndWaveIdIdAndWaveIdDomainAndWaveletIdIdAnd" 560 "lookupByWaveIdHashAndWaveIdIdAndWaveIdDomainAndWaveletIdIdAnd"
544 "WaveletIdDomainAndBlipBlipid"; 561 "WaveletIdDomainAndBlipBlipid";
545 TransportSecurityState::DomainState domain_state; 562 TransportSecurityState::DomainState domain_state;
546 // Just checks that we don't hit a NOTREACHED. 563 // Just checks that we don't hit a NOTREACHED.
547 EXPECT_FALSE(state.GetStaticDomainState(kLongName, &domain_state)); 564 EXPECT_FALSE(state.GetStaticDomainState(kLongName, &domain_state));
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 // These hosts used to only be HSTS when SNI was available. 768 // These hosts used to only be HSTS when SNI was available.
752 EXPECT_TRUE(TransportSecurityState::IsGooglePinnedProperty( 769 EXPECT_TRUE(TransportSecurityState::IsGooglePinnedProperty(
753 "gmail.com")); 770 "gmail.com"));
754 EXPECT_TRUE(TransportSecurityState::IsGooglePinnedProperty( 771 EXPECT_TRUE(TransportSecurityState::IsGooglePinnedProperty(
755 "googlegroups.com")); 772 "googlegroups.com"));
756 EXPECT_TRUE(TransportSecurityState::IsGooglePinnedProperty( 773 EXPECT_TRUE(TransportSecurityState::IsGooglePinnedProperty(
757 "www.googlegroups.com")); 774 "www.googlegroups.com"));
758 } 775 }
759 776
760 } // namespace net 777 } // namespace net
OLDNEW
« no previous file with comments | « net/http/transport_security_state_static.json ('k') | net/http/url_security_manager_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698