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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 virtual ~CertLoaderTest() {} | 49 virtual ~CertLoaderTest() {} |
50 | 50 |
51 virtual void SetUp() OVERRIDE { | 51 virtual void SetUp() OVERRIDE { |
52 ASSERT_TRUE(primary_user_.constructed_successfully()); | 52 ASSERT_TRUE(primary_user_.constructed_successfully()); |
53 ASSERT_TRUE( | 53 ASSERT_TRUE( |
54 crypto::GetPublicSlotForChromeOSUser(primary_user_.username_hash())); | 54 crypto::GetPublicSlotForChromeOSUser(primary_user_.username_hash())); |
55 | 55 |
56 CertLoader::Initialize(); | 56 CertLoader::Initialize(); |
57 cert_loader_ = CertLoader::Get(); | 57 cert_loader_ = CertLoader::Get(); |
58 cert_loader_->AddObserver(this); | 58 cert_loader_->AddObserver(this); |
59 cert_loader_->SetSlowTaskRunnerForTest(message_loop_.message_loop_proxy()); | |
60 } | 59 } |
61 | 60 |
62 virtual void TearDown() { | 61 virtual void TearDown() { |
63 cert_loader_->RemoveObserver(this); | 62 cert_loader_->RemoveObserver(this); |
64 CertLoader::Shutdown(); | 63 CertLoader::Shutdown(); |
65 } | 64 } |
66 | 65 |
67 protected: | 66 protected: |
68 // CertLoader::Observer: | 67 // CertLoader::Observer: |
69 // The test keeps count of times the observer method was called. | 68 // The test keeps count of times the observer method was called. |
(...skipping 23 matching lines...) Expand all Loading... |
93 crypto::ScopedPK11Slot private_slot( | 92 crypto::ScopedPK11Slot private_slot( |
94 crypto::GetPrivateSlotForChromeOSUser( | 93 crypto::GetPrivateSlotForChromeOSUser( |
95 user->username_hash(), | 94 user->username_hash(), |
96 base::Bind(&NotReachedPrivateSlotCallback))); | 95 base::Bind(&NotReachedPrivateSlotCallback))); |
97 if (!private_slot) | 96 if (!private_slot) |
98 return database.Pass(); | 97 return database.Pass(); |
99 | 98 |
100 database.reset(new net::NSSCertDatabaseChromeOS( | 99 database.reset(new net::NSSCertDatabaseChromeOS( |
101 crypto::GetPublicSlotForChromeOSUser(user->username_hash()), | 100 crypto::GetPublicSlotForChromeOSUser(user->username_hash()), |
102 private_slot.Pass())); | 101 private_slot.Pass())); |
| 102 database->SetSlowTaskRunnerForTest(message_loop_.message_loop_proxy()); |
103 return database.Pass(); | 103 return database.Pass(); |
104 } | 104 } |
105 | 105 |
106 int GetDbPrivateSlotId(net::NSSCertDatabase* db) { | 106 int GetDbPrivateSlotId(net::NSSCertDatabase* db) { |
107 return static_cast<int>(PK11_GetSlotID(db->GetPrivateSlot().get())); | 107 return static_cast<int>(PK11_GetSlotID(db->GetPrivateSlot().get())); |
108 } | 108 } |
109 | 109 |
110 bool ImportCACerts(const std::string& cert_file, | 110 bool ImportCACerts(const std::string& cert_file, |
111 net::NSSCertDatabase* database, | 111 net::NSSCertDatabase* database, |
112 net::CertificateList* imported_certs) { | 112 net::CertificateList* imported_certs) { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 ASSERT_TRUE(NewCertificatesLoadedEventsCountEquals(0U)); | 327 ASSERT_TRUE(NewCertificatesLoadedEventsCountEquals(0U)); |
328 base::RunLoop().RunUntilIdle(); | 328 base::RunLoop().RunUntilIdle(); |
329 EXPECT_TRUE(NewCertificatesLoadedEventsCountEquals(1U)); | 329 EXPECT_TRUE(NewCertificatesLoadedEventsCountEquals(1U)); |
330 | 330 |
331 ASSERT_FALSE(IsCertInCertificateList(client_certs[0], | 331 ASSERT_FALSE(IsCertInCertificateList(client_certs[0], |
332 cert_loader_->cert_list())); | 332 cert_loader_->cert_list())); |
333 } | 333 } |
334 | 334 |
335 } // namespace | 335 } // namespace |
336 } // namespace chromeos | 336 } // namespace chromeos |
OLD | NEW |