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 "net/base/default_server_bound_cert_store.h" | 5 #include "net/base/default_server_bound_cert_store.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 MockPersistentStore(); | 22 MockPersistentStore(); |
23 | 23 |
24 // DefaultServerBoundCertStore::PersistentStore implementation. | 24 // DefaultServerBoundCertStore::PersistentStore implementation. |
25 virtual bool Load( | 25 virtual bool Load( |
26 std::vector<DefaultServerBoundCertStore::ServerBoundCert*>* certs) | 26 std::vector<DefaultServerBoundCertStore::ServerBoundCert*>* certs) |
27 OVERRIDE; | 27 OVERRIDE; |
28 virtual void AddServerBoundCert( | 28 virtual void AddServerBoundCert( |
29 const DefaultServerBoundCertStore::ServerBoundCert& cert) OVERRIDE; | 29 const DefaultServerBoundCertStore::ServerBoundCert& cert) OVERRIDE; |
30 virtual void DeleteServerBoundCert( | 30 virtual void DeleteServerBoundCert( |
31 const DefaultServerBoundCertStore::ServerBoundCert& cert) OVERRIDE; | 31 const DefaultServerBoundCertStore::ServerBoundCert& cert) OVERRIDE; |
32 virtual void SetClearLocalStateOnExit(bool clear_local_state) OVERRIDE; | 32 virtual void SetForceKeepSessionState() OVERRIDE; |
33 virtual void Flush(const base::Closure& completion_task) OVERRIDE; | 33 virtual void Flush(const base::Closure& completion_task) OVERRIDE; |
34 | 34 |
35 protected: | 35 protected: |
36 virtual ~MockPersistentStore(); | 36 virtual ~MockPersistentStore(); |
37 | 37 |
38 private: | 38 private: |
39 typedef std::map<std::string, DefaultServerBoundCertStore::ServerBoundCert> | 39 typedef std::map<std::string, DefaultServerBoundCertStore::ServerBoundCert> |
40 ServerBoundCertMap; | 40 ServerBoundCertMap; |
41 | 41 |
42 ServerBoundCertMap origin_certs_; | 42 ServerBoundCertMap origin_certs_; |
(...skipping 16 matching lines...) Expand all Loading... |
59 void MockPersistentStore::AddServerBoundCert( | 59 void MockPersistentStore::AddServerBoundCert( |
60 const DefaultServerBoundCertStore::ServerBoundCert& cert) { | 60 const DefaultServerBoundCertStore::ServerBoundCert& cert) { |
61 origin_certs_[cert.server_identifier()] = cert; | 61 origin_certs_[cert.server_identifier()] = cert; |
62 } | 62 } |
63 | 63 |
64 void MockPersistentStore::DeleteServerBoundCert( | 64 void MockPersistentStore::DeleteServerBoundCert( |
65 const DefaultServerBoundCertStore::ServerBoundCert& cert) { | 65 const DefaultServerBoundCertStore::ServerBoundCert& cert) { |
66 origin_certs_.erase(cert.server_identifier()); | 66 origin_certs_.erase(cert.server_identifier()); |
67 } | 67 } |
68 | 68 |
69 void MockPersistentStore::SetClearLocalStateOnExit(bool clear_local_state) {} | 69 void MockPersistentStore::SetForceKeepSessionState() {} |
70 | 70 |
71 void MockPersistentStore::Flush(const base::Closure& completion_task) { | 71 void MockPersistentStore::Flush(const base::Closure& completion_task) { |
72 NOTREACHED(); | 72 NOTREACHED(); |
73 } | 73 } |
74 | 74 |
75 MockPersistentStore::~MockPersistentStore() {} | 75 MockPersistentStore::~MockPersistentStore() {} |
76 | 76 |
77 TEST(DefaultServerBoundCertStoreTest, TestLoading) { | 77 TEST(DefaultServerBoundCertStoreTest, TestLoading) { |
78 scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); | 78 scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
79 | 79 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 base::Time(), | 287 base::Time(), |
288 "g", "h"); | 288 "g", "h"); |
289 | 289 |
290 EXPECT_EQ(4, store.GetCertCount()); | 290 EXPECT_EQ(4, store.GetCertCount()); |
291 ServerBoundCertStore::ServerBoundCertList certs; | 291 ServerBoundCertStore::ServerBoundCertList certs; |
292 store.GetAllServerBoundCerts(&certs); | 292 store.GetAllServerBoundCerts(&certs); |
293 EXPECT_EQ(4u, certs.size()); | 293 EXPECT_EQ(4u, certs.size()); |
294 } | 294 } |
295 | 295 |
296 } // namespace net | 296 } // namespace net |
OLD | NEW |