Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: chrome/browser/net/transport_security_persister_unittest.cc

Issue 12680003: net: split net/ssl out of net/base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "content/public/test/test_browser_thread.h" 15 #include "content/public/test/test_browser_thread.h"
16 #include "net/base/transport_security_state.h" 16 #include "net/http/transport_security_state.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 using net::TransportSecurityState; 19 using net::TransportSecurityState;
20 20
21 class TransportSecurityPersisterTest : public testing::Test { 21 class TransportSecurityPersisterTest : public testing::Test {
22 public: 22 public:
23 TransportSecurityPersisterTest() 23 TransportSecurityPersisterTest()
24 : message_loop_(MessageLoop::TYPE_IO), 24 : message_loop_(MessageLoop::TYPE_IO),
25 test_file_thread_(content::BrowserThread::FILE, &message_loop_), 25 test_file_thread_(content::BrowserThread::FILE, &message_loop_),
26 test_io_thread_(content::BrowserThread::IO, &message_loop_) { 26 test_io_thread_(content::BrowserThread::IO, &message_loop_) {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 213
214 TEST_F(TransportSecurityPersisterTest, ForcePreloads) { 214 TEST_F(TransportSecurityPersisterTest, ForcePreloads) {
215 // The static state for docs.google.com, defined in 215 // The static state for docs.google.com, defined in
216 // net/base/transport_security_state_static.h, has pins and mode strict. 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 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 218 // this new policy with |DeserializeFromCommandLine| and expect that the
219 // new policy is in effect, overriding the static policy. 219 // new policy is in effect, overriding the static policy.
220 std::string preload("{" 220 std::string preload("{"
221 "\"4AGT3lHihuMSd5rUj7B4u6At0jlSH3HFePovjPR+oLE=\": {" 221 "\"4AGT3lHihuMSd5rUj7B4u6At0jlSH3HFePovjPR+oLE=\": {"
222 "\"created\": 0.0," 222 "\"created\": 0.0,"
223 "\"expiry\": 2000000000.0," 223 "\"expiry\": 2000000000.0,"
224 "\"include_subdomains\": false," 224 "\"include_subdomains\": false,"
225 "\"mode\": \"pinning-only\"" 225 "\"mode\": \"pinning-only\""
226 "}}"); 226 "}}");
227 227
228 EXPECT_TRUE(persister_->DeserializeFromCommandLine(preload)); 228 EXPECT_TRUE(persister_->DeserializeFromCommandLine(preload));
229 229
230 TransportSecurityState::DomainState domain_state; 230 TransportSecurityState::DomainState domain_state;
231 EXPECT_TRUE(state_.GetDomainState("docs.google.com", true, &domain_state)); 231 EXPECT_TRUE(state_.GetDomainState("docs.google.com", true, &domain_state));
232 EXPECT_FALSE(domain_state.HasPublicKeyPins()); 232 EXPECT_FALSE(domain_state.HasPublicKeyPins());
233 EXPECT_FALSE(domain_state.ShouldUpgradeToSSL()); 233 EXPECT_FALSE(domain_state.ShouldUpgradeToSSL());
234 } 234 }
OLDNEW
« no previous file with comments | « chrome/browser/net/transport_security_persister.cc ('k') | chrome/browser/policy/cloud/device_management_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698