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 #include <pk11pub.h> | 8 #include <pk11pub.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/test/scoped_task_scheduler.h" | |
16 #include "chromeos/cert_loader.h" | 15 #include "chromeos/cert_loader.h" |
17 #include "chromeos/dbus/dbus_thread_manager.h" | 16 #include "chromeos/dbus/dbus_thread_manager.h" |
18 #include "chromeos/dbus/shill_profile_client.h" | 17 #include "chromeos/dbus/shill_profile_client.h" |
19 #include "chromeos/dbus/shill_service_client.h" | 18 #include "chromeos/dbus/shill_service_client.h" |
20 #include "chromeos/network/network_state_handler.h" | 19 #include "chromeos/network/network_state_handler.h" |
21 #include "crypto/scoped_nss_types.h" | 20 #include "crypto/scoped_nss_types.h" |
22 #include "crypto/scoped_test_nss_db.h" | 21 #include "crypto/scoped_test_nss_db.h" |
23 #include "net/cert/nss_cert_database_chromeos.h" | 22 #include "net/cert/nss_cert_database_chromeos.h" |
24 #include "net/cert/x509_certificate.h" | 23 #include "net/cert/x509_certificate.h" |
25 #include "net/test/cert_test_util.h" | 24 #include "net/test/cert_test_util.h" |
(...skipping 16 matching lines...) Expand all Loading... |
42 public: | 41 public: |
43 NetworkCertMigratorTest() : service_test_(nullptr) {} | 42 NetworkCertMigratorTest() : service_test_(nullptr) {} |
44 ~NetworkCertMigratorTest() override {} | 43 ~NetworkCertMigratorTest() override {} |
45 | 44 |
46 void SetUp() override { | 45 void SetUp() override { |
47 ASSERT_TRUE(test_nssdb_.is_open()); | 46 ASSERT_TRUE(test_nssdb_.is_open()); |
48 // Use the same DB for public and private slot. | 47 // Use the same DB for public and private slot. |
49 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( | 48 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( |
50 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), | 49 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), |
51 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())))); | 50 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())))); |
| 51 test_nsscertdb_->SetSlowTaskRunnerForTest(message_loop_.task_runner()); |
52 | 52 |
53 DBusThreadManager::Initialize(); | 53 DBusThreadManager::Initialize(); |
54 service_test_ = | 54 service_test_ = |
55 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 55 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
56 DBusThreadManager::Get() | 56 DBusThreadManager::Get() |
57 ->GetShillProfileClient() | 57 ->GetShillProfileClient() |
58 ->GetTestInterface() | 58 ->GetTestInterface() |
59 ->AddProfile(kProfile, "" /* userhash */); | 59 ->AddProfile(kProfile, "" /* userhash */); |
60 base::RunLoop().RunUntilIdle(); | 60 base::RunLoop().RunUntilIdle(); |
61 service_test_->ClearServices(); | 61 service_test_->ClearServices(); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 shill::kL2tpIpsecClientCertSlotProperty, slot_id); | 182 shill::kL2tpIpsecClientCertSlotProperty, slot_id); |
183 provider->GetStringWithoutPathExpansion( | 183 provider->GetStringWithoutPathExpansion( |
184 shill::kL2tpIpsecClientCertIdProperty, pkcs11_id); | 184 shill::kL2tpIpsecClientCertIdProperty, pkcs11_id); |
185 } | 185 } |
186 } | 186 } |
187 | 187 |
188 ShillServiceClient::TestInterface* service_test_; | 188 ShillServiceClient::TestInterface* service_test_; |
189 scoped_refptr<net::X509Certificate> test_client_cert_; | 189 scoped_refptr<net::X509Certificate> test_client_cert_; |
190 std::string test_client_cert_pkcs11_id_; | 190 std::string test_client_cert_pkcs11_id_; |
191 std::string test_client_cert_slot_id_; | 191 std::string test_client_cert_slot_id_; |
192 base::test::ScopedTaskScheduler scoped_task_scheduler_; | 192 base::MessageLoop message_loop_; |
193 | 193 |
194 private: | 194 private: |
195 std::unique_ptr<NetworkStateHandler> network_state_handler_; | 195 std::unique_ptr<NetworkStateHandler> network_state_handler_; |
196 std::unique_ptr<NetworkCertMigrator> network_cert_migrator_; | 196 std::unique_ptr<NetworkCertMigrator> network_cert_migrator_; |
197 crypto::ScopedTestNSSDB test_nssdb_; | 197 crypto::ScopedTestNSSDB test_nssdb_; |
198 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; | 198 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; |
199 | 199 |
200 DISALLOW_COPY_AND_ASSIGN(NetworkCertMigratorTest); | 200 DISALLOW_COPY_AND_ASSIGN(NetworkCertMigratorTest); |
201 }; | 201 }; |
202 | 202 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 base::RunLoop().RunUntilIdle(); | 332 base::RunLoop().RunUntilIdle(); |
333 | 333 |
334 std::string pkcs11_id; | 334 std::string pkcs11_id; |
335 std::string slot_id; | 335 std::string slot_id; |
336 GetVpnCertId(false /* IPsec */, &slot_id, &pkcs11_id); | 336 GetVpnCertId(false /* IPsec */, &slot_id, &pkcs11_id); |
337 EXPECT_EQ(test_client_cert_pkcs11_id_, pkcs11_id); | 337 EXPECT_EQ(test_client_cert_pkcs11_id_, pkcs11_id); |
338 EXPECT_EQ(test_client_cert_slot_id_, slot_id); | 338 EXPECT_EQ(test_client_cert_slot_id_, slot_id); |
339 } | 339 } |
340 | 340 |
341 } // namespace chromeos | 341 } // namespace chromeos |
OLD | NEW |