| 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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, | 490 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, |
| 491 "accounts.google.com", | 491 "accounts.google.com", |
| 492 true)); | 492 true)); |
| 493 | 493 |
| 494 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "entropia.de", true)); | 494 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "entropia.de", true)); |
| 495 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "www.entropia.de", true)); | 495 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "www.entropia.de", true)); |
| 496 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, "foo.entropia.de", true)); | 496 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, "foo.entropia.de", true)); |
| 497 | 497 |
| 498 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "gmail.com", true)); | 498 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "gmail.com", true)); |
| 499 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "www.gmail.com", true)); | 499 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "www.gmail.com", true)); |
| 500 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, "m.gmail.com", true)); |
| 500 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "googlemail.com", true)); | 501 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "googlemail.com", true)); |
| 501 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, | 502 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, |
| 502 "www.googlemail.com", | 503 "www.googlemail.com", |
| 503 true)); | 504 true)); |
| 505 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, |
| 506 "m.googlemail.com", |
| 507 true)); |
| 504 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, "gmail.com", false)); | 508 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, "gmail.com", false)); |
| 505 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, "www.gmail.com", false)); | 509 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, "www.gmail.com", false)); |
| 510 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, "m.gmail.com", false)); |
| 506 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, "googlemail.com", false)); | 511 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, "googlemail.com", false)); |
| 507 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, | 512 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, |
| 508 "www.googlemail.com", | 513 "www.googlemail.com", |
| 509 false)); | 514 false)); |
| 515 EXPECT_FALSE(state->IsEnabledForHost(&domain_state, |
| 516 "m.googlemail.com", |
| 517 false)); |
| 510 } | 518 } |
| 511 | 519 |
| 512 TEST_F(TransportSecurityStateTest, LongNames) { | 520 TEST_F(TransportSecurityStateTest, LongNames) { |
| 513 scoped_refptr<TransportSecurityState> state( | 521 scoped_refptr<TransportSecurityState> state( |
| 514 new TransportSecurityState); | 522 new TransportSecurityState); |
| 515 const char kLongName[] = | 523 const char kLongName[] = |
| 516 "lookupByWaveIdHashAndWaveIdIdAndWaveIdDomainAndWaveletIdIdAnd" | 524 "lookupByWaveIdHashAndWaveIdIdAndWaveIdDomainAndWaveletIdIdAnd" |
| 517 "WaveletIdDomainAndBlipBlipid"; | 525 "WaveletIdDomainAndBlipBlipid"; |
| 518 TransportSecurityState::DomainState domain_state; | 526 TransportSecurityState::DomainState domain_state; |
| 519 // Just checks that we don't hit a NOTREACHED. | 527 // Just checks that we don't hit a NOTREACHED. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 547 EXPECT_TRUE(state->Serialise(&ser)); | 555 EXPECT_TRUE(state->Serialise(&ser)); |
| 548 bool dirty; | 556 bool dirty; |
| 549 EXPECT_TRUE(state->LoadEntries(ser, &dirty)); | 557 EXPECT_TRUE(state->LoadEntries(ser, &dirty)); |
| 550 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "example.com", false)); | 558 EXPECT_TRUE(state->IsEnabledForHost(&domain_state, "example.com", false)); |
| 551 EXPECT_EQ(1u, domain_state.public_key_hashes.size()); | 559 EXPECT_EQ(1u, domain_state.public_key_hashes.size()); |
| 552 EXPECT_TRUE(0 == memcmp(domain_state.public_key_hashes[0].data, hash.data, | 560 EXPECT_TRUE(0 == memcmp(domain_state.public_key_hashes[0].data, hash.data, |
| 553 sizeof(hash.data))); | 561 sizeof(hash.data))); |
| 554 } | 562 } |
| 555 | 563 |
| 556 } // namespace net | 564 } // namespace net |
| OLD | NEW |