diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-10-13 13:24:50 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-10-14 10:57:25 +0000 |
commit | af3d4809763ef308f08ced947a73b624729ac7ea (patch) | |
tree | 4402b911e30383f6c6dace1e8cf3b8e85355db3a /chromium/net/http/transport_security_persister_unittest.cc | |
parent | 0e8ff63a407fe323e215bb1a2c423c09a4747c8a (diff) | |
download | qtwebengine-chromium-af3d4809763ef308f08ced947a73b624729ac7ea.tar.gz |
BASELINE: Update Chromium to 47.0.2526.14
Also adding in sources needed for spellchecking.
Change-Id: Idd44170fa1616f26315188970a8d5ba7d472b18a
Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com>
Diffstat (limited to 'chromium/net/http/transport_security_persister_unittest.cc')
-rw-r--r-- | chromium/net/http/transport_security_persister_unittest.cc | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/chromium/net/http/transport_security_persister_unittest.cc b/chromium/net/http/transport_security_persister_unittest.cc index 53cb2f4b702..0799f5820bd 100644 --- a/chromium/net/http/transport_security_persister_unittest.cc +++ b/chromium/net/http/transport_security_persister_unittest.cc @@ -19,6 +19,8 @@ namespace net { namespace { +const char kReportUri[] = "http://www.example.test/report"; + class TransportSecurityPersisterTest : public testing::Test { public: TransportSecurityPersisterTest() { @@ -86,10 +88,11 @@ TEST_F(TransportSecurityPersisterTest, SerializeData2) { } TEST_F(TransportSecurityPersisterTest, SerializeData3) { + const GURL report_uri(kReportUri); // Add an entry. - HashValue fp1(HASH_VALUE_SHA1); + HashValue fp1(HASH_VALUE_SHA256); memset(fp1.data(), 0, fp1.size()); - HashValue fp2(HASH_VALUE_SHA1); + HashValue fp2(HASH_VALUE_SHA256); memset(fp2.data(), 1, fp2.size()); base::Time expiry = base::Time::Now() + base::TimeDelta::FromSeconds(1000); @@ -99,7 +102,7 @@ TEST_F(TransportSecurityPersisterTest, SerializeData3) { bool include_subdomains = false; state_.AddHSTS("www.example.com", expiry, include_subdomains); state_.AddHPKP("www.example.com", expiry, include_subdomains, - dynamic_spki_hashes); + dynamic_spki_hashes, report_uri); // Add another entry. memset(fp1.data(), 2, fp1.size()); @@ -110,7 +113,7 @@ TEST_F(TransportSecurityPersisterTest, SerializeData3) { dynamic_spki_hashes.push_back(fp2); state_.AddHSTS("www.example.net", expiry, include_subdomains); state_.AddHPKP("www.example.net", expiry, include_subdomains, - dynamic_spki_hashes); + dynamic_spki_hashes, report_uri); // Save a copy of everything. std::set<std::string> sts_saved; @@ -180,21 +183,23 @@ TEST_F(TransportSecurityPersisterTest, SerializeDataOld) { EXPECT_TRUE(dirty); } -TEST_F(TransportSecurityPersisterTest, PublicKeyHashes) { +TEST_F(TransportSecurityPersisterTest, PublicKeyPins) { + const GURL report_uri(kReportUri); TransportSecurityState::PKPState pkp_state; static const char kTestDomain[] = "example.com"; + EXPECT_FALSE(state_.GetDynamicPKPState(kTestDomain, &pkp_state)); HashValueVector hashes; std::string failure_log; EXPECT_FALSE(pkp_state.CheckPublicKeyPins(hashes, &failure_log)); - HashValue sha1(HASH_VALUE_SHA1); - memset(sha1.data(), '1', sha1.size()); - pkp_state.spki_hashes.push_back(sha1); + HashValue sha256(HASH_VALUE_SHA256); + memset(sha256.data(), '1', sha256.size()); + pkp_state.spki_hashes.push_back(sha256); EXPECT_FALSE(pkp_state.CheckPublicKeyPins(hashes, &failure_log)); - hashes.push_back(sha1); + hashes.push_back(sha256); EXPECT_TRUE(pkp_state.CheckPublicKeyPins(hashes, &failure_log)); hashes[0].data()[0] = '2'; @@ -204,8 +209,8 @@ TEST_F(TransportSecurityPersisterTest, PublicKeyHashes) { const base::Time expiry = current_time + base::TimeDelta::FromSeconds(1000); bool include_subdomains = false; state_.AddHSTS(kTestDomain, expiry, include_subdomains); - state_.AddHPKP(kTestDomain, expiry, include_subdomains, - pkp_state.spki_hashes); + state_.AddHPKP(kTestDomain, expiry, include_subdomains, pkp_state.spki_hashes, + report_uri); std::string serialized; EXPECT_TRUE(persister_->SerializeData(&serialized)); bool dirty; @@ -214,9 +219,10 @@ TEST_F(TransportSecurityPersisterTest, PublicKeyHashes) { TransportSecurityState::PKPState new_pkp_state; EXPECT_TRUE(state_.GetDynamicPKPState(kTestDomain, &new_pkp_state)); EXPECT_EQ(1u, new_pkp_state.spki_hashes.size()); - EXPECT_EQ(sha1.tag, new_pkp_state.spki_hashes[0].tag); - EXPECT_EQ( - 0, memcmp(new_pkp_state.spki_hashes[0].data(), sha1.data(), sha1.size())); + EXPECT_EQ(sha256.tag, new_pkp_state.spki_hashes[0].tag); + EXPECT_EQ(0, memcmp(new_pkp_state.spki_hashes[0].data(), sha256.data(), + sha256.size())); + EXPECT_EQ(report_uri, new_pkp_state.report_uri); } } // namespace |