OLD | NEW |
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 "chrome/browser/net/transport_security_persister.h" | 5 #include "chrome/browser/net/transport_security_persister.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 std::string ser; | 203 std::string ser; |
204 EXPECT_TRUE(persister_->SerializeData(&ser)); | 204 EXPECT_TRUE(persister_->SerializeData(&ser)); |
205 bool dirty; | 205 bool dirty; |
206 EXPECT_TRUE(persister_->LoadEntries(ser, &dirty)); | 206 EXPECT_TRUE(persister_->LoadEntries(ser, &dirty)); |
207 EXPECT_TRUE(state_.GetDomainState(kTestDomain, false, &domain_state)); | 207 EXPECT_TRUE(state_.GetDomainState(kTestDomain, false, &domain_state)); |
208 EXPECT_EQ(1u, domain_state.dynamic_spki_hashes.size()); | 208 EXPECT_EQ(1u, domain_state.dynamic_spki_hashes.size()); |
209 EXPECT_EQ(sha1.tag, domain_state.dynamic_spki_hashes[0].tag); | 209 EXPECT_EQ(sha1.tag, domain_state.dynamic_spki_hashes[0].tag); |
210 EXPECT_EQ(0, memcmp(domain_state.dynamic_spki_hashes[0].data(), sha1.data(), | 210 EXPECT_EQ(0, memcmp(domain_state.dynamic_spki_hashes[0].data(), sha1.data(), |
211 sha1.size())); | 211 sha1.size())); |
212 } | 212 } |
213 | |
214 TEST_F(TransportSecurityPersisterTest, ForcePreloads) { | |
215 // The static state for docs.google.com, defined in | |
216 // net/http/transport_security_state_static.h, has pins and mode strict. | |
217 // This new policy overrides that with no pins and a weaker mode. We apply | |
218 // this new policy with |DeserializeFromCommandLine| and expect that the | |
219 // new policy is in effect, overriding the static policy. | |
220 std::string preload("{" | |
221 "\"4AGT3lHihuMSd5rUj7B4u6At0jlSH3HFePovjPR+oLE=\": {" | |
222 "\"created\": 0.0," | |
223 "\"expiry\": 2000000000.0," | |
224 "\"include_subdomains\": false," | |
225 "\"mode\": \"pinning-only\"" | |
226 "}}"); | |
227 | |
228 EXPECT_TRUE(persister_->DeserializeFromCommandLine(preload)); | |
229 | |
230 TransportSecurityState::DomainState domain_state; | |
231 EXPECT_TRUE(state_.GetDomainState("docs.google.com", true, &domain_state)); | |
232 EXPECT_FALSE(domain_state.HasPublicKeyPins()); | |
233 EXPECT_FALSE(domain_state.ShouldUpgradeToSSL()); | |
234 } | |
OLD | NEW |