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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // just do it directly rather than call persister_->StateIsDirty. (That uses | 135 // just do it directly rather than call persister_->StateIsDirty. (That uses |
136 // ImportantFileWriter, which has an asynchronous commit interval rather | 136 // ImportantFileWriter, which has an asynchronous commit interval rather |
137 // than block.) Use a different basename just for cleanliness. | 137 // than block.) Use a different basename just for cleanliness. |
138 base::FilePath path = | 138 base::FilePath path = |
139 temp_dir_.path().AppendASCII("TransportSecurityPersisterTest"); | 139 temp_dir_.path().AppendASCII("TransportSecurityPersisterTest"); |
140 EXPECT_TRUE(file_util::WriteFile(path, serialized.c_str(), | 140 EXPECT_TRUE(file_util::WriteFile(path, serialized.c_str(), |
141 serialized.size())); | 141 serialized.size())); |
142 | 142 |
143 // Read the data back. | 143 // Read the data back. |
144 std::string persisted; | 144 std::string persisted; |
145 EXPECT_TRUE(file_util::ReadFileToString(path, &persisted)); | 145 EXPECT_TRUE(base::ReadFileToString(path, &persisted)); |
146 EXPECT_EQ(persisted, serialized); | 146 EXPECT_EQ(persisted, serialized); |
147 bool dirty; | 147 bool dirty; |
148 EXPECT_TRUE(persister_->LoadEntries(persisted, &dirty)); | 148 EXPECT_TRUE(persister_->LoadEntries(persisted, &dirty)); |
149 EXPECT_FALSE(dirty); | 149 EXPECT_FALSE(dirty); |
150 | 150 |
151 // Check that states are the same as saved. | 151 // Check that states are the same as saved. |
152 size_t count = 0; | 152 size_t count = 0; |
153 TransportSecurityState::Iterator j(state_); | 153 TransportSecurityState::Iterator j(state_); |
154 while (j.HasNext()) { | 154 while (j.HasNext()) { |
155 count++; | 155 count++; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 std::string ser; | 202 std::string ser; |
203 EXPECT_TRUE(persister_->SerializeData(&ser)); | 203 EXPECT_TRUE(persister_->SerializeData(&ser)); |
204 bool dirty; | 204 bool dirty; |
205 EXPECT_TRUE(persister_->LoadEntries(ser, &dirty)); | 205 EXPECT_TRUE(persister_->LoadEntries(ser, &dirty)); |
206 EXPECT_TRUE(state_.GetDomainState(kTestDomain, false, &domain_state)); | 206 EXPECT_TRUE(state_.GetDomainState(kTestDomain, false, &domain_state)); |
207 EXPECT_EQ(1u, domain_state.dynamic_spki_hashes.size()); | 207 EXPECT_EQ(1u, domain_state.dynamic_spki_hashes.size()); |
208 EXPECT_EQ(sha1.tag, domain_state.dynamic_spki_hashes[0].tag); | 208 EXPECT_EQ(sha1.tag, domain_state.dynamic_spki_hashes[0].tag); |
209 EXPECT_EQ(0, memcmp(domain_state.dynamic_spki_hashes[0].data(), sha1.data(), | 209 EXPECT_EQ(0, memcmp(domain_state.dynamic_spki_hashes[0].data(), sha1.data(), |
210 sha1.size())); | 210 sha1.size())); |
211 } | 211 } |
OLD | NEW |