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

Side by Side Diff: net/cert/nss_cert_database_chromeos_unittest.cc

Issue 574513003: Remove implicit conversions from scoped_refptr to T* in net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | net/ssl/client_cert_store_chromeos_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/cert/nss_cert_database_chromeos.h" 5 #include "net/cert/nss_cert_database_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/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 EXPECT_EQ(0U, failed.size()); 163 EXPECT_EQ(0U, failed.size());
164 164
165 // Get cert list for each user. 165 // Get cert list for each user.
166 CertificateList user_1_certlist; 166 CertificateList user_1_certlist;
167 CertificateList user_2_certlist; 167 CertificateList user_2_certlist;
168 db_1_->ListCertsSync(&user_1_certlist); 168 db_1_->ListCertsSync(&user_1_certlist);
169 db_2_->ListCertsSync(&user_2_certlist); 169 db_2_->ListCertsSync(&user_2_certlist);
170 170
171 // Check that the imported certs only shows up in the list for the user that 171 // Check that the imported certs only shows up in the list for the user that
172 // imported them. 172 // imported them.
173 EXPECT_TRUE(IsCertInCertificateList(certs_1[0], user_1_certlist)); 173 EXPECT_TRUE(IsCertInCertificateList(certs_1[0].get(), user_1_certlist));
174 EXPECT_FALSE(IsCertInCertificateList(certs_1[0], user_2_certlist)); 174 EXPECT_FALSE(IsCertInCertificateList(certs_1[0].get(), user_2_certlist));
175 175
176 EXPECT_TRUE(IsCertInCertificateList(certs_2[0], user_2_certlist)); 176 EXPECT_TRUE(IsCertInCertificateList(certs_2[0].get(), user_2_certlist));
177 EXPECT_FALSE(IsCertInCertificateList(certs_2[0], user_1_certlist)); 177 EXPECT_FALSE(IsCertInCertificateList(certs_2[0].get(), user_1_certlist));
178 178
179 // Run the message loop so the observer notifications get processed. 179 // Run the message loop so the observer notifications get processed.
180 base::RunLoop().RunUntilIdle(); 180 base::RunLoop().RunUntilIdle();
181 // Should have gotten two OnCACertChanged notifications. 181 // Should have gotten two OnCACertChanged notifications.
182 ASSERT_EQ(2U, added_ca_.size()); 182 ASSERT_EQ(2U, added_ca_.size());
183 // TODO(mattm): make NSSCertDatabase actually pass the cert to the callback, 183 // TODO(mattm): make NSSCertDatabase actually pass the cert to the callback,
184 // and enable these checks: 184 // and enable these checks:
185 // EXPECT_EQ(certs_1[0]->os_cert_handle(), added_ca_[0]); 185 // EXPECT_EQ(certs_1[0]->os_cert_handle(), added_ca_[0]);
186 // EXPECT_EQ(certs_2[0]->os_cert_handle(), added_ca_[1]); 186 // EXPECT_EQ(certs_2[0]->os_cert_handle(), added_ca_[1]);
187 EXPECT_EQ(0U, added_.size()); 187 EXPECT_EQ(0U, added_.size());
188 188
189 // Tests that the new certs are loaded by async ListCerts method. 189 // Tests that the new certs are loaded by async ListCerts method.
190 CertificateList user_1_certlist_async; 190 CertificateList user_1_certlist_async;
191 CertificateList user_2_certlist_async; 191 CertificateList user_2_certlist_async;
192 db_1_->ListCerts( 192 db_1_->ListCerts(
193 base::Bind(&SwapCertLists, base::Unretained(&user_1_certlist_async))); 193 base::Bind(&SwapCertLists, base::Unretained(&user_1_certlist_async)));
194 db_2_->ListCerts( 194 db_2_->ListCerts(
195 base::Bind(&SwapCertLists, base::Unretained(&user_2_certlist_async))); 195 base::Bind(&SwapCertLists, base::Unretained(&user_2_certlist_async)));
196 196
197 base::RunLoop().RunUntilIdle(); 197 base::RunLoop().RunUntilIdle();
198 198
199 EXPECT_TRUE(IsCertInCertificateList(certs_1[0], user_1_certlist_async)); 199 EXPECT_TRUE(IsCertInCertificateList(certs_1[0].get(), user_1_certlist_async));
200 EXPECT_FALSE(IsCertInCertificateList(certs_1[0], user_2_certlist_async)); 200 EXPECT_FALSE(
201 IsCertInCertificateList(certs_1[0].get(), user_2_certlist_async));
201 202
202 EXPECT_TRUE(IsCertInCertificateList(certs_2[0], user_2_certlist_async)); 203 EXPECT_TRUE(IsCertInCertificateList(certs_2[0].get(), user_2_certlist_async));
203 EXPECT_FALSE(IsCertInCertificateList(certs_2[0], user_1_certlist_async)); 204 EXPECT_FALSE(
205 IsCertInCertificateList(certs_2[0].get(), user_1_certlist_async));
204 } 206 }
205 207
206 // Test that ImportServerCerts imports the cert to the correct slot, and that 208 // Test that ImportServerCerts imports the cert to the correct slot, and that
207 // ListCerts includes the added cert for the correct user, and does not include 209 // ListCerts includes the added cert for the correct user, and does not include
208 // it for the other user. 210 // it for the other user.
209 TEST_F(NSSCertDatabaseChromeOSTest, ImportServerCert) { 211 TEST_F(NSSCertDatabaseChromeOSTest, ImportServerCert) {
210 // Load test certs from disk. 212 // Load test certs from disk.
211 CertificateList certs_1 = CreateCertificateListFromFile( 213 CertificateList certs_1 = CreateCertificateListFromFile(
212 GetTestCertsDirectory(), "ok_cert.pem", X509Certificate::FORMAT_AUTO); 214 GetTestCertsDirectory(), "ok_cert.pem", X509Certificate::FORMAT_AUTO);
213 ASSERT_EQ(1U, certs_1.size()); 215 ASSERT_EQ(1U, certs_1.size());
(...skipping 15 matching lines...) Expand all
229 EXPECT_EQ(0U, failed.size()); 231 EXPECT_EQ(0U, failed.size());
230 232
231 // Get cert list for each user. 233 // Get cert list for each user.
232 CertificateList user_1_certlist; 234 CertificateList user_1_certlist;
233 CertificateList user_2_certlist; 235 CertificateList user_2_certlist;
234 db_1_->ListCertsSync(&user_1_certlist); 236 db_1_->ListCertsSync(&user_1_certlist);
235 db_2_->ListCertsSync(&user_2_certlist); 237 db_2_->ListCertsSync(&user_2_certlist);
236 238
237 // Check that the imported certs only shows up in the list for the user that 239 // Check that the imported certs only shows up in the list for the user that
238 // imported them. 240 // imported them.
239 EXPECT_TRUE(IsCertInCertificateList(certs_1[0], user_1_certlist)); 241 EXPECT_TRUE(IsCertInCertificateList(certs_1[0].get(), user_1_certlist));
240 EXPECT_FALSE(IsCertInCertificateList(certs_1[0], user_2_certlist)); 242 EXPECT_FALSE(IsCertInCertificateList(certs_1[0].get(), user_2_certlist));
241 243
242 EXPECT_TRUE(IsCertInCertificateList(certs_2[0], user_2_certlist)); 244 EXPECT_TRUE(IsCertInCertificateList(certs_2[0].get(), user_2_certlist));
243 EXPECT_FALSE(IsCertInCertificateList(certs_2[0], user_1_certlist)); 245 EXPECT_FALSE(IsCertInCertificateList(certs_2[0].get(), user_1_certlist));
244 246
245 // Run the message loop so the observer notifications get processed. 247 // Run the message loop so the observer notifications get processed.
246 base::RunLoop().RunUntilIdle(); 248 base::RunLoop().RunUntilIdle();
247 // TODO(mattm): ImportServerCert doesn't actually cause any observers to 249 // TODO(mattm): ImportServerCert doesn't actually cause any observers to
248 // fire. Is that correct? 250 // fire. Is that correct?
249 EXPECT_EQ(0U, added_ca_.size()); 251 EXPECT_EQ(0U, added_ca_.size());
250 EXPECT_EQ(0U, added_.size()); 252 EXPECT_EQ(0U, added_.size());
251 253
252 // Tests that the new certs are loaded by async ListCerts method. 254 // Tests that the new certs are loaded by async ListCerts method.
253 CertificateList user_1_certlist_async; 255 CertificateList user_1_certlist_async;
254 CertificateList user_2_certlist_async; 256 CertificateList user_2_certlist_async;
255 db_1_->ListCerts( 257 db_1_->ListCerts(
256 base::Bind(&SwapCertLists, base::Unretained(&user_1_certlist_async))); 258 base::Bind(&SwapCertLists, base::Unretained(&user_1_certlist_async)));
257 db_2_->ListCerts( 259 db_2_->ListCerts(
258 base::Bind(&SwapCertLists, base::Unretained(&user_2_certlist_async))); 260 base::Bind(&SwapCertLists, base::Unretained(&user_2_certlist_async)));
259 261
260 base::RunLoop().RunUntilIdle(); 262 base::RunLoop().RunUntilIdle();
261 263
262 EXPECT_TRUE(IsCertInCertificateList(certs_1[0], user_1_certlist_async)); 264 EXPECT_TRUE(IsCertInCertificateList(certs_1[0].get(), user_1_certlist_async));
263 EXPECT_FALSE(IsCertInCertificateList(certs_1[0], user_2_certlist_async)); 265 EXPECT_FALSE(
266 IsCertInCertificateList(certs_1[0].get(), user_2_certlist_async));
264 267
265 EXPECT_TRUE(IsCertInCertificateList(certs_2[0], user_2_certlist_async)); 268 EXPECT_TRUE(IsCertInCertificateList(certs_2[0].get(), user_2_certlist_async));
266 EXPECT_FALSE(IsCertInCertificateList(certs_2[0], user_1_certlist_async)); 269 EXPECT_FALSE(
270 IsCertInCertificateList(certs_2[0].get(), user_1_certlist_async));
267 } 271 }
268 272
269 // Tests that There is no crash if the database is deleted while ListCerts 273 // Tests that There is no crash if the database is deleted while ListCerts
270 // is being processed on the worker pool. 274 // is being processed on the worker pool.
271 TEST_F(NSSCertDatabaseChromeOSTest, NoCrashIfShutdownBeforeDoneOnWorkerPool) { 275 TEST_F(NSSCertDatabaseChromeOSTest, NoCrashIfShutdownBeforeDoneOnWorkerPool) {
272 CertificateList certlist; 276 CertificateList certlist;
273 db_1_->ListCerts(base::Bind(&SwapCertLists, base::Unretained(&certlist))); 277 db_1_->ListCerts(base::Bind(&SwapCertLists, base::Unretained(&certlist)));
274 EXPECT_EQ(0U, certlist.size()); 278 EXPECT_EQ(0U, certlist.size());
275 279
276 db_1_.reset(); 280 db_1_.reset();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 "client_2.pem", 314 "client_2.pem",
311 "client_2.pk8", 315 "client_2.pk8",
312 system_db_.slot())); 316 system_db_.slot()));
313 CertificateList certs; 317 CertificateList certs;
314 db_2_->ListCertsSync(&certs); 318 db_2_->ListCertsSync(&certs);
315 EXPECT_TRUE(IsCertInCertificateList(cert_1.get(), certs)); 319 EXPECT_TRUE(IsCertInCertificateList(cert_1.get(), certs));
316 EXPECT_FALSE(IsCertInCertificateList(cert_2.get(), certs)); 320 EXPECT_FALSE(IsCertInCertificateList(cert_2.get(), certs));
317 } 321 }
318 322
319 } // namespace net 323 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/ssl/client_cert_store_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698