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

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

Issue 2608073003: Use TaskScheduler instead of WorkerPool in client_cert_resolver.cc. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « chromeos/network/client_cert_resolver.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/simple_test_clock.h" 20 #include "base/test/simple_test_clock.h"
20 #include "base/values.h" 21 #include "base/values.h"
21 #include "chromeos/cert_loader.h" 22 #include "chromeos/cert_loader.h"
22 #include "chromeos/dbus/dbus_thread_manager.h" 23 #include "chromeos/dbus/dbus_thread_manager.h"
23 #include "chromeos/dbus/shill_manager_client.h" 24 #include "chromeos/dbus/shill_manager_client.h"
24 #include "chromeos/dbus/shill_profile_client.h" 25 #include "chromeos/dbus/shill_profile_client.h"
25 #include "chromeos/dbus/shill_service_client.h" 26 #include "chromeos/dbus/shill_service_client.h"
26 #include "chromeos/network/managed_network_configuration_handler_impl.h" 27 #include "chromeos/network/managed_network_configuration_handler_impl.h"
27 #include "chromeos/network/network_configuration_handler.h" 28 #include "chromeos/network/network_configuration_handler.h"
28 #include "chromeos/network/network_profile_handler.h" 29 #include "chromeos/network/network_profile_handler.h"
(...skipping 20 matching lines...) Expand all
49 50
50 } // namespace 51 } // namespace
51 52
52 class ClientCertResolverTest : public testing::Test, 53 class ClientCertResolverTest : public testing::Test,
53 public ClientCertResolver::Observer { 54 public ClientCertResolver::Observer {
54 public: 55 public:
55 ClientCertResolverTest() 56 ClientCertResolverTest()
56 : network_properties_changed_count_(0), 57 : network_properties_changed_count_(0),
57 service_test_(nullptr), 58 service_test_(nullptr),
58 profile_test_(nullptr), 59 profile_test_(nullptr),
59 cert_loader_(nullptr) {} 60 cert_loader_(nullptr),
61 scoped_task_scheduler_(&message_loop_) {}
60 ~ClientCertResolverTest() override {} 62 ~ClientCertResolverTest() override {}
61 63
62 void SetUp() override { 64 void SetUp() override {
63 ASSERT_TRUE(test_nssdb_.is_open()); 65 ASSERT_TRUE(test_nssdb_.is_open());
64 66
65 // Use the same DB for public and private slot. 67 // Use the same DB for public and private slot.
66 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( 68 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS(
67 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), 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 test_nsscertdb_->SetSlowTaskRunnerForTest(message_loop_.task_runner()); 71 test_nsscertdb_->SetSlowTaskRunnerForTest(message_loop_.task_runner());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 managed_config_handler_->Init( 153 managed_config_handler_->Init(
152 network_state_handler_.get(), network_profile_handler_.get(), 154 network_state_handler_.get(), network_profile_handler_.get(),
153 network_config_handler_.get(), nullptr /* network_device_handler */, 155 network_config_handler_.get(), nullptr /* network_device_handler */,
154 nullptr /* prohibited_technologies_handler */); 156 nullptr /* prohibited_technologies_handler */);
155 // Run all notifications before starting the cert loader to reduce run time. 157 // Run all notifications before starting the cert loader to reduce run time.
156 base::RunLoop().RunUntilIdle(); 158 base::RunLoop().RunUntilIdle();
157 159
158 client_cert_resolver_->Init(network_state_handler_.get(), 160 client_cert_resolver_->Init(network_state_handler_.get(),
159 managed_config_handler_.get()); 161 managed_config_handler_.get());
160 client_cert_resolver_->AddObserver(this); 162 client_cert_resolver_->AddObserver(this);
161 client_cert_resolver_->SetSlowTaskRunnerForTest(
162 message_loop_.task_runner());
163 } 163 }
164 164
165 void SetupWifi() { 165 void SetupWifi() {
166 service_test_->SetServiceProperties(kWifiStub, 166 service_test_->SetServiceProperties(kWifiStub,
167 kWifiStub, 167 kWifiStub,
168 kWifiSSID, 168 kWifiSSID,
169 shill::kTypeWifi, 169 shill::kTypeWifi,
170 shill::kStateOnline, 170 shill::kStateOnline,
171 true /* visible */); 171 true /* visible */);
172 // Set an arbitrary cert id, so that we can check afterwards whether we 172 // Set an arbitrary cert id, so that we can check afterwards whether we
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 286
287 ShillServiceClient::TestInterface* service_test_; 287 ShillServiceClient::TestInterface* service_test_;
288 ShillProfileClient::TestInterface* profile_test_; 288 ShillProfileClient::TestInterface* profile_test_;
289 CertLoader* cert_loader_; 289 CertLoader* cert_loader_;
290 std::unique_ptr<NetworkStateHandler> network_state_handler_; 290 std::unique_ptr<NetworkStateHandler> network_state_handler_;
291 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; 291 std::unique_ptr<NetworkProfileHandler> network_profile_handler_;
292 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; 292 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_;
293 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> 293 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl>
294 managed_config_handler_; 294 managed_config_handler_;
295 base::MessageLoop message_loop_; 295 base::MessageLoop message_loop_;
296 base::test::ScopedTaskScheduler scoped_task_scheduler_;
296 scoped_refptr<net::X509Certificate> test_client_cert_; 297 scoped_refptr<net::X509Certificate> test_client_cert_;
297 std::string test_ca_cert_pem_; 298 std::string test_ca_cert_pem_;
298 crypto::ScopedTestNSSDB test_nssdb_; 299 crypto::ScopedTestNSSDB test_nssdb_;
299 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; 300 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_;
300 301
301 DISALLOW_COPY_AND_ASSIGN(ClientCertResolverTest); 302 DISALLOW_COPY_AND_ASSIGN(ClientCertResolverTest);
302 }; 303 };
303 304
304 TEST_F(ClientCertResolverTest, NoMatchingCertificates) { 305 TEST_F(ClientCertResolverTest, NoMatchingCertificates) {
305 SetupTestCerts("client_1", false /* do not import the issuer */); 306 SetupTestCerts("client_1", false /* do not import the issuer */);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 // substituted into the shill service entry. 438 // substituted into the shill service entry.
438 SetupPolicyMatchingIssuerPEM("upn-${CERT_SAN_UPN}-suffix"); 439 SetupPolicyMatchingIssuerPEM("upn-${CERT_SAN_UPN}-suffix");
439 base::RunLoop().RunUntilIdle(); 440 base::RunLoop().RunUntilIdle();
440 441
441 GetServiceProperty(shill::kEapIdentityProperty, &identity); 442 GetServiceProperty(shill::kEapIdentityProperty, &identity);
442 EXPECT_EQ("upn-santest@ad.corp.example.com-suffix", identity); 443 EXPECT_EQ("upn-santest@ad.corp.example.com-suffix", identity);
443 EXPECT_EQ(2, network_properties_changed_count_); 444 EXPECT_EQ(2, network_properties_changed_count_);
444 } 445 }
445 446
446 } // namespace chromeos 447 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/client_cert_resolver.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698