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

Unified Diff: net/base/default_origin_bound_cert_store_unittest.cc

Issue 7585037: Add functionality to OriginBoundCertStore interface and implementations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698