Index: net/ssl/default_server_bound_cert_store_unittest.cc |
diff --git a/net/ssl/default_server_bound_cert_store_unittest.cc b/net/ssl/default_server_bound_cert_store_unittest.cc |
index a742e0c3f1cf4a697ed1e2d805fd6516273b965d..e174605621437f3f39368f5e98cb5d33cd50d4a7 100644 |
--- a/net/ssl/default_server_bound_cert_store_unittest.cc |
+++ b/net/ssl/default_server_bound_cert_store_unittest.cc |
@@ -57,9 +57,8 @@ class AsyncGetCertHelper { |
bool called_; |
}; |
-void GetAllCallback( |
- ServerBoundCertStore::ServerBoundCertList* dest, |
- const ServerBoundCertStore::ServerBoundCertList& result) { |
+void GetAllCallback(ServerBoundCertStore::ServerBoundCertList* dest, |
+ const ServerBoundCertStore::ServerBoundCertList& result) { |
*dest = result; |
} |
@@ -86,11 +85,12 @@ class MockPersistentStore |
ServerBoundCertMap origin_certs_; |
}; |
-MockPersistentStore::MockPersistentStore() {} |
+MockPersistentStore::MockPersistentStore() { |
+} |
void MockPersistentStore::Load(const LoadedCallback& loaded_callback) { |
- scoped_ptr<ScopedVector<DefaultServerBoundCertStore::ServerBoundCert> > |
- certs(new ScopedVector<DefaultServerBoundCertStore::ServerBoundCert>()); |
+ scoped_ptr<ScopedVector<DefaultServerBoundCertStore::ServerBoundCert> > certs( |
+ new ScopedVector<DefaultServerBoundCertStore::ServerBoundCert>()); |
ServerBoundCertMap::iterator it; |
for (it = origin_certs_.begin(); it != origin_certs_.end(); ++it) { |
@@ -112,9 +112,11 @@ void MockPersistentStore::DeleteServerBoundCert( |
origin_certs_.erase(cert.server_identifier()); |
} |
-void MockPersistentStore::SetForceKeepSessionState() {} |
+void MockPersistentStore::SetForceKeepSessionState() { |
+} |
-MockPersistentStore::~MockPersistentStore() {} |
+MockPersistentStore::~MockPersistentStore() { |
+} |
} // namespace |
@@ -123,39 +125,26 @@ TEST(DefaultServerBoundCertStoreTest, TestLoading) { |
persistent_store->AddServerBoundCert( |
DefaultServerBoundCertStore::ServerBoundCert( |
- "google.com", |
- base::Time(), |
- base::Time(), |
- "a", "b")); |
+ "google.com", base::Time(), base::Time(), "a", "b")); |
persistent_store->AddServerBoundCert( |
DefaultServerBoundCertStore::ServerBoundCert( |
- "verisign.com", |
- base::Time(), |
- base::Time(), |
- "c", "d")); |
+ "verisign.com", base::Time(), base::Time(), "c", "d")); |
// Make sure certs load properly. |
DefaultServerBoundCertStore store(persistent_store.get()); |
// Load has not occurred yet. |
EXPECT_EQ(0, store.GetCertCount()); |
store.SetServerBoundCert( |
- "verisign.com", |
- base::Time(), |
- base::Time(), |
- "e", "f"); |
+ "verisign.com", base::Time(), base::Time(), "e", "f"); |
// Wait for load & queued set task. |
base::MessageLoop::current()->RunUntilIdle(); |
EXPECT_EQ(2, store.GetCertCount()); |
- store.SetServerBoundCert( |
- "twitter.com", |
- base::Time(), |
- base::Time(), |
- "g", "h"); |
+ store.SetServerBoundCert("twitter.com", base::Time(), base::Time(), "g", "h"); |
// Set should be synchronous now that load is done. |
EXPECT_EQ(3, store.GetCertCount()); |
} |
-//TODO(mattm): add more tests of without a persistent store? |
+// TODO(mattm): add more tests of without a persistent store? |
TEST(DefaultServerBoundCertStoreTest, TestSettingAndGetting) { |
// No persistent store, all calls will be synchronous. |
DefaultServerBoundCertStore store(NULL); |
@@ -170,11 +159,11 @@ TEST(DefaultServerBoundCertStoreTest, TestSettingAndGetting) { |
base::Bind(&GetCertCallbackNotCalled))); |
EXPECT_TRUE(private_key.empty()); |
EXPECT_TRUE(cert.empty()); |
- store.SetServerBoundCert( |
- "verisign.com", |
- base::Time::FromInternalValue(123), |
- base::Time::FromInternalValue(456), |
- "i", "j"); |
+ store.SetServerBoundCert("verisign.com", |
+ base::Time::FromInternalValue(123), |
+ base::Time::FromInternalValue(456), |
+ "i", |
+ "j"); |
EXPECT_EQ(OK, |
store.GetServerBoundCert("verisign.com", |
&expiration_time, |
@@ -193,16 +182,16 @@ TEST(DefaultServerBoundCertStoreTest, TestDuplicateCerts) { |
base::Time expiration_time; |
std::string private_key, cert; |
EXPECT_EQ(0, store.GetCertCount()); |
- store.SetServerBoundCert( |
- "verisign.com", |
- base::Time::FromInternalValue(123), |
- base::Time::FromInternalValue(1234), |
- "a", "b"); |
- store.SetServerBoundCert( |
- "verisign.com", |
- base::Time::FromInternalValue(456), |
- base::Time::FromInternalValue(4567), |
- "c", "d"); |
+ store.SetServerBoundCert("verisign.com", |
+ base::Time::FromInternalValue(123), |
+ base::Time::FromInternalValue(1234), |
+ "a", |
+ "b"); |
+ store.SetServerBoundCert("verisign.com", |
+ base::Time::FromInternalValue(456), |
+ base::Time::FromInternalValue(4567), |
+ "c", |
+ "d"); |
// Wait for load & queued set tasks. |
base::MessageLoop::current()->RunUntilIdle(); |
@@ -220,11 +209,12 @@ TEST(DefaultServerBoundCertStoreTest, TestDuplicateCerts) { |
TEST(DefaultServerBoundCertStoreTest, TestAsyncGet) { |
scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
- persistent_store->AddServerBoundCert(ServerBoundCertStore::ServerBoundCert( |
- "verisign.com", |
- base::Time::FromInternalValue(123), |
- base::Time::FromInternalValue(1234), |
- "a", "b")); |
+ persistent_store->AddServerBoundCert( |
+ ServerBoundCertStore::ServerBoundCert("verisign.com", |
+ base::Time::FromInternalValue(123), |
+ base::Time::FromInternalValue(1234), |
+ "a", |
+ "b")); |
DefaultServerBoundCertStore store(persistent_store.get()); |
AsyncGetCertHelper helper; |
@@ -257,20 +247,9 @@ TEST(DefaultServerBoundCertStoreTest, TestDeleteAll) { |
DefaultServerBoundCertStore store(persistent_store.get()); |
store.SetServerBoundCert( |
- "verisign.com", |
- base::Time(), |
- base::Time(), |
- "a", "b"); |
- store.SetServerBoundCert( |
- "google.com", |
- base::Time(), |
- base::Time(), |
- "c", "d"); |
- store.SetServerBoundCert( |
- "harvard.com", |
- base::Time(), |
- base::Time(), |
- "e", "f"); |
+ "verisign.com", base::Time(), base::Time(), "a", "b"); |
+ store.SetServerBoundCert("google.com", base::Time(), base::Time(), "c", "d"); |
+ store.SetServerBoundCert("harvard.com", base::Time(), base::Time(), "e", "f"); |
// Wait for load & queued set tasks. |
base::MessageLoop::current()->RunUntilIdle(); |
@@ -284,15 +263,9 @@ TEST(DefaultServerBoundCertStoreTest, TestDeleteAll) { |
TEST(DefaultServerBoundCertStoreTest, TestAsyncGetAndDeleteAll) { |
scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
persistent_store->AddServerBoundCert(ServerBoundCertStore::ServerBoundCert( |
- "verisign.com", |
- base::Time(), |
- base::Time(), |
- "a", "b")); |
+ "verisign.com", base::Time(), base::Time(), "a", "b")); |
persistent_store->AddServerBoundCert(ServerBoundCertStore::ServerBoundCert( |
- "google.com", |
- base::Time(), |
- base::Time(), |
- "c", "d")); |
+ "google.com", base::Time(), base::Time(), "c", "d")); |
ServerBoundCertStore::ServerBoundCertList pre_certs; |
ServerBoundCertStore::ServerBoundCertList post_certs; |
@@ -319,18 +292,11 @@ TEST(DefaultServerBoundCertStoreTest, TestDelete) { |
std::string private_key, cert; |
EXPECT_EQ(0, store.GetCertCount()); |
store.SetServerBoundCert( |
- "verisign.com", |
- base::Time(), |
- base::Time(), |
- "a", "b"); |
+ "verisign.com", base::Time(), base::Time(), "a", "b"); |
// Wait for load & queued set task. |
base::MessageLoop::current()->RunUntilIdle(); |
- store.SetServerBoundCert( |
- "google.com", |
- base::Time(), |
- base::Time(), |
- "c", "d"); |
+ store.SetServerBoundCert("google.com", base::Time(), base::Time(), "c", "d"); |
EXPECT_EQ(2, store.GetCertCount()); |
int delete_finished = 0; |
@@ -365,16 +331,18 @@ TEST(DefaultServerBoundCertStoreTest, TestDelete) { |
TEST(DefaultServerBoundCertStoreTest, TestAsyncDelete) { |
scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
- persistent_store->AddServerBoundCert(ServerBoundCertStore::ServerBoundCert( |
- "a.com", |
- base::Time::FromInternalValue(1), |
- base::Time::FromInternalValue(2), |
- "a", "b")); |
- persistent_store->AddServerBoundCert(ServerBoundCertStore::ServerBoundCert( |
- "b.com", |
- base::Time::FromInternalValue(3), |
- base::Time::FromInternalValue(4), |
- "c", "d")); |
+ persistent_store->AddServerBoundCert( |
+ ServerBoundCertStore::ServerBoundCert("a.com", |
+ base::Time::FromInternalValue(1), |
+ base::Time::FromInternalValue(2), |
+ "a", |
+ "b")); |
+ persistent_store->AddServerBoundCert( |
+ ServerBoundCertStore::ServerBoundCert("b.com", |
+ base::Time::FromInternalValue(3), |
+ base::Time::FromInternalValue(4), |
+ "c", |
+ "d")); |
DefaultServerBoundCertStore store(persistent_store.get()); |
int delete_finished = 0; |
store.DeleteServerBoundCert("a.com", |
@@ -387,15 +355,19 @@ TEST(DefaultServerBoundCertStoreTest, TestAsyncDelete) { |
std::string cert = "not set"; |
EXPECT_EQ(0, store.GetCertCount()); |
EXPECT_EQ(ERR_IO_PENDING, |
- store.GetServerBoundCert( |
- "a.com", &expiration_time, &private_key, &cert, |
- base::Bind(&AsyncGetCertHelper::Callback, |
- base::Unretained(&a_helper)))); |
+ store.GetServerBoundCert("a.com", |
+ &expiration_time, |
+ &private_key, |
+ &cert, |
+ base::Bind(&AsyncGetCertHelper::Callback, |
+ base::Unretained(&a_helper)))); |
EXPECT_EQ(ERR_IO_PENDING, |
- store.GetServerBoundCert( |
- "b.com", &expiration_time, &private_key, &cert, |
- base::Bind(&AsyncGetCertHelper::Callback, |
- base::Unretained(&b_helper)))); |
+ store.GetServerBoundCert("b.com", |
+ &expiration_time, |
+ &private_key, |
+ &cert, |
+ base::Bind(&AsyncGetCertHelper::Callback, |
+ base::Unretained(&b_helper)))); |
EXPECT_EQ(0, delete_finished); |
EXPECT_FALSE(a_helper.called_); |
@@ -425,25 +397,10 @@ TEST(DefaultServerBoundCertStoreTest, TestGetAll) { |
EXPECT_EQ(0, store.GetCertCount()); |
store.SetServerBoundCert( |
- "verisign.com", |
- base::Time(), |
- base::Time(), |
- "a", "b"); |
- store.SetServerBoundCert( |
- "google.com", |
- base::Time(), |
- base::Time(), |
- "c", "d"); |
- store.SetServerBoundCert( |
- "harvard.com", |
- base::Time(), |
- base::Time(), |
- "e", "f"); |
- store.SetServerBoundCert( |
- "mit.com", |
- base::Time(), |
- base::Time(), |
- "g", "h"); |
+ "verisign.com", base::Time(), base::Time(), "a", "b"); |
+ store.SetServerBoundCert("google.com", base::Time(), base::Time(), "c", "d"); |
+ store.SetServerBoundCert("harvard.com", base::Time(), base::Time(), "e", "f"); |
+ store.SetServerBoundCert("mit.com", base::Time(), base::Time(), "g", "h"); |
// Wait for load & queued set tasks. |
base::MessageLoop::current()->RunUntilIdle(); |
@@ -458,15 +415,8 @@ TEST(DefaultServerBoundCertStoreTest, TestInitializeFrom) { |
DefaultServerBoundCertStore store(persistent_store.get()); |
store.SetServerBoundCert( |
- "preexisting.com", |
- base::Time(), |
- base::Time(), |
- "a", "b"); |
- store.SetServerBoundCert( |
- "both.com", |
- base::Time(), |
- base::Time(), |
- "c", "d"); |
+ "preexisting.com", base::Time(), base::Time(), "a", "b"); |
+ store.SetServerBoundCert("both.com", base::Time(), base::Time(), "c", "d"); |
// Wait for load & queued set tasks. |
base::MessageLoop::current()->RunUntilIdle(); |
EXPECT_EQ(2, store.GetCertCount()); |
@@ -477,12 +427,10 @@ TEST(DefaultServerBoundCertStoreTest, TestInitializeFrom) { |
base::Time(), |
base::Time(), |
// Key differs from above to test that existing entries are overwritten. |
- "e", "f")); |
+ "e", |
+ "f")); |
source_certs.push_back(ServerBoundCertStore::ServerBoundCert( |
- "copied.com", |
- base::Time(), |
- base::Time(), |
- "g", "h")); |
+ "copied.com", base::Time(), base::Time(), "g", "h")); |
store.InitializeFrom(source_certs); |
EXPECT_EQ(3, store.GetCertCount()); |
@@ -506,15 +454,9 @@ TEST(DefaultServerBoundCertStoreTest, TestInitializeFrom) { |
TEST(DefaultServerBoundCertStoreTest, TestAsyncInitializeFrom) { |
scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
persistent_store->AddServerBoundCert(ServerBoundCertStore::ServerBoundCert( |
- "preexisting.com", |
- base::Time(), |
- base::Time(), |
- "a", "b")); |
+ "preexisting.com", base::Time(), base::Time(), "a", "b")); |
persistent_store->AddServerBoundCert(ServerBoundCertStore::ServerBoundCert( |
- "both.com", |
- base::Time(), |
- base::Time(), |
- "c", "d")); |
+ "both.com", base::Time(), base::Time(), "c", "d")); |
DefaultServerBoundCertStore store(persistent_store.get()); |
ServerBoundCertStore::ServerBoundCertList source_certs; |
@@ -523,12 +465,10 @@ TEST(DefaultServerBoundCertStoreTest, TestAsyncInitializeFrom) { |
base::Time(), |
base::Time(), |
// Key differs from above to test that existing entries are overwritten. |
- "e", "f")); |
+ "e", |
+ "f")); |
source_certs.push_back(ServerBoundCertStore::ServerBoundCert( |
- "copied.com", |
- base::Time(), |
- base::Time(), |
- "g", "h")); |
+ "copied.com", base::Time(), base::Time(), "g", "h")); |
store.InitializeFrom(source_certs); |
EXPECT_EQ(0, store.GetCertCount()); |
// Wait for load & queued tasks. |