Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Side by Side Diff: chromeos/network/client_cert_resolver_unittest.cc

Issue 2840593002: Remove usage of ScopedTaskScheduler. (Closed)
Patch Set: self-review Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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() = default;
57 ~ClientCertResolverTest() override {} 58 ~ClientCertResolverTest() override {}
58 59
59 void SetUp() override { 60 void SetUp() override {
60 ASSERT_TRUE(test_nssdb_.is_open()); 61 ASSERT_TRUE(test_nssdb_.is_open());
61 ASSERT_TRUE(test_system_nssdb_.is_open()); 62 ASSERT_TRUE(test_system_nssdb_.is_open());
62 63
63 // Use the same DB for public and private slot. 64 // Use the same DB for public and private slot.
64 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( 65 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS(
65 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), 66 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())),
66 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())))); 67 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot()))));
67 test_nsscertdb_->SetSlowTaskRunnerForTest(message_loop_.task_runner()); 68 test_nsscertdb_->SetSlowTaskRunnerForTest(
69 base::ThreadTaskRunnerHandle::Get());
68 70
69 DBusThreadManager::Initialize(); 71 DBusThreadManager::Initialize();
70 service_test_ = 72 service_test_ =
71 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); 73 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
72 profile_test_ = 74 profile_test_ =
73 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); 75 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface();
74 profile_test_->AddProfile(kUserProfilePath, kUserHash); 76 profile_test_->AddProfile(kUserProfilePath, kUserHash);
75 base::RunLoop().RunUntilIdle(); 77 base::RunLoop().RunUntilIdle();
76 service_test_->ClearServices(); 78 service_test_->ClearServices();
77 base::RunLoop().RunUntilIdle(); 79 base::RunLoop().RunUntilIdle();
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 ++network_properties_changed_count_; 321 ++network_properties_changed_count_;
320 } 322 }
321 323
322 ShillServiceClient::TestInterface* service_test_ = nullptr; 324 ShillServiceClient::TestInterface* service_test_ = nullptr;
323 ShillProfileClient::TestInterface* profile_test_ = nullptr; 325 ShillProfileClient::TestInterface* profile_test_ = nullptr;
324 std::unique_ptr<NetworkStateHandler> network_state_handler_; 326 std::unique_ptr<NetworkStateHandler> network_state_handler_;
325 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; 327 std::unique_ptr<NetworkProfileHandler> network_profile_handler_;
326 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; 328 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_;
327 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> 329 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl>
328 managed_config_handler_; 330 managed_config_handler_;
329 base::MessageLoop message_loop_; 331 base::test::ScopedTaskEnvironment scoped_task_environment_;
330 base::test::ScopedTaskScheduler scoped_task_scheduler_;
331 scoped_refptr<net::X509Certificate> test_client_cert_; 332 scoped_refptr<net::X509Certificate> test_client_cert_;
332 std::string test_ca_cert_pem_; 333 std::string test_ca_cert_pem_;
333 crypto::ScopedTestNSSDB test_nssdb_; 334 crypto::ScopedTestNSSDB test_nssdb_;
334 crypto::ScopedTestNSSDB test_system_nssdb_; 335 crypto::ScopedTestNSSDB test_system_nssdb_;
335 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; 336 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_;
336 337
337 DISALLOW_COPY_AND_ASSIGN(ClientCertResolverTest); 338 DISALLOW_COPY_AND_ASSIGN(ClientCertResolverTest);
338 }; 339 };
339 340
340 TEST_F(ClientCertResolverTest, NoMatchingCertificates) { 341 TEST_F(ClientCertResolverTest, NoMatchingCertificates) {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 SetupPolicyMatchingIssuerPEM(onc::ONC_SOURCE_USER_POLICY, 592 SetupPolicyMatchingIssuerPEM(onc::ONC_SOURCE_USER_POLICY,
592 "upn-${CERT_SAN_UPN}-suffix"); 593 "upn-${CERT_SAN_UPN}-suffix");
593 base::RunLoop().RunUntilIdle(); 594 base::RunLoop().RunUntilIdle();
594 595
595 GetServiceProperty(shill::kEapIdentityProperty, &identity); 596 GetServiceProperty(shill::kEapIdentityProperty, &identity);
596 EXPECT_EQ("upn-santest@ad.corp.example.com-suffix", identity); 597 EXPECT_EQ("upn-santest@ad.corp.example.com-suffix", identity);
597 EXPECT_EQ(2, network_properties_changed_count_); 598 EXPECT_EQ(2, network_properties_changed_count_);
598 } 599 }
599 600
600 } // namespace chromeos 601 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698