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