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

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

Issue 6869043: Add command-line control of the HSTS preload list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/base/transport_security_state.h" 5 #include "net/base/transport_security_state.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 namespace net { 8 namespace net {
9 9
10 class TransportSecurityStateTest : public testing::Test { 10 class TransportSecurityStateTest : public testing::Test {
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 TransportSecurityState::CanonicalizeHost("www.paypal.com"); 329 TransportSecurityState::CanonicalizeHost("www.paypal.com");
330 const std::string a_www_paypal = 330 const std::string a_www_paypal =
331 TransportSecurityState::CanonicalizeHost("a.www.paypal.com"); 331 TransportSecurityState::CanonicalizeHost("a.www.paypal.com");
332 const std::string abc_paypal = 332 const std::string abc_paypal =
333 TransportSecurityState::CanonicalizeHost("a.b.c.paypal.com"); 333 TransportSecurityState::CanonicalizeHost("a.b.c.paypal.com");
334 const std::string example = 334 const std::string example =
335 TransportSecurityState::CanonicalizeHost("example.com"); 335 TransportSecurityState::CanonicalizeHost("example.com");
336 const std::string aypal = 336 const std::string aypal =
337 TransportSecurityState::CanonicalizeHost("aypal.com"); 337 TransportSecurityState::CanonicalizeHost("aypal.com");
338 338
339 bool b; 339 TransportSecurityState::DomainState domain_state;
340 EXPECT_FALSE(TransportSecurityState::IsPreloadedSTS(paypal, true, &b)); 340 EXPECT_FALSE(TransportSecurityState::IsPreloadedSTS(
341 EXPECT_TRUE(TransportSecurityState::IsPreloadedSTS(www_paypal, true, &b)); 341 paypal, true, &domain_state));
342 EXPECT_FALSE(b); 342 EXPECT_TRUE(TransportSecurityState::IsPreloadedSTS(
343 EXPECT_FALSE(TransportSecurityState::IsPreloadedSTS(a_www_paypal, true, &b)); 343 www_paypal, true, &domain_state));
344 EXPECT_FALSE(TransportSecurityState::IsPreloadedSTS(abc_paypal, true, &b)); 344 EXPECT_FALSE(domain_state.include_subdomains);
345 EXPECT_FALSE(TransportSecurityState::IsPreloadedSTS(example, true, &b)); 345 EXPECT_FALSE(TransportSecurityState::IsPreloadedSTS(
346 EXPECT_FALSE(TransportSecurityState::IsPreloadedSTS(aypal, true, &b)); 346 a_www_paypal, true, &domain_state));
347 EXPECT_FALSE(TransportSecurityState::IsPreloadedSTS(
348 abc_paypal, true, &domain_state));
349 EXPECT_FALSE(TransportSecurityState::IsPreloadedSTS(
350 example, true, &domain_state));
351 EXPECT_FALSE(TransportSecurityState::IsPreloadedSTS(
352 aypal, true, &domain_state));
347 } 353 }
348 354
349 TEST_F(TransportSecurityStateTest, Preloaded) { 355 TEST_F(TransportSecurityStateTest, Preloaded) {
350 scoped_refptr<TransportSecurityState> state( 356 scoped_refptr<TransportSecurityState> state(
351 new TransportSecurityState); 357 new TransportSecurityState);
352 TransportSecurityState::DomainState domain_state; 358 TransportSecurityState::DomainState domain_state;
353 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, "paypal.com", true)); 359 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, "paypal.com", true));
354 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "www.paypal.com", true)); 360 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "www.paypal.com", true));
355 EXPECT_EQ(domain_state.mode, 361 EXPECT_EQ(domain_state.mode,
356 TransportSecurityState::DomainState::MODE_STRICT); 362 TransportSecurityState::DomainState::MODE_STRICT);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 EXPECT_TRUE(state->Serialise(&ser)); 540 EXPECT_TRUE(state->Serialise(&ser));
535 bool dirty; 541 bool dirty;
536 EXPECT_TRUE(state->Deserialise(ser, &dirty)); 542 EXPECT_TRUE(state->Deserialise(ser, &dirty));
537 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "example.com", false)); 543 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "example.com", false));
538 EXPECT_EQ(1u, domain_state.public_key_hashes.size()); 544 EXPECT_EQ(1u, domain_state.public_key_hashes.size());
539 EXPECT_TRUE(0 == memcmp(domain_state.public_key_hashes[0].data, hash.data, 545 EXPECT_TRUE(0 == memcmp(domain_state.public_key_hashes[0].data, hash.data,
540 sizeof(hash.data))); 546 sizeof(hash.data)));
541 } 547 }
542 548
543 } // namespace net 549 } // namespace net
OLDNEW
« net/base/transport_security_state.cc ('K') | « net/base/transport_security_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698