OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/net/client_cert_store_chromeos.h" | 5 #include "chrome/browser/chromeos/net/client_cert_store_chromeos.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/message_loop/message_loop.h" | |
15 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
16 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
17 #include "base/test/scoped_task_scheduler.h" | 16 #include "base/test/scoped_task_scheduler.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
19 #include "chrome/browser/chromeos/certificate_provider/certificate_provider.h" | 18 #include "chrome/browser/chromeos/certificate_provider/certificate_provider.h" |
20 #include "crypto/scoped_test_nss_db.h" | 19 #include "crypto/scoped_test_nss_db.h" |
21 #include "net/cert/x509_certificate.h" | 20 #include "net/cert/x509_certificate.h" |
22 #include "net/ssl/ssl_cert_request_info.h" | 21 #include "net/ssl/ssl_cert_request_info.h" |
23 #include "net/test/cert_test_util.h" | 22 #include "net/test/cert_test_util.h" |
24 #include "net/test/test_data_directory.h" | 23 #include "net/test/test_data_directory.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 scoped_refptr<net::X509Certificate> ImportCertToSlot( | 82 scoped_refptr<net::X509Certificate> ImportCertToSlot( |
84 const std::string& cert_filename, | 83 const std::string& cert_filename, |
85 const std::string& key_filename, | 84 const std::string& key_filename, |
86 PK11SlotInfo* slot) { | 85 PK11SlotInfo* slot) { |
87 return net::ImportClientCertAndKeyFromFile( | 86 return net::ImportClientCertAndKeyFromFile( |
88 net::GetTestCertsDirectory(), cert_filename, key_filename, slot); | 87 net::GetTestCertsDirectory(), cert_filename, key_filename, slot); |
89 } | 88 } |
90 | 89 |
91 private: | 90 private: |
92 base::test::ScopedTaskScheduler scoped_task_scheduler_; | 91 base::test::ScopedTaskScheduler scoped_task_scheduler_; |
93 base::MessageLoopForIO message_loop_; | |
94 }; | 92 }; |
95 | 93 |
96 // Ensure that cert requests, that are started before the filter is initialized, | 94 // Ensure that cert requests, that are started before the filter is initialized, |
97 // will wait for the initialization and succeed afterwards. | 95 // will wait for the initialization and succeed afterwards. |
98 TEST_F(ClientCertStoreChromeOSTest, RequestWaitsForNSSInitAndSucceeds) { | 96 TEST_F(ClientCertStoreChromeOSTest, RequestWaitsForNSSInitAndSucceeds) { |
99 crypto::ScopedTestNSSDB test_db; | 97 crypto::ScopedTestNSSDB test_db; |
100 ASSERT_TRUE(test_db.is_open()); | 98 ASSERT_TRUE(test_db.is_open()); |
101 | 99 |
102 TestCertFilter* cert_filter = | 100 TestCertFilter* cert_filter = |
103 new TestCertFilter(false /* init asynchronously */); | 101 new TestCertFilter(false /* init asynchronously */); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 base::RunLoop run_loop; | 227 base::RunLoop run_loop; |
230 net::CertificateList selected_certs; | 228 net::CertificateList selected_certs; |
231 store.GetClientCerts(*request, &selected_certs, run_loop.QuitClosure()); | 229 store.GetClientCerts(*request, &selected_certs, run_loop.QuitClosure()); |
232 run_loop.Run(); | 230 run_loop.Run(); |
233 | 231 |
234 ASSERT_EQ(1u, selected_certs.size()); | 232 ASSERT_EQ(1u, selected_certs.size()); |
235 EXPECT_TRUE(cert_1->Equals(selected_certs[0].get())); | 233 EXPECT_TRUE(cert_1->Equals(selected_certs[0].get())); |
236 } | 234 } |
237 | 235 |
238 } // namespace chromeos | 236 } // namespace chromeos |
OLD | NEW |