Chromium Code Reviews| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 15 #include "base/json/json_reader.h" | 15 #include "base/json/json_reader.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 19 #include "base/test/scoped_task_scheduler.h" | 19 #include "base/test/scoped_task_environment.h" |
| 20 #include "base/test/simple_test_clock.h" | 20 #include "base/test/simple_test_clock.h" |
| 21 #include "base/threading/thread_task_runner_handle.h" | |
| 21 #include "base/values.h" | 22 #include "base/values.h" |
| 22 #include "chromeos/cert_loader.h" | 23 #include "chromeos/cert_loader.h" |
| 23 #include "chromeos/dbus/dbus_thread_manager.h" | 24 #include "chromeos/dbus/dbus_thread_manager.h" |
| 24 #include "chromeos/dbus/shill_manager_client.h" | 25 #include "chromeos/dbus/shill_manager_client.h" |
| 25 #include "chromeos/dbus/shill_profile_client.h" | 26 #include "chromeos/dbus/shill_profile_client.h" |
| 26 #include "chromeos/dbus/shill_service_client.h" | 27 #include "chromeos/dbus/shill_service_client.h" |
| 27 #include "chromeos/network/managed_network_configuration_handler_impl.h" | 28 #include "chromeos/network/managed_network_configuration_handler_impl.h" |
| 28 #include "chromeos/network/network_configuration_handler.h" | 29 #include "chromeos/network/network_configuration_handler.h" |
| 29 #include "chromeos/network/network_profile_handler.h" | 30 #include "chromeos/network/network_profile_handler.h" |
| 30 #include "chromeos/network/network_state_handler.h" | 31 #include "chromeos/network/network_state_handler.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 46 const char* kWifiStub = "wifi_stub"; | 47 const char* kWifiStub = "wifi_stub"; |
| 47 const char* kWifiSSID = "wifi_ssid"; | 48 const char* kWifiSSID = "wifi_ssid"; |
| 48 const char* kUserProfilePath = "user_profile"; | 49 const char* kUserProfilePath = "user_profile"; |
| 49 const char* kUserHash = "user_hash"; | 50 const char* kUserHash = "user_hash"; |
| 50 | 51 |
| 51 } // namespace | 52 } // namespace |
| 52 | 53 |
| 53 class ClientCertResolverTest : public testing::Test, | 54 class ClientCertResolverTest : public testing::Test, |
| 54 public ClientCertResolver::Observer { | 55 public ClientCertResolver::Observer { |
| 55 public: | 56 public: |
| 56 ClientCertResolverTest() : scoped_task_scheduler_(&message_loop_) {} | 57 ClientCertResolverTest() |
| 58 : network_properties_changed_count_(0), | |
| 59 service_test_(nullptr), | |
| 60 profile_test_(nullptr), | |
| 61 cert_loader_(nullptr) {} | |
|
gab
2017/05/01 19:05:03
Why init these? Already initialized inline below
fdoray
2017/05/03 17:38:14
Probably a bad merge
| |
| 57 ~ClientCertResolverTest() override {} | 62 ~ClientCertResolverTest() override {} |
| 58 | 63 |
| 59 void SetUp() override { | 64 void SetUp() override { |
| 60 ASSERT_TRUE(test_nssdb_.is_open()); | 65 ASSERT_TRUE(test_nssdb_.is_open()); |
| 61 ASSERT_TRUE(test_system_nssdb_.is_open()); | 66 ASSERT_TRUE(test_system_nssdb_.is_open()); |
| 62 | 67 |
| 63 // Use the same DB for public and private slot. | 68 // Use the same DB for public and private slot. |
| 64 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( | 69 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( |
| 65 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), | 70 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), |
| 66 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())))); | 71 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())))); |
| 67 test_nsscertdb_->SetSlowTaskRunnerForTest(message_loop_.task_runner()); | 72 test_nsscertdb_->SetSlowTaskRunnerForTest( |
| 73 base::ThreadTaskRunnerHandle::Get()); | |
| 68 | 74 |
| 69 DBusThreadManager::Initialize(); | 75 DBusThreadManager::Initialize(); |
| 70 service_test_ = | 76 service_test_ = |
| 71 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 77 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
| 72 profile_test_ = | 78 profile_test_ = |
| 73 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); | 79 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); |
| 74 profile_test_->AddProfile(kUserProfilePath, kUserHash); | 80 profile_test_->AddProfile(kUserProfilePath, kUserHash); |
| 75 base::RunLoop().RunUntilIdle(); | 81 base::RunLoop().RunUntilIdle(); |
| 76 service_test_->ClearServices(); | 82 service_test_->ClearServices(); |
| 77 base::RunLoop().RunUntilIdle(); | 83 base::RunLoop().RunUntilIdle(); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 ++network_properties_changed_count_; | 325 ++network_properties_changed_count_; |
| 320 } | 326 } |
| 321 | 327 |
| 322 ShillServiceClient::TestInterface* service_test_ = nullptr; | 328 ShillServiceClient::TestInterface* service_test_ = nullptr; |
| 323 ShillProfileClient::TestInterface* profile_test_ = nullptr; | 329 ShillProfileClient::TestInterface* profile_test_ = nullptr; |
| 324 std::unique_ptr<NetworkStateHandler> network_state_handler_; | 330 std::unique_ptr<NetworkStateHandler> network_state_handler_; |
| 325 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; | 331 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; |
| 326 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; | 332 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; |
| 327 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> | 333 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> |
| 328 managed_config_handler_; | 334 managed_config_handler_; |
| 329 base::MessageLoop message_loop_; | 335 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 330 base::test::ScopedTaskScheduler scoped_task_scheduler_; | |
| 331 scoped_refptr<net::X509Certificate> test_client_cert_; | 336 scoped_refptr<net::X509Certificate> test_client_cert_; |
| 332 std::string test_ca_cert_pem_; | 337 std::string test_ca_cert_pem_; |
| 333 crypto::ScopedTestNSSDB test_nssdb_; | 338 crypto::ScopedTestNSSDB test_nssdb_; |
| 334 crypto::ScopedTestNSSDB test_system_nssdb_; | 339 crypto::ScopedTestNSSDB test_system_nssdb_; |
| 335 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; | 340 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; |
| 336 | 341 |
| 337 DISALLOW_COPY_AND_ASSIGN(ClientCertResolverTest); | 342 DISALLOW_COPY_AND_ASSIGN(ClientCertResolverTest); |
| 338 }; | 343 }; |
| 339 | 344 |
| 340 TEST_F(ClientCertResolverTest, NoMatchingCertificates) { | 345 TEST_F(ClientCertResolverTest, NoMatchingCertificates) { |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 591 SetupPolicyMatchingIssuerPEM(onc::ONC_SOURCE_USER_POLICY, | 596 SetupPolicyMatchingIssuerPEM(onc::ONC_SOURCE_USER_POLICY, |
| 592 "upn-${CERT_SAN_UPN}-suffix"); | 597 "upn-${CERT_SAN_UPN}-suffix"); |
| 593 base::RunLoop().RunUntilIdle(); | 598 base::RunLoop().RunUntilIdle(); |
| 594 | 599 |
| 595 GetServiceProperty(shill::kEapIdentityProperty, &identity); | 600 GetServiceProperty(shill::kEapIdentityProperty, &identity); |
| 596 EXPECT_EQ("upn-santest@ad.corp.example.com-suffix", identity); | 601 EXPECT_EQ("upn-santest@ad.corp.example.com-suffix", identity); |
| 597 EXPECT_EQ(2, network_properties_changed_count_); | 602 EXPECT_EQ(2, network_properties_changed_count_); |
| 598 } | 603 } |
| 599 | 604 |
| 600 } // namespace chromeos | 605 } // namespace chromeos |
| OLD | NEW |