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" | |
16 #include "base/values.h" | 15 #include "base/values.h" |
17 #include "chromeos/network/onc/onc_constants.h" | 16 #include "chromeos/network/onc/onc_constants.h" |
18 #include "chromeos/network/onc/onc_test_utils.h" | 17 #include "chromeos/network/onc/onc_test_utils.h" |
19 #include "crypto/nss_util.h" | 18 #include "crypto/nss_util.h" |
20 #include "net/base/crypto_module.h" | 19 #include "net/base/crypto_module.h" |
21 #include "net/cert/cert_type.h" | 20 #include "net/cert/cert_type.h" |
22 #include "net/cert/nss_cert_database.h" | 21 #include "net/cert/nss_cert_database.h" |
23 #include "net/cert/x509_certificate.h" | 22 #include "net/cert/x509_certificate.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
25 | 24 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 EXPECT_TRUE(CleanupSlotContents()); | 73 EXPECT_TRUE(CleanupSlotContents()); |
75 EXPECT_EQ(0ul, ListCertsInSlot().size()); | 74 EXPECT_EQ(0ul, ListCertsInSlot().size()); |
76 } | 75 } |
77 | 76 |
78 virtual ~ONCCertificateImporterTest() {} | 77 virtual ~ONCCertificateImporterTest() {} |
79 | 78 |
80 protected: | 79 protected: |
81 void AddCertificatesFromFile( | 80 void AddCertificatesFromFile( |
82 std::string filename, | 81 std::string filename, |
83 CertificateImporter::ParseResult expected_parse_result) { | 82 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 | |
88 scoped_ptr<base::DictionaryValue> onc = | 83 scoped_ptr<base::DictionaryValue> onc = |
89 test_utils::ReadTestDictionary(filename); | 84 test_utils::ReadTestDictionary(filename); |
90 base::Value* certificates_value = NULL; | 85 base::Value* certificates_value = NULL; |
91 base::ListValue* certificates = NULL; | 86 base::ListValue* certificates = NULL; |
92 onc->RemoveWithoutPathExpansion(toplevel_config::kCertificates, | 87 onc->RemoveWithoutPathExpansion(toplevel_config::kCertificates, |
93 &certificates_value); | 88 &certificates_value); |
94 certificates_value->GetAsList(&certificates); | 89 certificates_value->GetAsList(&certificates); |
95 onc_certificates_.reset(certificates); | 90 onc_certificates_.reset(certificates); |
96 | 91 |
97 web_trust_certificates_.clear(); | 92 web_trust_certificates_.clear(); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 "certificate-client-update.onc"), | 306 "certificate-client-update.onc"), |
312 CertParam(net::SERVER_CERT, | 307 CertParam(net::SERVER_CERT, |
313 "certificate-server.onc", | 308 "certificate-server.onc", |
314 "certificate-server-update.onc"), | 309 "certificate-server-update.onc"), |
315 CertParam(net::CA_CERT, | 310 CertParam(net::CA_CERT, |
316 "certificate-web-authority.onc", | 311 "certificate-web-authority.onc", |
317 "certificate-web-authority-update.onc"))); | 312 "certificate-web-authority-update.onc"))); |
318 | 313 |
319 } // namespace onc | 314 } // namespace onc |
320 } // namespace chromeos | 315 } // namespace chromeos |
OLD | NEW |