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 #include "chromeos/network/client_cert_resolver.h" | 4 #include "chromeos/network/client_cert_resolver.h" |
5 | 5 |
6 #include <cert.h> | 6 #include <cert.h> |
7 #include <pk11pub.h> | 7 #include <pk11pub.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 class ClientCertResolverTest : public testing::Test, | 53 class ClientCertResolverTest : public testing::Test, |
54 public ClientCertResolver::Observer { | 54 public ClientCertResolver::Observer { |
55 public: | 55 public: |
56 ClientCertResolverTest() | 56 ClientCertResolverTest() |
57 : network_properties_changed_count_(0), | 57 : network_properties_changed_count_(0), |
58 service_test_(nullptr), | 58 service_test_(nullptr), |
59 profile_test_(nullptr), | 59 profile_test_(nullptr), |
60 cert_loader_(nullptr) {} | 60 cert_loader_(nullptr), |
| 61 scoped_task_scheduler_(&message_loop_) {} |
61 ~ClientCertResolverTest() override {} | 62 ~ClientCertResolverTest() override {} |
62 | 63 |
63 void SetUp() override { | 64 void SetUp() override { |
64 ASSERT_TRUE(test_nssdb_.is_open()); | 65 ASSERT_TRUE(test_nssdb_.is_open()); |
65 | 66 |
66 // Use the same DB for public and private slot. | 67 // Use the same DB for public and private slot. |
67 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( | 68 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( |
68 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), | 69 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), |
69 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())))); | 70 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())))); |
| 71 test_nsscertdb_->SetSlowTaskRunnerForTest(message_loop_.task_runner()); |
70 | 72 |
71 DBusThreadManager::Initialize(); | 73 DBusThreadManager::Initialize(); |
72 service_test_ = | 74 service_test_ = |
73 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 75 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
74 profile_test_ = | 76 profile_test_ = |
75 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); | 77 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); |
76 profile_test_->AddProfile(kUserProfilePath, kUserHash); | 78 profile_test_->AddProfile(kUserProfilePath, kUserHash); |
77 base::RunLoop().RunUntilIdle(); | 79 base::RunLoop().RunUntilIdle(); |
78 service_test_->ClearServices(); | 80 service_test_->ClearServices(); |
79 base::RunLoop().RunUntilIdle(); | 81 base::RunLoop().RunUntilIdle(); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 } | 286 } |
285 | 287 |
286 ShillServiceClient::TestInterface* service_test_; | 288 ShillServiceClient::TestInterface* service_test_; |
287 ShillProfileClient::TestInterface* profile_test_; | 289 ShillProfileClient::TestInterface* profile_test_; |
288 CertLoader* cert_loader_; | 290 CertLoader* cert_loader_; |
289 std::unique_ptr<NetworkStateHandler> network_state_handler_; | 291 std::unique_ptr<NetworkStateHandler> network_state_handler_; |
290 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; | 292 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; |
291 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; | 293 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; |
292 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> | 294 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> |
293 managed_config_handler_; | 295 managed_config_handler_; |
| 296 base::MessageLoop message_loop_; |
294 base::test::ScopedTaskScheduler scoped_task_scheduler_; | 297 base::test::ScopedTaskScheduler scoped_task_scheduler_; |
295 scoped_refptr<net::X509Certificate> test_client_cert_; | 298 scoped_refptr<net::X509Certificate> test_client_cert_; |
296 std::string test_ca_cert_pem_; | 299 std::string test_ca_cert_pem_; |
297 crypto::ScopedTestNSSDB test_nssdb_; | 300 crypto::ScopedTestNSSDB test_nssdb_; |
298 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; | 301 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; |
299 | 302 |
300 DISALLOW_COPY_AND_ASSIGN(ClientCertResolverTest); | 303 DISALLOW_COPY_AND_ASSIGN(ClientCertResolverTest); |
301 }; | 304 }; |
302 | 305 |
303 TEST_F(ClientCertResolverTest, NoMatchingCertificates) { | 306 TEST_F(ClientCertResolverTest, NoMatchingCertificates) { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 // substituted into the shill service entry. | 439 // substituted into the shill service entry. |
437 SetupPolicyMatchingIssuerPEM("upn-${CERT_SAN_UPN}-suffix"); | 440 SetupPolicyMatchingIssuerPEM("upn-${CERT_SAN_UPN}-suffix"); |
438 base::RunLoop().RunUntilIdle(); | 441 base::RunLoop().RunUntilIdle(); |
439 | 442 |
440 GetServiceProperty(shill::kEapIdentityProperty, &identity); | 443 GetServiceProperty(shill::kEapIdentityProperty, &identity); |
441 EXPECT_EQ("upn-santest@ad.corp.example.com-suffix", identity); | 444 EXPECT_EQ("upn-santest@ad.corp.example.com-suffix", identity); |
442 EXPECT_EQ(2, network_properties_changed_count_); | 445 EXPECT_EQ(2, network_properties_changed_count_); |
443 } | 446 } |
444 | 447 |
445 } // namespace chromeos | 448 } // namespace chromeos |
OLD | NEW |