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

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

Issue 2711113002: net: remove CryptoModuleList typedef (Closed)
Patch Set: more std::moves Created 3 years, 9 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 | « net/cert/nss_cert_database_chromeos.cc ('k') | net/cert/nss_profile_filter_chromeos.h » ('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 <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 crypto::ScopedTestNSSChromeOSUser user_2_; 101 crypto::ScopedTestNSSChromeOSUser user_2_;
102 crypto::ScopedTestNSSDB system_db_; 102 crypto::ScopedTestNSSDB system_db_;
103 std::unique_ptr<NSSCertDatabaseChromeOS> db_1_; 103 std::unique_ptr<NSSCertDatabaseChromeOS> db_1_;
104 std::unique_ptr<NSSCertDatabaseChromeOS> db_2_; 104 std::unique_ptr<NSSCertDatabaseChromeOS> db_2_;
105 }; 105 };
106 106
107 // Test that ListModules() on each user includes that user's NSS software slot, 107 // Test that ListModules() on each user includes that user's NSS software slot,
108 // and does not include the software slot of the other user. (Does not check the 108 // and does not include the software slot of the other user. (Does not check the
109 // private slot, since it is the same as the public slot in tests.) 109 // private slot, since it is the same as the public slot in tests.)
110 TEST_F(NSSCertDatabaseChromeOSTest, ListModules) { 110 TEST_F(NSSCertDatabaseChromeOSTest, ListModules) {
111 CryptoModuleList modules_1; 111 std::vector<crypto::ScopedPK11Slot> modules_1;
112 CryptoModuleList modules_2; 112 std::vector<crypto::ScopedPK11Slot> modules_2;
113 113
114 db_1_->ListModules(&modules_1, false /* need_rw */); 114 db_1_->ListModules(&modules_1, false /* need_rw */);
115 db_2_->ListModules(&modules_2, false /* need_rw */); 115 db_2_->ListModules(&modules_2, false /* need_rw */);
116 116
117 bool found_1 = false; 117 bool found_1 = false;
118 for (CryptoModuleList::iterator it = modules_1.begin(); it != modules_1.end(); 118 for (std::vector<crypto::ScopedPK11Slot>::iterator it = modules_1.begin();
119 ++it) { 119 it != modules_1.end(); ++it) {
120 EXPECT_NE(db_2_->GetPublicSlot().get(), (*it)->os_module_handle()); 120 EXPECT_NE(db_2_->GetPublicSlot().get(), (*it).get());
121 if ((*it)->os_module_handle() == db_1_->GetPublicSlot().get()) 121 if ((*it).get() == db_1_->GetPublicSlot().get())
122 found_1 = true; 122 found_1 = true;
123 } 123 }
124 EXPECT_TRUE(found_1); 124 EXPECT_TRUE(found_1);
125 125
126 bool found_2 = false; 126 bool found_2 = false;
127 for (CryptoModuleList::iterator it = modules_2.begin(); it != modules_2.end(); 127 for (std::vector<crypto::ScopedPK11Slot>::iterator it = modules_2.begin();
128 ++it) { 128 it != modules_2.end(); ++it) {
129 EXPECT_NE(db_1_->GetPublicSlot().get(), (*it)->os_module_handle()); 129 EXPECT_NE(db_1_->GetPublicSlot().get(), (*it).get());
130 if ((*it)->os_module_handle() == db_2_->GetPublicSlot().get()) 130 if ((*it).get() == db_2_->GetPublicSlot().get())
131 found_2 = true; 131 found_2 = true;
132 } 132 }
133 EXPECT_TRUE(found_2); 133 EXPECT_TRUE(found_2);
134 } 134 }
135 135
136 // Test that ImportCACerts imports the cert to the correct slot, and that 136 // Test that ImportCACerts imports the cert to the correct slot, and that
137 // ListCerts includes the added cert for the correct user, and does not include 137 // ListCerts includes the added cert for the correct user, and does not include
138 // it for the other user. 138 // it for the other user.
139 TEST_F(NSSCertDatabaseChromeOSTest, ImportCACerts) { 139 TEST_F(NSSCertDatabaseChromeOSTest, ImportCACerts) {
140 // Load test certs from disk. 140 // Load test certs from disk.
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 "client_2.pem", 306 "client_2.pem",
307 "client_2.pk8", 307 "client_2.pk8",
308 system_db_.slot())); 308 system_db_.slot()));
309 CertificateList certs; 309 CertificateList certs;
310 db_2_->ListCertsSync(&certs); 310 db_2_->ListCertsSync(&certs);
311 EXPECT_TRUE(IsCertInCertificateList(cert_1.get(), certs)); 311 EXPECT_TRUE(IsCertInCertificateList(cert_1.get(), certs));
312 EXPECT_FALSE(IsCertInCertificateList(cert_2.get(), certs)); 312 EXPECT_FALSE(IsCertInCertificateList(cert_2.get(), certs));
313 } 313 }
314 314
315 } // namespace net 315 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/nss_cert_database_chromeos.cc ('k') | net/cert/nss_profile_filter_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698