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

Unified Diff: net/base/default_origin_bound_cert_store_unittest.cc

Issue 8890073: Handle Origin Bound Certificate expiration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review changes Created 9 years 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_service.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
diff --git a/net/base/default_origin_bound_cert_store_unittest.cc b/net/base/default_origin_bound_cert_store_unittest.cc
index 6b888e02740a6661eb5d91a40822201dd4c39390..a62191ac678bd695ef8afbea21d9fbd6e6dda1b6 100644
--- a/net/base/default_origin_bound_cert_store_unittest.cc
+++ b/net/base/default_origin_bound_cert_store_unittest.cc
@@ -77,40 +77,59 @@ TEST(DefaultOriginBoundCertStoreTest, TestLoading) {
persistent_store->AddOriginBoundCert(
DefaultOriginBoundCertStore::OriginBoundCert(
- "https://encrypted.google.com/", CLIENT_CERT_RSA_SIGN, "a", "b"));
+ "https://encrypted.google.com/",
+ CLIENT_CERT_RSA_SIGN,
+ base::Time(),
+ "a", "b"));
persistent_store->AddOriginBoundCert(
DefaultOriginBoundCertStore::OriginBoundCert(
- "https://www.verisign.com/", CLIENT_CERT_ECDSA_SIGN, "c", "d"));
+ "https://www.verisign.com/",
+ CLIENT_CERT_ECDSA_SIGN,
+ base::Time(),
+ "c", "d"));
// Make sure certs load properly.
DefaultOriginBoundCertStore store(persistent_store.get());
EXPECT_EQ(2, store.GetCertCount());
store.SetOriginBoundCert(
- "https://www.verisign.com/", CLIENT_CERT_RSA_SIGN, "e", "f");
+ "https://www.verisign.com/",
+ CLIENT_CERT_RSA_SIGN,
+ base::Time(),
+ "e", "f");
EXPECT_EQ(2, store.GetCertCount());
store.SetOriginBoundCert(
- "https://www.twitter.com/", CLIENT_CERT_RSA_SIGN, "g", "h");
+ "https://www.twitter.com/",
+ CLIENT_CERT_RSA_SIGN,
+ base::Time(),
+ "g", "h");
EXPECT_EQ(3, store.GetCertCount());
}
TEST(DefaultOriginBoundCertStoreTest, TestSettingAndGetting) {
DefaultOriginBoundCertStore store(NULL);
SSLClientCertType type;
+ base::Time expiration_time;
std::string private_key, cert;
EXPECT_EQ(0, store.GetCertCount());
EXPECT_FALSE(store.GetOriginBoundCert("https://www.verisign.com/",
&type,
+ &expiration_time,
&private_key,
&cert));
EXPECT_TRUE(private_key.empty());
EXPECT_TRUE(cert.empty());
store.SetOriginBoundCert(
- "https://www.verisign.com/", CLIENT_CERT_RSA_SIGN, "i", "j");
+ "https://www.verisign.com/",
+ CLIENT_CERT_RSA_SIGN,
+ base::Time::FromInternalValue(123),
+ "i", "j");
EXPECT_TRUE(store.GetOriginBoundCert("https://www.verisign.com/",
&type,
+ &expiration_time,
&private_key,
&cert));
EXPECT_EQ(CLIENT_CERT_RSA_SIGN, type);
+ EXPECT_EQ(123, expiration_time.ToInternalValue());
EXPECT_EQ("i", private_key);
EXPECT_EQ("j", cert);
}
@@ -120,19 +139,28 @@ TEST(DefaultOriginBoundCertStoreTest, TestDuplicateCerts) {
DefaultOriginBoundCertStore store(persistent_store.get());
SSLClientCertType type;
+ base::Time expiration_time;
std::string private_key, cert;
EXPECT_EQ(0, store.GetCertCount());
store.SetOriginBoundCert(
- "https://www.verisign.com/", CLIENT_CERT_RSA_SIGN, "a", "b");
+ "https://www.verisign.com/",
+ CLIENT_CERT_RSA_SIGN,
+ base::Time::FromInternalValue(123),
+ "a", "b");
store.SetOriginBoundCert(
- "https://www.verisign.com/", CLIENT_CERT_ECDSA_SIGN, "c", "d");
+ "https://www.verisign.com/",
+ CLIENT_CERT_ECDSA_SIGN,
+ base::Time::FromInternalValue(456),
+ "c", "d");
EXPECT_EQ(1, store.GetCertCount());
EXPECT_TRUE(store.GetOriginBoundCert("https://www.verisign.com/",
&type,
+ &expiration_time,
&private_key,
&cert));
EXPECT_EQ(CLIENT_CERT_ECDSA_SIGN, type);
+ EXPECT_EQ(456, expiration_time.ToInternalValue());
EXPECT_EQ("c", private_key);
EXPECT_EQ("d", cert);
}
@@ -143,11 +171,20 @@ TEST(DefaultOriginBoundCertStoreTest, TestDeleteAll) {
EXPECT_EQ(0, store.GetCertCount());
store.SetOriginBoundCert(
- "https://www.verisign.com/", CLIENT_CERT_RSA_SIGN, "a", "b");
+ "https://www.verisign.com/",
+ CLIENT_CERT_RSA_SIGN,
+ base::Time(),
+ "a", "b");
store.SetOriginBoundCert(
- "https://www.google.com/", CLIENT_CERT_RSA_SIGN, "c", "d");
+ "https://www.google.com/",
+ CLIENT_CERT_RSA_SIGN,
+ base::Time(),
+ "c", "d");
store.SetOriginBoundCert(
- "https://www.harvard.com/", CLIENT_CERT_RSA_SIGN, "e", "f");
+ "https://www.harvard.com/",
+ CLIENT_CERT_RSA_SIGN,
+ base::Time(),
+ "e", "f");
EXPECT_EQ(3, store.GetCertCount());
store.DeleteAll();
@@ -159,28 +196,38 @@ TEST(DefaultOriginBoundCertStoreTest, TestDelete) {
DefaultOriginBoundCertStore store(persistent_store.get());
SSLClientCertType type;
+ base::Time expiration_time;
std::string private_key, cert;
EXPECT_EQ(0, store.GetCertCount());
store.SetOriginBoundCert(
- "https://www.verisign.com/", CLIENT_CERT_RSA_SIGN, "a", "b");
+ "https://www.verisign.com/",
+ CLIENT_CERT_RSA_SIGN,
+ base::Time(),
+ "a", "b");
store.SetOriginBoundCert(
- "https://www.google.com/", CLIENT_CERT_ECDSA_SIGN, "c", "d");
+ "https://www.google.com/",
+ CLIENT_CERT_ECDSA_SIGN,
+ base::Time(),
+ "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/",
&type,
+ &expiration_time,
&private_key,
&cert));
EXPECT_TRUE(store.GetOriginBoundCert("https://www.google.com/",
&type,
+ &expiration_time,
&private_key,
&cert));
store.DeleteOriginBoundCert("https://www.google.com/");
EXPECT_EQ(0, store.GetCertCount());
EXPECT_FALSE(store.GetOriginBoundCert("https://www.google.com/",
&type,
+ &expiration_time,
&private_key,
&cert));
}
@@ -191,13 +238,25 @@ TEST(DefaultOriginBoundCertStoreTest, TestGetAll) {
EXPECT_EQ(0, store.GetCertCount());
store.SetOriginBoundCert(
- "https://www.verisign.com/", CLIENT_CERT_RSA_SIGN, "a", "b");
+ "https://www.verisign.com/",
+ CLIENT_CERT_RSA_SIGN,
+ base::Time(),
+ "a", "b");
store.SetOriginBoundCert(
- "https://www.google.com/", CLIENT_CERT_ECDSA_SIGN, "c", "d");
+ "https://www.google.com/",
+ CLIENT_CERT_ECDSA_SIGN,
+ base::Time(),
+ "c", "d");
store.SetOriginBoundCert(
- "https://www.harvard.com/", CLIENT_CERT_RSA_SIGN, "e", "f");
+ "https://www.harvard.com/",
+ CLIENT_CERT_RSA_SIGN,
+ base::Time(),
+ "e", "f");
store.SetOriginBoundCert(
- "https://www.mit.com/", CLIENT_CERT_RSA_SIGN, "g", "h");
+ "https://www.mit.com/",
+ CLIENT_CERT_RSA_SIGN,
+ base::Time(),
+ "g", "h");
EXPECT_EQ(4, store.GetCertCount());
std::vector<OriginBoundCertStore::OriginBoundCert> certs;
« no previous file with comments | « net/base/default_origin_bound_cert_store.cc ('k') | net/base/origin_bound_cert_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698