| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/network/onc/onc_certificate_importer.h" | 5 #include "chromeos/network/onc/onc_certificate_importer.h" |
| 6 | 6 |
| 7 #include <cert.h> | 7 #include <cert.h> |
| 8 #include <certdb.h> | 8 #include <certdb.h> |
| 9 #include <keyhi.h> | 9 #include <keyhi.h> |
| 10 #include <pk11pub.h> | 10 #include <pk11pub.h> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/threading/platform_thread.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "chromeos/network/onc/onc_constants.h" | 17 #include "chromeos/network/onc/onc_constants.h" |
| 17 #include "chromeos/network/onc/onc_test_utils.h" | 18 #include "chromeos/network/onc/onc_test_utils.h" |
| 18 #include "crypto/nss_util.h" | 19 #include "crypto/nss_util.h" |
| 19 #include "net/base/crypto_module.h" | 20 #include "net/base/crypto_module.h" |
| 20 #include "net/cert/cert_type.h" | 21 #include "net/cert/cert_type.h" |
| 21 #include "net/cert/nss_cert_database.h" | 22 #include "net/cert/nss_cert_database.h" |
| 22 #include "net/cert/x509_certificate.h" | 23 #include "net/cert/x509_certificate.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 25 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 EXPECT_TRUE(CleanupSlotContents()); | 74 EXPECT_TRUE(CleanupSlotContents()); |
| 74 EXPECT_EQ(0ul, ListCertsInSlot().size()); | 75 EXPECT_EQ(0ul, ListCertsInSlot().size()); |
| 75 } | 76 } |
| 76 | 77 |
| 77 virtual ~ONCCertificateImporterTest() {} | 78 virtual ~ONCCertificateImporterTest() {} |
| 78 | 79 |
| 79 protected: | 80 protected: |
| 80 void AddCertificatesFromFile( | 81 void AddCertificatesFromFile( |
| 81 std::string filename, | 82 std::string filename, |
| 82 CertificateImporter::ParseResult expected_parse_result) { | 83 CertificateImporter::ParseResult expected_parse_result) { |
| 84 // This 1 second sleep is necessary because NSS has a caching bug. This |
| 85 // can be removed once http://crbug.com/238654 is fixed. |
| 86 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); |
| 87 |
| 83 scoped_ptr<base::DictionaryValue> onc = | 88 scoped_ptr<base::DictionaryValue> onc = |
| 84 test_utils::ReadTestDictionary(filename); | 89 test_utils::ReadTestDictionary(filename); |
| 85 base::Value* certificates_value = NULL; | 90 base::Value* certificates_value = NULL; |
| 86 base::ListValue* certificates = NULL; | 91 base::ListValue* certificates = NULL; |
| 87 onc->RemoveWithoutPathExpansion(toplevel_config::kCertificates, | 92 onc->RemoveWithoutPathExpansion(toplevel_config::kCertificates, |
| 88 &certificates_value); | 93 &certificates_value); |
| 89 certificates_value->GetAsList(&certificates); | 94 certificates_value->GetAsList(&certificates); |
| 90 onc_certificates_.reset(certificates); | 95 onc_certificates_.reset(certificates); |
| 91 | 96 |
| 92 web_trust_certificates_.clear(); | 97 web_trust_certificates_.clear(); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 "certificate-client-update.onc"), | 311 "certificate-client-update.onc"), |
| 307 CertParam(net::SERVER_CERT, | 312 CertParam(net::SERVER_CERT, |
| 308 "certificate-server.onc", | 313 "certificate-server.onc", |
| 309 "certificate-server-update.onc"), | 314 "certificate-server-update.onc"), |
| 310 CertParam(net::CA_CERT, | 315 CertParam(net::CA_CERT, |
| 311 "certificate-web-authority.onc", | 316 "certificate-web-authority.onc", |
| 312 "certificate-web-authority-update.onc"))); | 317 "certificate-web-authority-update.onc"))); |
| 313 | 318 |
| 314 } // namespace onc | 319 } // namespace onc |
| 315 } // namespace chromeos | 320 } // namespace chromeos |
| OLD | NEW |