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 "net/cert/nss_cert_database.h" | 5 #include "net/cert/nss_cert_database.h" |
6 | 6 |
7 #include <cert.h> | 7 #include <cert.h> |
8 #include <certdb.h> | 8 #include <certdb.h> |
9 #include <pk11pub.h> | 9 #include <pk11pub.h> |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <memory> | 12 #include <memory> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
18 #include "base/message_loop/message_loop.h" | |
19 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
20 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
21 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
22 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
23 #include "base/threading/thread_task_runner_handle.h" | 22 #include "base/threading/thread_task_runner_handle.h" |
24 #include "crypto/scoped_nss_types.h" | 23 #include "crypto/scoped_nss_types.h" |
25 #include "crypto/scoped_test_nss_db.h" | 24 #include "crypto/scoped_test_nss_db.h" |
26 #include "net/base/crypto_module.h" | 25 #include "net/base/crypto_module.h" |
27 #include "net/base/net_errors.h" | 26 #include "net/base/net_errors.h" |
28 #include "net/base/test_data_directory.h" | 27 #include "net/base/test_data_directory.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 public_module_ = cert_db_->GetPublicModule(); | 65 public_module_ = cert_db_->GetPublicModule(); |
67 | 66 |
68 // Test db should be empty at start of test. | 67 // Test db should be empty at start of test. |
69 EXPECT_EQ(0U, ListCerts().size()); | 68 EXPECT_EQ(0U, ListCerts().size()); |
70 } | 69 } |
71 | 70 |
72 void TearDown() override { | 71 void TearDown() override { |
73 // Run the message loop to process any observer callbacks (e.g. for the | 72 // Run the message loop to process any observer callbacks (e.g. for the |
74 // ClientSocketFactory singleton) so that the scoped ref ptrs created in | 73 // ClientSocketFactory singleton) so that the scoped ref ptrs created in |
75 // NSSCertDatabase::NotifyObservers* get released. | 74 // NSSCertDatabase::NotifyObservers* get released. |
76 base::MessageLoop::current()->RunUntilIdle(); | 75 base::RunLoop().RunUntilIdle(); |
77 } | 76 } |
78 | 77 |
79 protected: | 78 protected: |
80 CryptoModule* GetPublicModule() { return public_module_.get(); } | 79 CryptoModule* GetPublicModule() { return public_module_.get(); } |
81 | 80 |
82 static std::string ReadTestFile(const std::string& name) { | 81 static std::string ReadTestFile(const std::string& name) { |
83 std::string result; | 82 std::string result; |
84 base::FilePath cert_path = GetTestCertsDirectory().AppendASCII(name); | 83 base::FilePath cert_path = GetTestCertsDirectory().AppendASCII(name); |
85 EXPECT_TRUE(base::ReadFileToString(cert_path, &result)); | 84 EXPECT_TRUE(base::ReadFileToString(cert_path, &result)); |
86 return result; | 85 return result; |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 EXPECT_EQ(NSSCertDatabase::TRUST_DEFAULT, | 973 EXPECT_EQ(NSSCertDatabase::TRUST_DEFAULT, |
975 cert_db_->GetCertTrust(certs2[0].get(), SERVER_CERT)); | 974 cert_db_->GetCertTrust(certs2[0].get(), SERVER_CERT)); |
976 | 975 |
977 new_certs = ListCerts(); | 976 new_certs = ListCerts(); |
978 ASSERT_EQ(2U, new_certs.size()); | 977 ASSERT_EQ(2U, new_certs.size()); |
979 EXPECT_STRNE(new_certs[0]->os_cert_handle()->nickname, | 978 EXPECT_STRNE(new_certs[0]->os_cert_handle()->nickname, |
980 new_certs[1]->os_cert_handle()->nickname); | 979 new_certs[1]->os_cert_handle()->nickname); |
981 } | 980 } |
982 | 981 |
983 } // namespace net | 982 } // namespace net |
OLD | NEW |