Chromium Code Reviews| Index: net/base/default_origin_bound_cert_store_unittest.cc |
| =================================================================== |
| --- net/base/default_origin_bound_cert_store_unittest.cc (revision 94628) |
| +++ net/base/default_origin_bound_cert_store_unittest.cc (working copy) |
| @@ -109,4 +109,80 @@ |
| EXPECT_EQ("j", cert); |
| } |
| +TEST(DefaultOriginBoundCertStoreTest, TestDuplicateCerts) { |
| + scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
| + scoped_ptr<DefaultOriginBoundCertStore> store( |
| + new DefaultOriginBoundCertStore(persistent_store)); |
|
wtc
2011/08/10 21:35:59
Consider using a local variable:
DefaultOriginBo
rkn
2011/08/16 21:11:45
I know this isn't exactly the change you were sugg
|
| + |
| + std::string private_key, cert; |
| + EXPECT_EQ(0, store->GetCertCount()); |
| + EXPECT_TRUE(store->SetOriginBoundCert("https://www.verisign.com/", "a", "b")); |
| + EXPECT_TRUE(store->SetOriginBoundCert("https://www.verisign.com/", "c", "d")); |
| + |
| + EXPECT_EQ(1, store->GetCertCount()); |
| + EXPECT_TRUE(store->GetOriginBoundCert("https://www.verisign.com/", |
| + &private_key, |
| + &cert)); |
| + EXPECT_EQ("c", private_key); |
| + EXPECT_EQ("d", cert); |
| +} |
| + |
| +TEST(DefaultOriginBoundCertStoreTest, TestDeleteAll) { |
| + scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
| + scoped_ptr<DefaultOriginBoundCertStore> store( |
| + new DefaultOriginBoundCertStore(persistent_store)); |
| + |
| + EXPECT_EQ(0, store->GetCertCount()); |
| + EXPECT_TRUE(store->SetOriginBoundCert("https://www.verisign.com/", "a", "b")); |
| + EXPECT_TRUE(store->SetOriginBoundCert("https://www.google.com/", "c", "d")); |
| + EXPECT_TRUE(store->SetOriginBoundCert("https://www.harvard.com/", "e", "f")); |
| + |
| + EXPECT_EQ(3, store->GetCertCount()); |
| + store->DeleteAll(); |
| + EXPECT_EQ(0, store->GetCertCount()); |
| +} |
| + |
| +TEST(DefaultOriginBoundCertStoreTest, TestDelete) { |
| + scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
| + scoped_ptr<DefaultOriginBoundCertStore> store( |
| + new DefaultOriginBoundCertStore(persistent_store)); |
| + |
| + std::string private_key, cert; |
| + EXPECT_EQ(0, store->GetCertCount()); |
| + EXPECT_TRUE(store->SetOriginBoundCert("https://www.verisign.com/", "a", "b")); |
| + EXPECT_TRUE(store->SetOriginBoundCert("https://www.google.com/", "c", "d")); |
| + |
| + EXPECT_EQ(2, store->GetCertCount()); |
| + store->DeleteOriginBoundCert("https://www.verisign.com/"); |
| + EXPECT_EQ(1, store->GetCertCount()); |
| + EXPECT_FALSE(store->GetOriginBoundCert("https://www.verisign.com/", |
| + &private_key, |
| + &cert)); |
| + EXPECT_TRUE(store->GetOriginBoundCert("https://www.google.com/", |
| + &private_key, |
| + &cert)); |
| + store->DeleteOriginBoundCert("https://www.google.com/"); |
| + EXPECT_EQ(0, store->GetCertCount()); |
| + EXPECT_FALSE(store->GetOriginBoundCert("https://www.google.com/", |
| + &private_key, |
| + &cert)); |
| +} |
| + |
| +TEST(DefaultOriginBoundCertStoreTest, TestGetAll) { |
| + scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); |
| + scoped_ptr<DefaultOriginBoundCertStore> store( |
| + new DefaultOriginBoundCertStore(persistent_store)); |
| + |
| + EXPECT_EQ(0, store->GetCertCount()); |
| + EXPECT_TRUE(store->SetOriginBoundCert("https://www.verisign.com/", "a", "b")); |
| + EXPECT_TRUE(store->SetOriginBoundCert("https://www.google.com/", "c", "d")); |
| + EXPECT_TRUE(store->SetOriginBoundCert("https://www.harvard.com/", "e", "f")); |
| + EXPECT_TRUE(store->SetOriginBoundCert("https://www.mit.com/", "g", "h")); |
| + |
| + EXPECT_EQ(4, store->GetCertCount()); |
| + std::vector<OriginBoundCertStore::OriginBoundCertInfo> certs; |
| + store->GetAllOriginBoundCerts(&certs); |
| + EXPECT_EQ(4u, certs.size()); |
| +} |
| + |
| } // namespace net |