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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 ASSERT_TRUE(file_util::PathExists( | 92 ASSERT_TRUE(file_util::PathExists( |
93 temp_dir_.path().Append(chrome::kOBCertFilename))); | 93 temp_dir_.path().Append(chrome::kOBCertFilename))); |
94 ASSERT_TRUE(file_util::Delete( | 94 ASSERT_TRUE(file_util::Delete( |
95 temp_dir_.path().Append(chrome::kOBCertFilename), false)); | 95 temp_dir_.path().Append(chrome::kOBCertFilename), false)); |
96 } | 96 } |
97 | 97 |
98 TEST_F(SQLiteServerBoundCertStoreTest, RemoveOnDestruction) { | 98 TEST_F(SQLiteServerBoundCertStoreTest, RemoveOnDestruction) { |
99 store_->SetClearLocalStateOnExit(true); | 99 store_->SetClearLocalStateOnExit(true); |
100 // Replace the store effectively destroying the current one and forcing it | 100 // Replace the store effectively destroying the current one and forcing it |
101 // to write it's data to disk. Then we can see if after loading it again it | 101 // to write its data to disk. Then we can see if after loading it again it |
102 // is still there. | 102 // is still there. |
103 store_ = NULL; | 103 store_ = NULL; |
104 // Make sure we wait until the destructor has run. | 104 // Make sure we wait until the destructor has run. |
105 scoped_refptr<base::ThreadTestHelper> helper( | 105 scoped_refptr<base::ThreadTestHelper> helper( |
106 new base::ThreadTestHelper( | 106 new base::ThreadTestHelper( |
107 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); | 107 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); |
108 ASSERT_TRUE(helper->Run()); | 108 ASSERT_TRUE(helper->Run()); |
109 | 109 |
110 ASSERT_FALSE(file_util::PathExists( | 110 ASSERT_FALSE(file_util::PathExists( |
111 temp_dir_.path().Append(chrome::kOBCertFilename))); | 111 temp_dir_.path().Append(chrome::kOBCertFilename))); |
112 } | 112 } |
113 | 113 |
114 // Test if data is stored as expected in the SQLite database. | 114 // Test if data is stored as expected in the SQLite database. |
115 TEST_F(SQLiteServerBoundCertStoreTest, TestPersistence) { | 115 TEST_F(SQLiteServerBoundCertStoreTest, TestPersistence) { |
116 store_->AddServerBoundCert( | 116 store_->AddServerBoundCert( |
117 net::DefaultServerBoundCertStore::ServerBoundCert( | 117 net::DefaultServerBoundCertStore::ServerBoundCert( |
118 "foo.com", | 118 "foo.com", |
119 net::CLIENT_CERT_ECDSA_SIGN, | 119 net::CLIENT_CERT_ECDSA_SIGN, |
120 base::Time::FromInternalValue(3), | 120 base::Time::FromInternalValue(3), |
121 base::Time::FromInternalValue(4), | 121 base::Time::FromInternalValue(4), |
122 "c", "d")); | 122 "c", "d")); |
123 | 123 |
124 ScopedVector<net::DefaultServerBoundCertStore::ServerBoundCert> certs; | 124 ScopedVector<net::DefaultServerBoundCertStore::ServerBoundCert> certs; |
125 // Replace the store effectively destroying the current one and forcing it | 125 // Replace the store effectively destroying the current one and forcing it |
126 // to write it's data to disk. Then we can see if after loading it again it | 126 // to write its data to disk. Then we can see if after loading it again it |
127 // is still there. | 127 // is still there. |
128 store_ = NULL; | 128 store_ = NULL; |
129 scoped_refptr<base::ThreadTestHelper> helper( | 129 scoped_refptr<base::ThreadTestHelper> helper( |
130 new base::ThreadTestHelper( | 130 new base::ThreadTestHelper( |
131 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); | 131 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); |
132 // Make sure we wait until the destructor has run. | 132 // Make sure we wait until the destructor has run. |
133 ASSERT_TRUE(helper->Run()); | 133 ASSERT_TRUE(helper->Run()); |
134 store_ = new SQLiteServerBoundCertStore( | 134 store_ = new SQLiteServerBoundCertStore( |
135 temp_dir_.path().Append(chrome::kOBCertFilename)); | 135 temp_dir_.path().Append(chrome::kOBCertFilename)); |
136 | 136 |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 | 501 |
502 store_->Flush(base::Bind(&CallbackCounter::Callback, counter.get())); | 502 store_->Flush(base::Bind(&CallbackCounter::Callback, counter.get())); |
503 | 503 |
504 scoped_refptr<base::ThreadTestHelper> helper( | 504 scoped_refptr<base::ThreadTestHelper> helper( |
505 new base::ThreadTestHelper( | 505 new base::ThreadTestHelper( |
506 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); | 506 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); |
507 ASSERT_TRUE(helper->Run()); | 507 ASSERT_TRUE(helper->Run()); |
508 | 508 |
509 ASSERT_EQ(1, counter->callback_count()); | 509 ASSERT_EQ(1, counter->callback_count()); |
510 } | 510 } |
OLD | NEW |