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

Unified Diff: net/base/x509_certificate_unittest.cc

Issue 4645001: Change the HTTP cache to cache the entire certificate chain for SSL sites (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/net/base
Patch Set: Rebase before commit Created 9 years, 8 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/x509_certificate_unittest.cc
diff --git a/net/base/x509_certificate_unittest.cc b/net/base/x509_certificate_unittest.cc
index f49e035a70ab95399d53d6e0afa26c4b47fab759..89ea582541aa6b660615649515c62d805aefbb9f 100644
--- a/net/base/x509_certificate_unittest.cc
+++ b/net/base/x509_certificate_unittest.cc
@@ -670,17 +670,40 @@ TEST(X509CertificateTest, Cache) {
}
TEST(X509CertificateTest, Pickle) {
- scoped_refptr<X509Certificate> cert1(X509Certificate::CreateFromBytes(
- reinterpret_cast<const char*>(google_der), sizeof(google_der)));
+ X509Certificate::OSCertHandle google_cert_handle =
+ X509Certificate::CreateOSCertHandleFromBytes(
+ reinterpret_cast<const char*>(google_der), sizeof(google_der));
+ X509Certificate::OSCertHandle thawte_cert_handle =
+ X509Certificate::CreateOSCertHandleFromBytes(
+ reinterpret_cast<const char*>(thawte_der), sizeof(thawte_der));
+
+ X509Certificate::OSCertHandles intermediates;
+ intermediates.push_back(thawte_cert_handle);
+ // Faking SOURCE_LONE_CERT_IMPORT so that when the pickled certificate is
+ // read, it successfully evicts |cert| from the X509Certificate::Cache.
+ // This will be fixed when http://crbug.com/49377 is fixed.
+ scoped_refptr<X509Certificate> cert = X509Certificate::CreateFromHandle(
+ google_cert_handle,
+ X509Certificate::SOURCE_LONE_CERT_IMPORT,
+ intermediates);
+ ASSERT_NE(static_cast<X509Certificate*>(NULL), cert.get());
+
+ X509Certificate::FreeOSCertHandle(google_cert_handle);
+ X509Certificate::FreeOSCertHandle(thawte_cert_handle);
Pickle pickle;
- cert1->Persist(&pickle);
+ cert->Persist(&pickle);
void* iter = NULL;
- scoped_refptr<X509Certificate> cert2(
- X509Certificate::CreateFromPickle(pickle, &iter));
-
- EXPECT_EQ(cert1, cert2);
+ scoped_refptr<X509Certificate> cert_from_pickle =
+ X509Certificate::CreateFromPickle(
+ pickle, &iter, X509Certificate::PICKLETYPE_CERTIFICATE_CHAIN);
+ ASSERT_NE(static_cast<X509Certificate*>(NULL), cert_from_pickle);
+ EXPECT_NE(cert.get(), cert_from_pickle.get());
+ EXPECT_TRUE(X509Certificate::IsSameOSCert(
+ cert->os_cert_handle(), cert_from_pickle->os_cert_handle()));
+ EXPECT_TRUE(cert->HasIntermediateCertificates(
+ cert_from_pickle->GetIntermediateCertificates()));
}
TEST(X509CertificateTest, Policy) {

Powered by Google App Engine
This is Rietveld 408576698