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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "crypto/nss_util_internal.h" | 13 #include "crypto/nss_util_internal.h" |
14 #include "crypto/rsa_private_key.h" | 14 #include "crypto/rsa_private_key.h" |
15 #include "crypto/scoped_test_nss_chromeos_user.h" | 15 #include "crypto/scoped_test_nss_chromeos_user.h" |
16 #include "crypto/scoped_test_system_nss_key_slot.h" | 16 #include "crypto/scoped_test_system_nss_key_slot.h" |
17 #include "net/base/test_data_directory.h" | 17 #include "net/base/test_data_directory.h" |
18 #include "net/cert/x509_certificate.h" | 18 #include "net/cert/x509_certificate.h" |
19 #include "net/ssl/client_cert_store_unittest-inl.h" | 19 #include "net/ssl/client_cert_store_unittest-inl.h" |
20 #include "net/test/cert_test_util.h" | 20 #include "net/test/cert_test_util.h" |
21 | 21 |
22 namespace net { | 22 namespace net { |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 enum ReadFromSlot { | 26 enum ReadFromSlot { READ_FROM_SLOT_USER, READ_FROM_SLOT_SYSTEM }; |
27 READ_FROM_SLOT_USER, | |
28 READ_FROM_SLOT_SYSTEM | |
29 }; | |
30 | 27 |
31 enum SystemSlotAvailability { | 28 enum SystemSlotAvailability { |
32 SYSTEM_SLOT_AVAILABILITY_ENABLED, | 29 SYSTEM_SLOT_AVAILABILITY_ENABLED, |
33 SYSTEM_SLOT_AVAILABILITY_DISABLED | 30 SYSTEM_SLOT_AVAILABILITY_DISABLED |
34 }; | 31 }; |
35 | 32 |
36 } // namespace | 33 } // namespace |
37 | 34 |
38 // Define a delegate to be used for instantiating the parameterized test set | 35 // Define a delegate to be used for instantiating the parameterized test set |
39 // ClientCertStoreTest. | 36 // ClientCertStoreTest. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 crypto::ScopedPK11Slot slot( | 150 crypto::ScopedPK11Slot slot( |
154 crypto::GetPublicSlotForChromeOSUser(username_hash)); | 151 crypto::GetPublicSlotForChromeOSUser(username_hash)); |
155 if (!slot) { | 152 if (!slot) { |
156 LOG(ERROR) << "No slot for user " << username_hash; | 153 LOG(ERROR) << "No slot for user " << username_hash; |
157 return NULL; | 154 return NULL; |
158 } | 155 } |
159 | 156 |
160 return ImportClientCertAndKeyFromFile( | 157 return ImportClientCertAndKeyFromFile( |
161 GetTestCertsDirectory(), cert_filename, key_filename, slot.get()); | 158 GetTestCertsDirectory(), cert_filename, key_filename, slot.get()); |
162 } | 159 } |
163 | |
164 }; | 160 }; |
165 | 161 |
166 // Ensure that cert requests, that are started before the user's NSS DB is | 162 // Ensure that cert requests, that are started before the user's NSS DB is |
167 // initialized, will wait for the initialization and succeed afterwards. | 163 // initialized, will wait for the initialization and succeed afterwards. |
168 TEST_F(ClientCertStoreChromeOSTest, RequestWaitsForNSSInitAndSucceeds) { | 164 TEST_F(ClientCertStoreChromeOSTest, RequestWaitsForNSSInitAndSucceeds) { |
169 crypto::ScopedTestNSSChromeOSUser user("scopeduser"); | 165 crypto::ScopedTestNSSChromeOSUser user("scopeduser"); |
170 ASSERT_TRUE(user.constructed_successfully()); | 166 ASSERT_TRUE(user.constructed_successfully()); |
171 | 167 |
172 crypto::ScopedTestSystemNSSKeySlot system_slot; | 168 crypto::ScopedTestSystemNSSKeySlot system_slot; |
173 | 169 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 store.GetClientCerts(*request_all, &selected_certs, run_loop.QuitClosure()); | 311 store.GetClientCerts(*request_all, &selected_certs, run_loop.QuitClosure()); |
316 | 312 |
317 run_loop.Run(); | 313 run_loop.Run(); |
318 | 314 |
319 // store should only return certs of the user, namely cert_1. | 315 // store should only return certs of the user, namely cert_1. |
320 ASSERT_EQ(1u, selected_certs.size()); | 316 ASSERT_EQ(1u, selected_certs.size()); |
321 EXPECT_TRUE(cert_1->Equals(selected_certs[0])); | 317 EXPECT_TRUE(cert_1->Equals(selected_certs[0])); |
322 } | 318 } |
323 | 319 |
324 } // namespace net | 320 } // namespace net |
OLD | NEW |