Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: net/ssl/client_cert_store_chromeos_unittest.cc

Issue 1274143002: ClientCertStoreChromeOS: support additional non-platform certs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/callback.h" 9 #include "base/callback.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 }; 62 };
63 63
64 } // namespace 64 } // namespace
65 65
66 // Define a delegate to be used for instantiating the parameterized test set 66 // Define a delegate to be used for instantiating the parameterized test set
67 // ClientCertStoreTest. 67 // ClientCertStoreTest.
68 class ClientCertStoreChromeOSTestDelegate { 68 class ClientCertStoreChromeOSTestDelegate {
69 public: 69 public:
70 ClientCertStoreChromeOSTestDelegate() 70 ClientCertStoreChromeOSTestDelegate()
71 : store_( 71 : store_(
72 CertificateList(),
72 make_scoped_ptr(new TestCertFilter(true /* init synchronously */)), 73 make_scoped_ptr(new TestCertFilter(true /* init synchronously */)),
73 ClientCertStoreChromeOS::PasswordDelegateFactory()) { 74 ClientCertStoreChromeOS::PasswordDelegateFactory()) {
74 // Defer futher initialization and checks to SelectClientCerts, because the 75 // Defer futher initialization and checks to SelectClientCerts, because the
75 // constructor doesn't allow us to return an initialization result. Could be 76 // constructor doesn't allow us to return an initialization result. Could be
76 // cleaned up by adding an Init() function. 77 // cleaned up by adding an Init() function.
77 } 78 }
78 79
79 // Called by the ClientCertStoreTest tests. 80 // Called by the ClientCertStoreTest tests.
80 // |inpurt_certs| contains certificates to select from. Because 81 // |inpurt_certs| contains certificates to select from. Because
81 // ClientCertStoreChromeOS filters also for the right slot, we have to import 82 // ClientCertStoreChromeOS filters also for the right slot, we have to import
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 141
141 // Ensure that cert requests, that are started before the filter is initialized, 142 // Ensure that cert requests, that are started before the filter is initialized,
142 // will wait for the initialization and succeed afterwards. 143 // will wait for the initialization and succeed afterwards.
143 TEST_F(ClientCertStoreChromeOSTest, RequestWaitsForNSSInitAndSucceeds) { 144 TEST_F(ClientCertStoreChromeOSTest, RequestWaitsForNSSInitAndSucceeds) {
144 crypto::ScopedTestNSSDB test_db; 145 crypto::ScopedTestNSSDB test_db;
145 ASSERT_TRUE(test_db.is_open()); 146 ASSERT_TRUE(test_db.is_open());
146 147
147 TestCertFilter* cert_filter = 148 TestCertFilter* cert_filter =
148 new TestCertFilter(false /* init asynchronously */); 149 new TestCertFilter(false /* init asynchronously */);
149 ClientCertStoreChromeOS store( 150 ClientCertStoreChromeOS store(
150 make_scoped_ptr(cert_filter), 151 CertificateList(), make_scoped_ptr(cert_filter),
151 ClientCertStoreChromeOS::PasswordDelegateFactory()); 152 ClientCertStoreChromeOS::PasswordDelegateFactory());
152 153
153 scoped_refptr<X509Certificate> cert_1( 154 scoped_refptr<X509Certificate> cert_1(
154 ImportCertToSlot("client_1.pem", "client_1.pk8", test_db.slot())); 155 ImportCertToSlot("client_1.pem", "client_1.pk8", test_db.slot()));
155 ASSERT_TRUE(cert_1.get()); 156 ASSERT_TRUE(cert_1.get());
156 157
157 // Request any client certificate, which is expected to match client_1. 158 // Request any client certificate, which is expected to match client_1.
158 scoped_refptr<SSLCertRequestInfo> request_all(new SSLCertRequestInfo()); 159 scoped_refptr<SSLCertRequestInfo> request_all(new SSLCertRequestInfo());
159 160
160 base::RunLoop run_loop; 161 base::RunLoop run_loop;
(...skipping 14 matching lines...) Expand all
175 ASSERT_EQ(1u, request_all->client_certs.size()); 176 ASSERT_EQ(1u, request_all->client_certs.size());
176 } 177 }
177 178
178 // Ensure that cert requests, that are started after the filter was initialized, 179 // Ensure that cert requests, that are started after the filter was initialized,
179 // will succeed. 180 // will succeed.
180 TEST_F(ClientCertStoreChromeOSTest, RequestsAfterNSSInitSucceed) { 181 TEST_F(ClientCertStoreChromeOSTest, RequestsAfterNSSInitSucceed) {
181 crypto::ScopedTestNSSDB test_db; 182 crypto::ScopedTestNSSDB test_db;
182 ASSERT_TRUE(test_db.is_open()); 183 ASSERT_TRUE(test_db.is_open());
183 184
184 ClientCertStoreChromeOS store( 185 ClientCertStoreChromeOS store(
186 CertificateList(),
185 make_scoped_ptr(new TestCertFilter(true /* init synchronously */)), 187 make_scoped_ptr(new TestCertFilter(true /* init synchronously */)),
186 ClientCertStoreChromeOS::PasswordDelegateFactory()); 188 ClientCertStoreChromeOS::PasswordDelegateFactory());
187 189
188 scoped_refptr<X509Certificate> cert_1( 190 scoped_refptr<X509Certificate> cert_1(
189 ImportCertToSlot("client_1.pem", "client_1.pk8", test_db.slot())); 191 ImportCertToSlot("client_1.pem", "client_1.pk8", test_db.slot()));
190 ASSERT_TRUE(cert_1.get()); 192 ASSERT_TRUE(cert_1.get());
191 193
192 scoped_refptr<SSLCertRequestInfo> request_all(new SSLCertRequestInfo()); 194 scoped_refptr<SSLCertRequestInfo> request_all(new SSLCertRequestInfo());
193 195
194 base::RunLoop run_loop; 196 base::RunLoop run_loop;
195 store.GetClientCerts( 197 store.GetClientCerts(
196 *request_all, &request_all->client_certs, run_loop.QuitClosure()); 198 *request_all, &request_all->client_certs, run_loop.QuitClosure());
197 run_loop.Run(); 199 run_loop.Run();
198 200
199 ASSERT_EQ(1u, request_all->client_certs.size()); 201 ASSERT_EQ(1u, request_all->client_certs.size());
200 } 202 }
201 203
202 TEST_F(ClientCertStoreChromeOSTest, Filter) { 204 TEST_F(ClientCertStoreChromeOSTest, Filter) {
203 crypto::ScopedTestNSSDB test_db; 205 crypto::ScopedTestNSSDB test_db;
204 ASSERT_TRUE(test_db.is_open()); 206 ASSERT_TRUE(test_db.is_open());
205 207
206 TestCertFilter* cert_filter = 208 TestCertFilter* cert_filter =
207 new TestCertFilter(true /* init synchronously */); 209 new TestCertFilter(true /* init synchronously */);
208 ClientCertStoreChromeOS store( 210 ClientCertStoreChromeOS store(
209 make_scoped_ptr(cert_filter), 211 CertificateList(), make_scoped_ptr(cert_filter),
210 ClientCertStoreChromeOS::PasswordDelegateFactory()); 212 ClientCertStoreChromeOS::PasswordDelegateFactory());
211 213
212 scoped_refptr<X509Certificate> cert_1( 214 scoped_refptr<X509Certificate> cert_1(
213 ImportCertToSlot("client_1.pem", "client_1.pk8", test_db.slot())); 215 ImportCertToSlot("client_1.pem", "client_1.pk8", test_db.slot()));
214 ASSERT_TRUE(cert_1.get()); 216 ASSERT_TRUE(cert_1.get());
215 scoped_refptr<X509Certificate> cert_2( 217 scoped_refptr<X509Certificate> cert_2(
216 ImportCertToSlot("client_2.pem", "client_2.pk8", test_db.slot())); 218 ImportCertToSlot("client_2.pem", "client_2.pk8", test_db.slot()));
217 ASSERT_TRUE(cert_2.get()); 219 ASSERT_TRUE(cert_2.get());
218 220
219 scoped_refptr<SSLCertRequestInfo> request_all(new SSLCertRequestInfo()); 221 scoped_refptr<SSLCertRequestInfo> request_all(new SSLCertRequestInfo());
(...skipping 15 matching lines...) Expand all
235 CertificateList selected_certs; 237 CertificateList selected_certs;
236 store.GetClientCerts(*request_all, &selected_certs, run_loop.QuitClosure()); 238 store.GetClientCerts(*request_all, &selected_certs, run_loop.QuitClosure());
237 run_loop.Run(); 239 run_loop.Run();
238 240
239 ASSERT_EQ(1u, selected_certs.size()); 241 ASSERT_EQ(1u, selected_certs.size());
240 EXPECT_TRUE(cert_2->Equals(selected_certs[0].get())); 242 EXPECT_TRUE(cert_2->Equals(selected_certs[0].get()));
241 } 243 }
242 } 244 }
243 245
244 } // namespace net 246 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698