OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromeos/cert_loader.h" | 5 #include "chromeos/cert_loader.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/test/scoped_task_scheduler.h" |
16 #include "crypto/scoped_nss_types.h" | 17 #include "crypto/scoped_nss_types.h" |
17 #include "crypto/scoped_test_nss_db.h" | 18 #include "crypto/scoped_test_nss_db.h" |
18 #include "net/cert/nss_cert_database_chromeos.h" | 19 #include "net/cert/nss_cert_database_chromeos.h" |
19 #include "net/cert/x509_certificate.h" | 20 #include "net/cert/x509_certificate.h" |
20 #include "net/test/cert_test_util.h" | 21 #include "net/test/cert_test_util.h" |
21 #include "net/test/test_data_directory.h" | 22 #include "net/test/test_data_directory.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 | 24 |
24 namespace chromeos { | 25 namespace chromeos { |
25 namespace { | 26 namespace { |
(...skipping 12 matching lines...) Expand all Loading... |
38 } | 39 } |
39 | 40 |
40 class TestNSSCertDatabase : public net::NSSCertDatabaseChromeOS { | 41 class TestNSSCertDatabase : public net::NSSCertDatabaseChromeOS { |
41 public: | 42 public: |
42 TestNSSCertDatabase(crypto::ScopedPK11Slot public_slot, | 43 TestNSSCertDatabase(crypto::ScopedPK11Slot public_slot, |
43 crypto::ScopedPK11Slot private_slot) | 44 crypto::ScopedPK11Slot private_slot) |
44 : NSSCertDatabaseChromeOS(std::move(public_slot), | 45 : NSSCertDatabaseChromeOS(std::move(public_slot), |
45 std::move(private_slot)) {} | 46 std::move(private_slot)) {} |
46 ~TestNSSCertDatabase() override {} | 47 ~TestNSSCertDatabase() override {} |
47 | 48 |
48 void NotifyOfCertAdded(const net::X509Certificate* cert) { | 49 // Make this method visible in the public interface. |
| 50 void NotifyObserversCertDBChanged() { |
49 NSSCertDatabaseChromeOS::NotifyObserversCertDBChanged(); | 51 NSSCertDatabaseChromeOS::NotifyObserversCertDBChanged(); |
50 } | 52 } |
51 }; | 53 }; |
52 | 54 |
53 class CertLoaderTest : public testing::Test, | 55 class CertLoaderTest : public testing::Test, |
54 public CertLoader::Observer { | 56 public CertLoader::Observer { |
55 public: | 57 public: |
56 CertLoaderTest() | 58 CertLoaderTest() |
57 : cert_loader_(nullptr), certificates_loaded_events_count_(0U) {} | 59 : cert_loader_(nullptr), |
| 60 scoped_task_scheduler_(&message_loop_), |
| 61 certificates_loaded_events_count_(0U) {} |
58 | 62 |
59 ~CertLoaderTest() override {} | 63 ~CertLoaderTest() override {} |
60 | 64 |
61 void SetUp() override { | 65 void SetUp() override { |
62 ASSERT_TRUE(primary_db_.is_open()); | 66 ASSERT_TRUE(primary_db_.is_open()); |
63 | 67 |
64 CertLoader::Initialize(); | 68 CertLoader::Initialize(); |
65 cert_loader_ = CertLoader::Get(); | 69 cert_loader_ = CertLoader::Get(); |
66 cert_loader_->AddObserver(this); | 70 cert_loader_->AddObserver(this); |
67 } | 71 } |
68 | 72 |
69 void TearDown() override { | 73 void TearDown() override { |
70 cert_loader_->RemoveObserver(this); | 74 cert_loader_->RemoveObserver(this); |
71 CertLoader::Shutdown(); | 75 CertLoader::Shutdown(); |
72 } | 76 } |
73 | 77 |
74 protected: | 78 protected: |
75 void StartCertLoaderWithPrimaryDB() { | 79 void StartCertLoaderWithPrimaryDB() { |
76 CreateCertDatabase(&primary_db_, &primary_certdb_); | 80 CreateCertDatabase(&primary_db_, &primary_certdb_); |
77 cert_loader_->StartWithNSSDB(primary_certdb_.get()); | 81 cert_loader_->StartWithNSSDB(primary_certdb_.get()); |
78 | 82 |
79 base::RunLoop().RunUntilIdle(); | 83 base::RunLoop().RunUntilIdle(); |
80 GetAndResetCertificatesLoadedEventsCount(); | 84 GetAndResetCertificatesLoadedEventsCount(); |
81 } | 85 } |
82 | 86 |
| 87 // Starts the cert loader with a primary cert database which has access to the |
| 88 // system token. |
| 89 void StartCertLoaderWithPrimaryDBAndSystemToken() { |
| 90 CreateCertDatabase(&primary_db_, &primary_certdb_); |
| 91 AddSystemToken(primary_certdb_.get()); |
| 92 cert_loader_->StartWithNSSDB(primary_certdb_.get()); |
| 93 |
| 94 base::RunLoop().RunUntilIdle(); |
| 95 GetAndResetCertificatesLoadedEventsCount(); |
| 96 } |
| 97 |
83 // CertLoader::Observer: | 98 // CertLoader::Observer: |
84 // The test keeps count of times the observer method was called. | 99 // The test keeps count of times the observer method was called. |
85 void OnCertificatesLoaded(const net::CertificateList& cert_list, | 100 void OnCertificatesLoaded(const net::CertificateList& cert_list, |
86 bool initial_load) override { | 101 bool initial_load) override { |
87 EXPECT_TRUE(certificates_loaded_events_count_ == 0 || !initial_load); | 102 EXPECT_TRUE(certificates_loaded_events_count_ == 0 || !initial_load); |
88 certificates_loaded_events_count_++; | 103 certificates_loaded_events_count_++; |
89 } | 104 } |
90 | 105 |
91 // Returns the number of |OnCertificatesLoaded| calls observed since the | 106 // Returns the number of |OnCertificatesLoaded| calls observed since the |
92 // last call to this method equals |value|. | 107 // last call to this method equals |value|. |
(...skipping 25 matching lines...) Expand all Loading... |
118 net::X509Certificate::FORMAT_AUTO); | 133 net::X509Certificate::FORMAT_AUTO); |
119 ASSERT_EQ(1U, imported_certs->size()); | 134 ASSERT_EQ(1U, imported_certs->size()); |
120 | 135 |
121 net::NSSCertDatabase::ImportCertFailureList failed; | 136 net::NSSCertDatabase::ImportCertFailureList failed; |
122 ASSERT_TRUE(database->ImportCACerts(*imported_certs, | 137 ASSERT_TRUE(database->ImportCACerts(*imported_certs, |
123 net::NSSCertDatabase::TRUST_DEFAULT, | 138 net::NSSCertDatabase::TRUST_DEFAULT, |
124 &failed)); | 139 &failed)); |
125 ASSERT_TRUE(failed.empty()); | 140 ASSERT_TRUE(failed.empty()); |
126 } | 141 } |
127 | 142 |
| 143 // Import a client cert and key into a PKCS11 slot. Then notify |
| 144 // |database_to_notify| (which is presumably using that slot) that new |
| 145 // certificates are available. |
128 scoped_refptr<net::X509Certificate> ImportClientCertAndKey( | 146 scoped_refptr<net::X509Certificate> ImportClientCertAndKey( |
129 TestNSSCertDatabase* database) { | 147 TestNSSCertDatabase* database_to_notify, |
| 148 PK11SlotInfo* slot_to_use) { |
130 // Import a client cert signed by that CA. | 149 // Import a client cert signed by that CA. |
131 scoped_refptr<net::X509Certificate> client_cert( | 150 scoped_refptr<net::X509Certificate> client_cert( |
132 net::ImportClientCertAndKeyFromFile(net::GetTestCertsDirectory(), | 151 net::ImportClientCertAndKeyFromFile(net::GetTestCertsDirectory(), |
133 "client_1.pem", "client_1.pk8", | 152 "client_1.pem", "client_1.pk8", |
134 database->GetPrivateSlot().get())); | 153 slot_to_use)); |
135 database->NotifyOfCertAdded(client_cert.get()); | 154 database_to_notify->NotifyObserversCertDBChanged(); |
136 return client_cert; | 155 return client_cert; |
137 } | 156 } |
138 | 157 |
| 158 // Import a client cert into |database|'s private slot. |
| 159 scoped_refptr<net::X509Certificate> ImportClientCertAndKey( |
| 160 TestNSSCertDatabase* database) { |
| 161 return ImportClientCertAndKey(database, database->GetPrivateSlot().get()); |
| 162 } |
| 163 |
139 CertLoader* cert_loader_; | 164 CertLoader* cert_loader_; |
140 | 165 |
141 // The user is primary as the one whose certificates CertLoader handles, it | 166 // The user is primary as the one whose certificates CertLoader handles, it |
142 // has nothing to do with crypto::InitializeNSSForChromeOSUser is_primary_user | 167 // has nothing to do with crypto::InitializeNSSForChromeOSUser is_primary_user |
143 // parameter (which is irrelevant for these tests). | 168 // parameter (which is irrelevant for these tests). |
144 crypto::ScopedTestNSSDB primary_db_; | 169 crypto::ScopedTestNSSDB primary_db_; |
145 std::unique_ptr<TestNSSCertDatabase> primary_certdb_; | 170 std::unique_ptr<TestNSSCertDatabase> primary_certdb_; |
146 | 171 |
| 172 // Additional NSS DB simulating the system token. |
| 173 crypto::ScopedTestNSSDB system_db_; |
| 174 |
147 base::MessageLoop message_loop_; | 175 base::MessageLoop message_loop_; |
148 | 176 |
149 private: | 177 private: |
| 178 // Adds the PKCS11 slot from |system_db_| to |certdb| as system slot. |
| 179 void AddSystemToken(TestNSSCertDatabase* certdb) { |
| 180 ASSERT_TRUE(system_db_.is_open()); |
| 181 certdb->SetSystemSlot( |
| 182 crypto::ScopedPK11Slot(PK11_ReferenceSlot(system_db_.slot()))); |
| 183 } |
| 184 |
| 185 base::test::ScopedTaskScheduler scoped_task_scheduler_; |
150 size_t certificates_loaded_events_count_; | 186 size_t certificates_loaded_events_count_; |
151 }; | 187 }; |
152 | 188 |
153 } // namespace | 189 } // namespace |
154 | 190 |
155 TEST_F(CertLoaderTest, Basic) { | 191 TEST_F(CertLoaderTest, Basic) { |
156 EXPECT_FALSE(cert_loader_->CertificatesLoading()); | 192 EXPECT_FALSE(cert_loader_->CertificatesLoading()); |
157 EXPECT_FALSE(cert_loader_->certificates_loaded()); | 193 EXPECT_FALSE(cert_loader_->certificates_loaded()); |
158 | 194 |
159 CreateCertDatabase(&primary_db_, &primary_certdb_); | 195 CreateCertDatabase(&primary_db_, &primary_certdb_); |
160 cert_loader_->StartWithNSSDB(primary_certdb_.get()); | 196 cert_loader_->StartWithNSSDB(primary_certdb_.get()); |
161 | 197 |
162 EXPECT_FALSE(cert_loader_->certificates_loaded()); | 198 EXPECT_FALSE(cert_loader_->certificates_loaded()); |
163 EXPECT_TRUE(cert_loader_->CertificatesLoading()); | 199 EXPECT_TRUE(cert_loader_->CertificatesLoading()); |
164 EXPECT_TRUE(cert_loader_->cert_list().empty()); | 200 EXPECT_TRUE(cert_loader_->all_certs().empty()); |
165 | 201 |
166 ASSERT_EQ(0U, GetAndResetCertificatesLoadedEventsCount()); | 202 ASSERT_EQ(0U, GetAndResetCertificatesLoadedEventsCount()); |
167 base::RunLoop().RunUntilIdle(); | 203 base::RunLoop().RunUntilIdle(); |
168 EXPECT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); | 204 EXPECT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); |
169 | 205 |
170 EXPECT_TRUE(cert_loader_->certificates_loaded()); | 206 EXPECT_TRUE(cert_loader_->certificates_loaded()); |
171 EXPECT_FALSE(cert_loader_->CertificatesLoading()); | 207 EXPECT_FALSE(cert_loader_->CertificatesLoading()); |
172 | 208 |
173 // Default CA cert roots should get loaded. | 209 // Default CA cert roots should get loaded. |
174 EXPECT_FALSE(cert_loader_->cert_list().empty()); | 210 EXPECT_FALSE(cert_loader_->all_certs().empty()); |
175 } | 211 } |
176 | 212 |
177 TEST_F(CertLoaderTest, CertLoaderUpdatesCertListOnNewCert) { | 213 TEST_F(CertLoaderTest, CertLoaderUpdatesCertListOnNewCert) { |
178 StartCertLoaderWithPrimaryDB(); | 214 StartCertLoaderWithPrimaryDB(); |
179 | 215 |
180 net::CertificateList certs; | 216 net::CertificateList certs; |
181 ImportCACert("root_ca_cert.pem", primary_certdb_.get(), &certs); | 217 ImportCACert("root_ca_cert.pem", primary_certdb_.get(), &certs); |
182 | 218 |
183 // Certs are loaded asynchronously, so the new cert should not yet be in the | 219 // Certs are loaded asynchronously, so the new cert should not yet be in the |
184 // cert list. | 220 // cert list. |
185 EXPECT_FALSE( | 221 EXPECT_FALSE( |
186 IsCertInCertificateList(certs[0].get(), cert_loader_->cert_list())); | 222 IsCertInCertificateList(certs[0].get(), cert_loader_->all_certs())); |
187 | 223 |
188 ASSERT_EQ(0U, GetAndResetCertificatesLoadedEventsCount()); | 224 ASSERT_EQ(0U, GetAndResetCertificatesLoadedEventsCount()); |
189 base::RunLoop().RunUntilIdle(); | 225 base::RunLoop().RunUntilIdle(); |
190 EXPECT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); | 226 EXPECT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); |
191 | 227 |
192 // The certificate list should be updated now, as the message loop's been run. | 228 // The certificate list should be updated now, as the message loop's been run. |
193 EXPECT_TRUE( | 229 EXPECT_TRUE( |
194 IsCertInCertificateList(certs[0].get(), cert_loader_->cert_list())); | 230 IsCertInCertificateList(certs[0].get(), cert_loader_->all_certs())); |
195 | 231 |
196 EXPECT_FALSE(cert_loader_->IsCertificateHardwareBacked(certs[0].get())); | 232 EXPECT_FALSE(cert_loader_->IsCertificateHardwareBacked(certs[0].get())); |
197 } | 233 } |
198 | 234 |
199 TEST_F(CertLoaderTest, CertLoaderNoUpdateOnSecondaryDbChanges) { | 235 TEST_F(CertLoaderTest, CertLoaderNoUpdateOnSecondaryDbChanges) { |
200 crypto::ScopedTestNSSDB secondary_db; | 236 crypto::ScopedTestNSSDB secondary_db; |
201 std::unique_ptr<TestNSSCertDatabase> secondary_certdb; | 237 std::unique_ptr<TestNSSCertDatabase> secondary_certdb; |
202 | 238 |
203 StartCertLoaderWithPrimaryDB(); | 239 StartCertLoaderWithPrimaryDB(); |
204 CreateCertDatabase(&secondary_db, &secondary_certdb); | 240 CreateCertDatabase(&secondary_db, &secondary_certdb); |
205 | 241 |
206 net::CertificateList certs; | 242 net::CertificateList certs; |
207 ImportCACert("root_ca_cert.pem", secondary_certdb.get(), &certs); | 243 ImportCACert("root_ca_cert.pem", secondary_certdb.get(), &certs); |
208 | 244 |
209 base::RunLoop().RunUntilIdle(); | 245 base::RunLoop().RunUntilIdle(); |
210 | 246 |
211 EXPECT_FALSE( | 247 EXPECT_FALSE( |
212 IsCertInCertificateList(certs[0].get(), cert_loader_->cert_list())); | 248 IsCertInCertificateList(certs[0].get(), cert_loader_->all_certs())); |
213 } | 249 } |
214 | 250 |
215 TEST_F(CertLoaderTest, ClientLoaderUpdateOnNewClientCert) { | 251 TEST_F(CertLoaderTest, ClientLoaderUpdateOnNewClientCert) { |
216 StartCertLoaderWithPrimaryDB(); | 252 StartCertLoaderWithPrimaryDB(); |
217 | 253 |
218 scoped_refptr<net::X509Certificate> cert( | 254 scoped_refptr<net::X509Certificate> cert( |
219 ImportClientCertAndKey(primary_certdb_.get())); | 255 ImportClientCertAndKey(primary_certdb_.get())); |
220 | 256 |
221 ASSERT_EQ(0U, GetAndResetCertificatesLoadedEventsCount()); | 257 ASSERT_EQ(0U, GetAndResetCertificatesLoadedEventsCount()); |
222 base::RunLoop().RunUntilIdle(); | 258 base::RunLoop().RunUntilIdle(); |
223 EXPECT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); | 259 EXPECT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); |
224 | 260 |
225 EXPECT_TRUE(IsCertInCertificateList(cert.get(), cert_loader_->cert_list())); | 261 EXPECT_TRUE(IsCertInCertificateList(cert.get(), cert_loader_->all_certs())); |
| 262 } |
| 263 |
| 264 TEST_F(CertLoaderTest, ClientLoaderUpdateOnNewClientCertInSystemToken) { |
| 265 StartCertLoaderWithPrimaryDBAndSystemToken(); |
| 266 |
| 267 EXPECT_TRUE(cert_loader_->system_certs().empty()); |
| 268 scoped_refptr<net::X509Certificate> cert(ImportClientCertAndKey( |
| 269 primary_certdb_.get(), primary_certdb_->GetSystemSlot().get())); |
| 270 |
| 271 ASSERT_EQ(0U, GetAndResetCertificatesLoadedEventsCount()); |
| 272 base::RunLoop().RunUntilIdle(); |
| 273 EXPECT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); |
| 274 |
| 275 EXPECT_TRUE(IsCertInCertificateList(cert.get(), cert_loader_->all_certs())); |
| 276 EXPECT_EQ(1U, cert_loader_->system_certs().size()); |
| 277 EXPECT_TRUE( |
| 278 IsCertInCertificateList(cert.get(), cert_loader_->system_certs())); |
226 } | 279 } |
227 | 280 |
228 TEST_F(CertLoaderTest, CertLoaderNoUpdateOnNewClientCertInSecondaryDb) { | 281 TEST_F(CertLoaderTest, CertLoaderNoUpdateOnNewClientCertInSecondaryDb) { |
229 crypto::ScopedTestNSSDB secondary_db; | 282 crypto::ScopedTestNSSDB secondary_db; |
230 std::unique_ptr<TestNSSCertDatabase> secondary_certdb; | 283 std::unique_ptr<TestNSSCertDatabase> secondary_certdb; |
231 | 284 |
232 StartCertLoaderWithPrimaryDB(); | 285 StartCertLoaderWithPrimaryDB(); |
233 CreateCertDatabase(&secondary_db, &secondary_certdb); | 286 CreateCertDatabase(&secondary_db, &secondary_certdb); |
234 | 287 |
235 scoped_refptr<net::X509Certificate> cert( | 288 scoped_refptr<net::X509Certificate> cert( |
236 ImportClientCertAndKey(secondary_certdb.get())); | 289 ImportClientCertAndKey(secondary_certdb.get())); |
237 | 290 |
238 base::RunLoop().RunUntilIdle(); | 291 base::RunLoop().RunUntilIdle(); |
239 | 292 |
240 EXPECT_FALSE(IsCertInCertificateList(cert.get(), cert_loader_->cert_list())); | 293 EXPECT_FALSE(IsCertInCertificateList(cert.get(), cert_loader_->all_certs())); |
241 } | 294 } |
242 | 295 |
243 TEST_F(CertLoaderTest, UpdatedOnCertRemoval) { | 296 TEST_F(CertLoaderTest, UpdatedOnCertRemoval) { |
244 StartCertLoaderWithPrimaryDB(); | 297 StartCertLoaderWithPrimaryDB(); |
245 | 298 |
246 scoped_refptr<net::X509Certificate> cert( | 299 scoped_refptr<net::X509Certificate> cert( |
247 ImportClientCertAndKey(primary_certdb_.get())); | 300 ImportClientCertAndKey(primary_certdb_.get())); |
248 | 301 |
249 base::RunLoop().RunUntilIdle(); | 302 base::RunLoop().RunUntilIdle(); |
250 | 303 |
251 ASSERT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); | 304 ASSERT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); |
252 ASSERT_TRUE(IsCertInCertificateList(cert.get(), cert_loader_->cert_list())); | 305 ASSERT_TRUE(IsCertInCertificateList(cert.get(), cert_loader_->all_certs())); |
253 | 306 |
254 primary_certdb_->DeleteCertAndKey(cert.get()); | 307 primary_certdb_->DeleteCertAndKey(cert.get()); |
255 | 308 |
256 ASSERT_EQ(0U, GetAndResetCertificatesLoadedEventsCount()); | 309 ASSERT_EQ(0U, GetAndResetCertificatesLoadedEventsCount()); |
257 base::RunLoop().RunUntilIdle(); | 310 base::RunLoop().RunUntilIdle(); |
258 EXPECT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); | 311 EXPECT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); |
259 | 312 |
260 ASSERT_FALSE(IsCertInCertificateList(cert.get(), cert_loader_->cert_list())); | 313 ASSERT_FALSE(IsCertInCertificateList(cert.get(), cert_loader_->all_certs())); |
261 } | 314 } |
262 | 315 |
263 TEST_F(CertLoaderTest, UpdatedOnCACertTrustChange) { | 316 TEST_F(CertLoaderTest, UpdatedOnCACertTrustChange) { |
264 StartCertLoaderWithPrimaryDB(); | 317 StartCertLoaderWithPrimaryDB(); |
265 | 318 |
266 net::CertificateList certs; | 319 net::CertificateList certs; |
267 ImportCACert("root_ca_cert.pem", primary_certdb_.get(), &certs); | 320 ImportCACert("root_ca_cert.pem", primary_certdb_.get(), &certs); |
268 | 321 |
269 base::RunLoop().RunUntilIdle(); | 322 base::RunLoop().RunUntilIdle(); |
270 ASSERT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); | 323 ASSERT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); |
271 ASSERT_TRUE( | 324 ASSERT_TRUE( |
272 IsCertInCertificateList(certs[0].get(), cert_loader_->cert_list())); | 325 IsCertInCertificateList(certs[0].get(), cert_loader_->all_certs())); |
273 | 326 |
274 // The value that should have been set by |ImportCACert|. | 327 // The value that should have been set by |ImportCACert|. |
275 ASSERT_EQ(net::NSSCertDatabase::TRUST_DEFAULT, | 328 ASSERT_EQ(net::NSSCertDatabase::TRUST_DEFAULT, |
276 primary_certdb_->GetCertTrust(certs[0].get(), net::CA_CERT)); | 329 primary_certdb_->GetCertTrust(certs[0].get(), net::CA_CERT)); |
277 ASSERT_TRUE(primary_certdb_->SetCertTrust(certs[0].get(), net::CA_CERT, | 330 ASSERT_TRUE(primary_certdb_->SetCertTrust(certs[0].get(), net::CA_CERT, |
278 net::NSSCertDatabase::TRUSTED_SSL)); | 331 net::NSSCertDatabase::TRUSTED_SSL)); |
279 | 332 |
280 // Cert trust change should trigger certificate reload in cert_loader_. | 333 // Cert trust change should trigger certificate reload in cert_loader_. |
281 ASSERT_EQ(0U, GetAndResetCertificatesLoadedEventsCount()); | 334 ASSERT_EQ(0U, GetAndResetCertificatesLoadedEventsCount()); |
282 base::RunLoop().RunUntilIdle(); | 335 base::RunLoop().RunUntilIdle(); |
283 EXPECT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); | 336 EXPECT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); |
284 } | 337 } |
285 | 338 |
286 } // namespace chromeos | 339 } // namespace chromeos |
OLD | NEW |