| OLD | NEW |
| 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 "chromeos/network/network_cert_migrator.h" | 5 #include "chromeos/network/network_cert_migrator.h" |
| 6 | 6 |
| 7 #include <cert.h> | 7 #include <cert.h> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 } // namespace | 44 } // namespace |
| 45 | 45 |
| 46 class NetworkCertMigratorTest : public testing::Test { | 46 class NetworkCertMigratorTest : public testing::Test { |
| 47 public: | 47 public: |
| 48 NetworkCertMigratorTest() : service_test_(NULL), | 48 NetworkCertMigratorTest() : service_test_(NULL), |
| 49 user_("user_hash") { | 49 user_("user_hash") { |
| 50 } | 50 } |
| 51 virtual ~NetworkCertMigratorTest() {} | 51 virtual ~NetworkCertMigratorTest() {} |
| 52 | 52 |
| 53 virtual void SetUp() OVERRIDE { | 53 virtual void SetUp() override { |
| 54 // Initialize NSS db for the user. | 54 // Initialize NSS db for the user. |
| 55 ASSERT_TRUE(user_.constructed_successfully()); | 55 ASSERT_TRUE(user_.constructed_successfully()); |
| 56 user_.FinishInit(); | 56 user_.FinishInit(); |
| 57 test_nssdb_.reset(new net::NSSCertDatabaseChromeOS( | 57 test_nssdb_.reset(new net::NSSCertDatabaseChromeOS( |
| 58 crypto::GetPublicSlotForChromeOSUser(user_.username_hash()), | 58 crypto::GetPublicSlotForChromeOSUser(user_.username_hash()), |
| 59 crypto::GetPrivateSlotForChromeOSUser( | 59 crypto::GetPrivateSlotForChromeOSUser( |
| 60 user_.username_hash(), | 60 user_.username_hash(), |
| 61 base::Callback<void(crypto::ScopedPK11Slot)>()))); | 61 base::Callback<void(crypto::ScopedPK11Slot)>()))); |
| 62 test_nssdb_->SetSlowTaskRunnerForTest(message_loop_.message_loop_proxy()); | 62 test_nssdb_->SetSlowTaskRunnerForTest(message_loop_.message_loop_proxy()); |
| 63 | 63 |
| 64 DBusThreadManager::Initialize(); | 64 DBusThreadManager::Initialize(); |
| 65 service_test_ = | 65 service_test_ = |
| 66 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 66 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
| 67 DBusThreadManager::Get() | 67 DBusThreadManager::Get() |
| 68 ->GetShillProfileClient() | 68 ->GetShillProfileClient() |
| 69 ->GetTestInterface() | 69 ->GetTestInterface() |
| 70 ->AddProfile(kProfile, "" /* userhash */); | 70 ->AddProfile(kProfile, "" /* userhash */); |
| 71 base::RunLoop().RunUntilIdle(); | 71 base::RunLoop().RunUntilIdle(); |
| 72 service_test_->ClearServices(); | 72 service_test_->ClearServices(); |
| 73 base::RunLoop().RunUntilIdle(); | 73 base::RunLoop().RunUntilIdle(); |
| 74 | 74 |
| 75 CertLoader::Initialize(); | 75 CertLoader::Initialize(); |
| 76 CertLoader* cert_loader_ = CertLoader::Get(); | 76 CertLoader* cert_loader_ = CertLoader::Get(); |
| 77 cert_loader_->StartWithNSSDB(test_nssdb_.get()); | 77 cert_loader_->StartWithNSSDB(test_nssdb_.get()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 virtual void TearDown() OVERRIDE { | 80 virtual void TearDown() override { |
| 81 network_cert_migrator_.reset(); | 81 network_cert_migrator_.reset(); |
| 82 network_state_handler_.reset(); | 82 network_state_handler_.reset(); |
| 83 CertLoader::Shutdown(); | 83 CertLoader::Shutdown(); |
| 84 DBusThreadManager::Shutdown(); | 84 DBusThreadManager::Shutdown(); |
| 85 CleanupTestCert(); | 85 CleanupTestCert(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 protected: | 88 protected: |
| 89 void SetupTestCACert() { | 89 void SetupTestCACert() { |
| 90 scoped_refptr<net::X509Certificate> cert_wo_nickname = | 90 scoped_refptr<net::X509Certificate> cert_wo_nickname = |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 std::string pkcs11_id; | 503 std::string pkcs11_id; |
| 504 std::string slot_id; | 504 std::string slot_id; |
| 505 GetVpnCertId(false /* IPsec */, &slot_id, &pkcs11_id); | 505 GetVpnCertId(false /* IPsec */, &slot_id, &pkcs11_id); |
| 506 EXPECT_EQ(test_client_cert_pkcs11_id_, pkcs11_id); | 506 EXPECT_EQ(test_client_cert_pkcs11_id_, pkcs11_id); |
| 507 EXPECT_EQ(test_client_cert_slot_id_, slot_id); | 507 EXPECT_EQ(test_client_cert_slot_id_, slot_id); |
| 508 } | 508 } |
| 509 | 509 |
| 510 } // namespace chromeos | 510 } // namespace chromeos |
| 511 | 511 |
| 512 #endif | 512 #endif |
| OLD | NEW |