| 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 <cert.h> | 5 #include <cert.h> |
| 6 #include <certdb.h> | 6 #include <certdb.h> |
| 7 #include <pk11pub.h> | 7 #include <pk11pub.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/message_loop/message_loop_proxy.h" | |
| 17 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 18 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 19 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/thread_task_runner_handle.h" |
| 21 #include "crypto/scoped_nss_types.h" | 21 #include "crypto/scoped_nss_types.h" |
| 22 #include "crypto/scoped_test_nss_db.h" | 22 #include "crypto/scoped_test_nss_db.h" |
| 23 #include "net/base/crypto_module.h" | 23 #include "net/base/crypto_module.h" |
| 24 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
| 25 #include "net/base/test_data_directory.h" | 25 #include "net/base/test_data_directory.h" |
| 26 #include "net/cert/cert_status_flags.h" | 26 #include "net/cert/cert_status_flags.h" |
| 27 #include "net/cert/cert_verify_proc_nss.h" | 27 #include "net/cert/cert_verify_proc_nss.h" |
| 28 #include "net/cert/cert_verify_result.h" | 28 #include "net/cert/cert_verify_result.h" |
| 29 #include "net/cert/nss_cert_database.h" | 29 #include "net/cert/nss_cert_database.h" |
| 30 #include "net/cert/x509_certificate.h" | 30 #include "net/cert/x509_certificate.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 cert_db_->ListCertsSync(&certs); | 124 cert_db_->ListCertsSync(&certs); |
| 125 // The test DB is empty, but let's assume there will always be something in | 125 // The test DB is empty, but let's assume there will always be something in |
| 126 // the other slots. | 126 // the other slots. |
| 127 EXPECT_LT(0U, certs.size()); | 127 EXPECT_LT(0U, certs.size()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 TEST_F(CertDatabaseNSSTest, ListCerts) { | 130 TEST_F(CertDatabaseNSSTest, ListCerts) { |
| 131 // This test isn't terribly useful, though it will at least let valgrind test | 131 // This test isn't terribly useful, though it will at least let valgrind test |
| 132 // for leaks. | 132 // for leaks. |
| 133 CertificateList certs; | 133 CertificateList certs; |
| 134 cert_db_->SetSlowTaskRunnerForTest(base::MessageLoopProxy::current()); | 134 cert_db_->SetSlowTaskRunnerForTest(base::ThreadTaskRunnerHandle::Get()); |
| 135 cert_db_->ListCerts(base::Bind(&SwapCertList, base::Unretained(&certs))); | 135 cert_db_->ListCerts(base::Bind(&SwapCertList, base::Unretained(&certs))); |
| 136 EXPECT_EQ(0U, certs.size()); | 136 EXPECT_EQ(0U, certs.size()); |
| 137 | 137 |
| 138 base::RunLoop().RunUntilIdle(); | 138 base::RunLoop().RunUntilIdle(); |
| 139 | 139 |
| 140 // The test DB is empty, but let's assume there will always be something in | 140 // The test DB is empty, but let's assume there will always be something in |
| 141 // the other slots. | 141 // the other slots. |
| 142 EXPECT_LT(0U, certs.size()); | 142 EXPECT_LT(0U, certs.size()); |
| 143 } | 143 } |
| 144 | 144 |
| (...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 EXPECT_EQ(NSSCertDatabase::TRUST_DEFAULT, | 972 EXPECT_EQ(NSSCertDatabase::TRUST_DEFAULT, |
| 973 cert_db_->GetCertTrust(certs2[0].get(), SERVER_CERT)); | 973 cert_db_->GetCertTrust(certs2[0].get(), SERVER_CERT)); |
| 974 | 974 |
| 975 new_certs = ListCerts(); | 975 new_certs = ListCerts(); |
| 976 ASSERT_EQ(2U, new_certs.size()); | 976 ASSERT_EQ(2U, new_certs.size()); |
| 977 EXPECT_STRNE(new_certs[0]->os_cert_handle()->nickname, | 977 EXPECT_STRNE(new_certs[0]->os_cert_handle()->nickname, |
| 978 new_certs[1]->os_cert_handle()->nickname); | 978 new_certs[1]->os_cert_handle()->nickname); |
| 979 } | 979 } |
| 980 | 980 |
| 981 } // namespace net | 981 } // namespace net |
| OLD | NEW |