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 "net/ssl/client_cert_store_chromeos.h" | 5 #include "net/ssl/client_cert_store_chromeos.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "crypto/nss_util.h" | 12 #include "crypto/nss_util.h" |
13 #include "crypto/nss_util_internal.h" | 13 #include "crypto/nss_util_internal.h" |
14 #include "net/cert/nss_cert_database.h" | 14 #include "net/cert/nss_cert_database.h" |
15 #include "net/ssl/client_cert_store_unittest-inl.h" | 15 #include "net/ssl/client_cert_store_unittest-inl.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 class ClientCertStoreChromeOSTestDelegate { | |
20 public: | |
21 ClientCertStoreChromeOSTestDelegate() | |
22 : store_("usernamehash", | |
23 ClientCertStoreChromeOS::PasswordDelegateFactory()) { | |
24 store_.InitForTesting( | |
25 crypto::ScopedPK11Slot(crypto::GetPublicNSSKeySlot()), | |
26 crypto::ScopedPK11Slot(crypto::GetPrivateNSSKeySlot())); | |
27 } | |
28 | |
29 bool SelectClientCerts(const CertificateList& input_certs, | |
30 const SSLCertRequestInfo& cert_request_info, | |
31 CertificateList* selected_certs) { | |
32 return store_.SelectClientCertsForTesting( | |
33 input_certs, cert_request_info, selected_certs); | |
34 } | |
35 | |
36 private: | |
37 ClientCertStoreChromeOS store_; | |
38 }; | |
39 | |
40 class ClientCertStoreChromeOSTest : public ::testing::Test { | 19 class ClientCertStoreChromeOSTest : public ::testing::Test { |
41 public: | 20 public: |
42 scoped_refptr<X509Certificate> ImportCertForUser( | 21 scoped_refptr<X509Certificate> ImportCertForUser( |
43 const std::string& username_hash, | 22 const std::string& username_hash, |
44 const std::string& filename, | 23 const std::string& filename, |
45 const std::string& password) { | 24 const std::string& password) { |
46 crypto::ScopedPK11Slot slot( | 25 crypto::ScopedPK11Slot slot( |
47 crypto::GetPublicSlotForChromeOSUser(username_hash)); | 26 crypto::GetPublicSlotForChromeOSUser(username_hash)); |
48 EXPECT_TRUE(slot.get()); | 27 EXPECT_TRUE(slot.get()); |
49 if (!slot.get()) | 28 if (!slot.get()) |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 run_loop_1.Run(); | 159 run_loop_1.Run(); |
181 run_loop_2.Run(); | 160 run_loop_2.Run(); |
182 | 161 |
183 ASSERT_EQ(1u, request_1->client_certs.size()); | 162 ASSERT_EQ(1u, request_1->client_certs.size()); |
184 EXPECT_TRUE(cert_1->Equals(request_1->client_certs[0])); | 163 EXPECT_TRUE(cert_1->Equals(request_1->client_certs[0])); |
185 // TODO(mattm): Request for second user will have zero results due to | 164 // TODO(mattm): Request for second user will have zero results due to |
186 // crbug.com/315285. Update the test once that is fixed. | 165 // crbug.com/315285. Update the test once that is fixed. |
187 } | 166 } |
188 | 167 |
189 } // namespace net | 168 } // namespace net |
OLD | NEW |