| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 virtual ~CertLoaderTest() {} | 50 virtual ~CertLoaderTest() {} |
| 51 | 51 |
| 52 virtual void SetUp() OVERRIDE { | 52 virtual void SetUp() OVERRIDE { |
| 53 ASSERT_TRUE(primary_user_.constructed_successfully()); | 53 ASSERT_TRUE(primary_user_.constructed_successfully()); |
| 54 ASSERT_TRUE( | 54 ASSERT_TRUE( |
| 55 crypto::GetPublicSlotForChromeOSUser(primary_user_.username_hash())); | 55 crypto::GetPublicSlotForChromeOSUser(primary_user_.username_hash())); |
| 56 | 56 |
| 57 CertLoader::Initialize(); | 57 CertLoader::Initialize(); |
| 58 cert_loader_ = CertLoader::Get(); | 58 cert_loader_ = CertLoader::Get(); |
| 59 cert_loader_->AddObserver(this); | 59 cert_loader_->AddObserver(this); |
| 60 cert_loader_->SetSlowTaskRunnerForTest(message_loop_.message_loop_proxy()); | |
| 61 } | 60 } |
| 62 | 61 |
| 63 virtual void TearDown() { | 62 virtual void TearDown() { |
| 64 cert_loader_->RemoveObserver(this); | 63 cert_loader_->RemoveObserver(this); |
| 65 CertLoader::Shutdown(); | 64 CertLoader::Shutdown(); |
| 66 } | 65 } |
| 67 | 66 |
| 68 protected: | 67 protected: |
| 69 void StartCertLoaderWithPrimaryUser() { | 68 void StartCertLoaderWithPrimaryUser() { |
| 70 FinishUserInitAndGetDatabase(&primary_user_, &primary_db_); | 69 FinishUserInitAndGetDatabase(&primary_user_, &primary_db_); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 101 | 100 |
| 102 crypto::ScopedPK11Slot private_slot( | 101 crypto::ScopedPK11Slot private_slot( |
| 103 crypto::GetPrivateSlotForChromeOSUser( | 102 crypto::GetPrivateSlotForChromeOSUser( |
| 104 user->username_hash(), | 103 user->username_hash(), |
| 105 base::Bind(&FailOnPrivateSlotCallback))); | 104 base::Bind(&FailOnPrivateSlotCallback))); |
| 106 ASSERT_TRUE(private_slot); | 105 ASSERT_TRUE(private_slot); |
| 107 | 106 |
| 108 database->reset(new net::NSSCertDatabaseChromeOS( | 107 database->reset(new net::NSSCertDatabaseChromeOS( |
| 109 crypto::GetPublicSlotForChromeOSUser(user->username_hash()), | 108 crypto::GetPublicSlotForChromeOSUser(user->username_hash()), |
| 110 private_slot.Pass())); | 109 private_slot.Pass())); |
| 110 (*database)->SetSlowTaskRunnerForTest(message_loop_.message_loop_proxy()); |
| 111 } | 111 } |
| 112 | 112 |
| 113 int GetDbPrivateSlotId(net::NSSCertDatabase* db) { | 113 int GetDbPrivateSlotId(net::NSSCertDatabase* db) { |
| 114 return static_cast<int>(PK11_GetSlotID(db->GetPrivateSlot().get())); | 114 return static_cast<int>(PK11_GetSlotID(db->GetPrivateSlot().get())); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ImportCACert(const std::string& cert_file, | 117 void ImportCACert(const std::string& cert_file, |
| 118 net::NSSCertDatabase* database, | 118 net::NSSCertDatabase* database, |
| 119 net::CertificateList* imported_certs) { | 119 net::CertificateList* imported_certs) { |
| 120 ASSERT_TRUE(database); | 120 ASSERT_TRUE(database); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 certs[0], net::CA_CERT, net::NSSCertDatabase::TRUSTED_SSL)); | 299 certs[0], net::CA_CERT, net::NSSCertDatabase::TRUSTED_SSL)); |
| 300 | 300 |
| 301 // Cert trust change should trigger certificate reload in cert_loader_. | 301 // Cert trust change should trigger certificate reload in cert_loader_. |
| 302 ASSERT_EQ(0U, GetAndResetCertificatesLoadedEventsCount()); | 302 ASSERT_EQ(0U, GetAndResetCertificatesLoadedEventsCount()); |
| 303 base::RunLoop().RunUntilIdle(); | 303 base::RunLoop().RunUntilIdle(); |
| 304 EXPECT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); | 304 EXPECT_EQ(1U, GetAndResetCertificatesLoadedEventsCount()); |
| 305 } | 305 } |
| 306 | 306 |
| 307 } // namespace | 307 } // namespace |
| 308 } // namespace chromeos | 308 } // namespace chromeos |
| OLD | NEW |