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

Unified Diff: net/cert/test_root_certs_unittest.cc

Issue 137553004: NSS Cros multiprofile: trust roots added by a profile shouldn't apply to other profiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ios TestRootCerts fix Created 6 years, 10 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/cert/test_root_certs_unittest.cc
diff --git a/net/cert/test_root_certs_unittest.cc b/net/cert/test_root_certs_unittest.cc
index 74c3551862bc6f787f40c250f978c24854e27cf8..336543ad4fff23373a6500a4922e4b6cbae0c932 100644
--- a/net/cert/test_root_certs_unittest.cc
+++ b/net/cert/test_root_certs_unittest.cc
@@ -18,6 +18,10 @@
#include <nss.h>
#endif
+#if defined(OS_IOS)
+#include "net/cert/x509_util_ios.h"
+#endif
+
namespace net {
namespace {
@@ -135,6 +139,52 @@ TEST(TestRootCertsTest, OverrideTrust) {
EXPECT_EQ(bad_verify_result.cert_status, restored_verify_result.cert_status);
}
+#if defined(USE_NSS) || defined(OS_IOS) || \
+ (defined(USE_OPENSSL) && !defined(OS_ANDROID))
+TEST(TestRootCertsTest, Contains) {
+ // Another test root certificate.
+ const char kRootCertificateFile2[] = "2048-rsa-root.pem";
+
+ TestRootCerts* test_roots = TestRootCerts::GetInstance();
+ ASSERT_NE(static_cast<TestRootCerts*>(NULL), test_roots);
+
+ scoped_refptr<X509Certificate> root_cert_1 =
+ ImportCertFromFile(GetTestCertsDirectory(), kRootCertificateFile);
+ ASSERT_NE(static_cast<X509Certificate*>(NULL), root_cert_1.get());
+
+ scoped_refptr<X509Certificate> root_cert_2 =
+ ImportCertFromFile(GetTestCertsDirectory(), kRootCertificateFile2);
+ ASSERT_NE(static_cast<X509Certificate*>(NULL), root_cert_2.get());
+
+#if defined(OS_IOS)
+ x509_util_ios::NSSCertificate nss_certificate_1(
+ root_cert_1->os_cert_handle());
+ x509_util_ios::NSSCertificate nss_certificate_2(
+ root_cert_2->os_cert_handle());
+ CERTCertificate* handle_1 = nss_certificate_1.cert_handle();
+ CERTCertificate* handle_2 = nss_certificate_2.cert_handle();
+#else
+ X509Certificate::OSCertHandle handle_1 = root_cert_1->os_cert_handle();
+ X509Certificate::OSCertHandle handle_2 = root_cert_2->os_cert_handle();
+#endif
+
+ EXPECT_FALSE(test_roots->Contains(handle_1));
+ EXPECT_FALSE(test_roots->Contains(handle_2));
+
+ EXPECT_TRUE(test_roots->Add(root_cert_1.get()));
+ EXPECT_TRUE(test_roots->Contains(handle_1));
+ EXPECT_FALSE(test_roots->Contains(handle_2));
+
+ EXPECT_TRUE(test_roots->Add(root_cert_2.get()));
+ EXPECT_TRUE(test_roots->Contains(handle_1));
+ EXPECT_TRUE(test_roots->Contains(handle_2));
+
+ test_roots->Clear();
+ EXPECT_FALSE(test_roots->Contains(handle_1));
+ EXPECT_FALSE(test_roots->Contains(handle_2));
+}
+#endif
+
// TODO(rsleevi): Add tests for revocation checking via CRLs, ensuring that
// TestRootCerts properly injects itself into the validation process. See
// http://crbug.com/63958

Powered by Google App Engine
This is Rietveld 408576698