| OLD | NEW |
| 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 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, | 656 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, |
| 657 "foo.ebanking.indovinabank.com.vn", | 657 "foo.ebanking.indovinabank.com.vn", |
| 658 false)); | 658 false)); |
| 659 | 659 |
| 660 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, | 660 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, |
| 661 "epoxate.com", | 661 "epoxate.com", |
| 662 false)); | 662 false)); |
| 663 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, | 663 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, |
| 664 "foo.epoxate.com", | 664 "foo.epoxate.com", |
| 665 false)); | 665 false)); |
| 666 |
| 667 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, |
| 668 "torproject.org", |
| 669 false)); |
| 670 EXPECT_TRUE(domain_state.public_key_hashes.size() != 0); |
| 671 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, |
| 672 "www.torproject.org", |
| 673 false)); |
| 674 EXPECT_TRUE(domain_state.public_key_hashes.size() != 0); |
| 675 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, |
| 676 "check.torproject.org", |
| 677 false)); |
| 678 EXPECT_TRUE(domain_state.public_key_hashes.size() != 0); |
| 679 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, |
| 680 "blog.torproject.org", |
| 681 false)); |
| 682 EXPECT_TRUE(domain_state.public_key_hashes.size() != 0); |
| 683 |
| 684 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, |
| 685 "foo.torproject.org", |
| 686 false)); |
| 666 } | 687 } |
| 667 | 688 |
| 668 TEST_F(TransportSecurityStateTest, LongNames) { | 689 TEST_F(TransportSecurityStateTest, LongNames) { |
| 669 scoped_refptr<TransportSecurityState> state( | 690 scoped_refptr<TransportSecurityState> state( |
| 670 new TransportSecurityState(std::string())); | 691 new TransportSecurityState(std::string())); |
| 671 const char kLongName[] = | 692 const char kLongName[] = |
| 672 "lookupByWaveIdHashAndWaveIdIdAndWaveIdDomainAndWaveletIdIdAnd" | 693 "lookupByWaveIdHashAndWaveIdIdAndWaveIdDomainAndWaveletIdIdAnd" |
| 673 "WaveletIdDomainAndBlipBlipid"; | 694 "WaveletIdDomainAndBlipBlipid"; |
| 674 TransportSecurityState::DomainState domain_state; | 695 TransportSecurityState::DomainState domain_state; |
| 675 // Just checks that we don't hit a NOTREACHED. | 696 // Just checks that we don't hit a NOTREACHED. |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 domain_state = TransportSecurityState::DomainState(); | 869 domain_state = TransportSecurityState::DomainState(); |
| 849 const base::Time current_time(base::Time::Now()); | 870 const base::Time current_time(base::Time::Now()); |
| 850 const base::Time expiry = current_time + base::TimeDelta::FromSeconds(1000); | 871 const base::Time expiry = current_time + base::TimeDelta::FromSeconds(1000); |
| 851 domain_state.expiry = expiry; | 872 domain_state.expiry = expiry; |
| 852 state->EnableHost("www.google.com", domain_state); | 873 state->EnableHost("www.google.com", domain_state); |
| 853 | 874 |
| 854 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "www.google.com", true)); | 875 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "www.google.com", true)); |
| 855 } | 876 } |
| 856 | 877 |
| 857 } // namespace net | 878 } // namespace net |
| OLD | NEW |