Index: net/base/x509_certificate_unittest.cc |
diff --git a/net/base/x509_certificate_unittest.cc b/net/base/x509_certificate_unittest.cc |
index 31173e4f469c7f24d8a0ff2017636fa070251a51..b316b12c6b6a8450d05782a165bdc7e9014386ab 100644 |
--- a/net/base/x509_certificate_unittest.cc |
+++ b/net/base/x509_certificate_unittest.cc |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -11,6 +11,7 @@ |
#include "net/base/cert_verify_result.h" |
#include "net/base/net_errors.h" |
#include "net/base/test_certificate_data.h" |
+#include "net/base/test_root_certs.h" |
#include "net/base/x509_certificate.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -161,30 +162,6 @@ const CertificateFormatTestData FormatTestData[] = { |
NULL, } }, |
}; |
-// Returns a FilePath object representing the src/net/data/ssl/certificates |
-// directory in the source tree. |
-FilePath GetTestCertsDirectory() { |
- FilePath certs_dir; |
- PathService::Get(base::DIR_SOURCE_ROOT, &certs_dir); |
- certs_dir = certs_dir.AppendASCII("net"); |
- certs_dir = certs_dir.AppendASCII("data"); |
- certs_dir = certs_dir.AppendASCII("ssl"); |
- certs_dir = certs_dir.AppendASCII("certificates"); |
- return certs_dir; |
-} |
- |
-// Imports a certificate file in the src/net/data/ssl/certificates directory. |
-// certs_dir represents the test certificates directory. cert_file is the |
-// name of the certificate file. |
-X509Certificate* ImportCertFromFile(const FilePath& certs_dir, |
- const std::string& cert_file) { |
- FilePath cert_path = certs_dir.AppendASCII(cert_file); |
- std::string cert_data; |
- if (!file_util::ReadFileToString(cert_path, &cert_data)) |
- return NULL; |
- return X509Certificate::CreateFromBytes(cert_data.data(), cert_data.size()); |
-} |
- |
CertificateList CreateCertificateListFromFile( |
const FilePath& certs_dir, |
const std::string& cert_file, |
@@ -427,13 +404,8 @@ TEST(X509CertificateTest, UnoSoftCertParsing) { |
EXPECT_NE(0, verify_result.cert_status & CERT_STATUS_AUTHORITY_INVALID); |
} |
-#if defined(USE_NSS) || defined(USE_OPENSSL) |
// A regression test for http://crbug.com/31497. |
// This certificate will expire on 2012-04-08. |
-// TODO(wtc): we can't run this test on Mac because MacTrustedCertificates |
-// can hold only one additional trusted root certificate for unit tests. |
-// TODO(wtc): we can't run this test on Windows because LoadTemporaryRootCert |
-// isn't implemented (http//crbug.com/8470). |
TEST(X509CertificateTest, IntermediateCARequireExplicitPolicy) { |
FilePath certs_dir = GetTestCertsDirectory(); |
@@ -448,9 +420,8 @@ TEST(X509CertificateTest, IntermediateCARequireExplicitPolicy) { |
ASSERT_NE(static_cast<X509Certificate*>(NULL), intermediate_cert); |
FilePath root_cert_path = certs_dir.AppendASCII("dod_root_ca_2_cert.der"); |
- scoped_refptr<X509Certificate> root_cert = |
- LoadTemporaryRootCert(root_cert_path); |
- ASSERT_NE(static_cast<X509Certificate*>(NULL), root_cert); |
+ TestRootCerts* root_certs = TestRootCerts::GetInstance(); |
+ ASSERT_TRUE(root_certs->AddFromFile(root_cert_path)); |
X509Certificate::OSCertHandles intermediates; |
intermediates.push_back(intermediate_cert->os_cert_handle()); |
@@ -464,8 +435,8 @@ TEST(X509CertificateTest, IntermediateCARequireExplicitPolicy) { |
int error = cert_chain->Verify("www.us.army.mil", flags, &verify_result); |
EXPECT_EQ(OK, error); |
EXPECT_EQ(0, verify_result.cert_status); |
+ root_certs->Clear(); |
} |
-#endif |
// Tests X509Certificate::Cache via X509Certificate::CreateFromHandle. We |
// call X509Certificate::CreateFromHandle several times and observe whether |