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

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
« no previous file with comments | « net/base/default_origin_bound_cert_store.cc ('k') | net/base/origin_bound_cert_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/default_origin_bound_cert_store_unittest.cc
===================================================================
--- net/base/default_origin_bound_cert_store_unittest.cc (revision 96316)
+++ net/base/default_origin_bound_cert_store_unittest.cc (working copy)
@@ -82,31 +82,101 @@
"https://www.verisign.com/", "c", "d"));
// Make sure certs load properly.
- scoped_ptr<DefaultOriginBoundCertStore> store(
- new DefaultOriginBoundCertStore(persistent_store));
- EXPECT_EQ(2, store->GetCertCount());
- EXPECT_TRUE(store->SetOriginBoundCert("https://www.verisign.com/", "e", "f"));
- EXPECT_EQ(2, store->GetCertCount());
- EXPECT_TRUE(store->SetOriginBoundCert("https://www.twitter.com/", "g", "h"));
- EXPECT_EQ(3, store->GetCertCount());
+ DefaultOriginBoundCertStore store(persistent_store.get());
+ EXPECT_EQ(2, store.GetCertCount());
+ store.SetOriginBoundCert("https://www.verisign.com/", "e", "f");
+ EXPECT_EQ(2, store.GetCertCount());
+ store.SetOriginBoundCert("https://www.twitter.com/", "g", "h");
+ EXPECT_EQ(3, store.GetCertCount());
}
TEST(DefaultOriginBoundCertStoreTest, TestSettingAndGetting) {
- scoped_ptr<DefaultOriginBoundCertStore> store(
- new DefaultOriginBoundCertStore(NULL));
+ DefaultOriginBoundCertStore store(NULL);
std::string private_key, cert;
- EXPECT_EQ(0, store->GetCertCount());
- EXPECT_FALSE(store->GetOriginBoundCert("https://www.verisign.com/",
+ EXPECT_EQ(0, store.GetCertCount());
+ EXPECT_FALSE(store.GetOriginBoundCert("https://www.verisign.com/",
&private_key,
&cert));
EXPECT_TRUE(private_key.empty());
EXPECT_TRUE(cert.empty());
- EXPECT_TRUE(store->SetOriginBoundCert("https://www.verisign.com/", "i", "j"));
- EXPECT_TRUE(store->GetOriginBoundCert("https://www.verisign.com/",
+ store.SetOriginBoundCert("https://www.verisign.com/", "i", "j");
+ EXPECT_TRUE(store.GetOriginBoundCert("https://www.verisign.com/",
&private_key,
&cert));
EXPECT_EQ("i", private_key);
EXPECT_EQ("j", cert);
}
+TEST(DefaultOriginBoundCertStoreTest, TestDuplicateCerts) {
+ scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore);
+ DefaultOriginBoundCertStore store(persistent_store.get());
+
+ std::string private_key, cert;
+ EXPECT_EQ(0, store.GetCertCount());
+ store.SetOriginBoundCert("https://www.verisign.com/", "a", "b");
+ 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);
+ DefaultOriginBoundCertStore store(persistent_store.get());
+
+ EXPECT_EQ(0, store.GetCertCount());
+ store.SetOriginBoundCert("https://www.verisign.com/", "a", "b");
+ store.SetOriginBoundCert("https://www.google.com/", "c", "d");
+ 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);
+ DefaultOriginBoundCertStore store(persistent_store.get());
+
+ std::string private_key, cert;
+ EXPECT_EQ(0, store.GetCertCount());
+ store.SetOriginBoundCert("https://www.verisign.com/", "a", "b");
+ 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);
+ DefaultOriginBoundCertStore store(persistent_store.get());
+
+ EXPECT_EQ(0, store.GetCertCount());
+ store.SetOriginBoundCert("https://www.verisign.com/", "a", "b");
+ store.SetOriginBoundCert("https://www.google.com/", "c", "d");
+ store.SetOriginBoundCert("https://www.harvard.com/", "e", "f");
+ 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
« no previous file with comments | « net/base/default_origin_bound_cert_store.cc ('k') | net/base/origin_bound_cert_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698