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

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

Issue 2828713002: Enable client certificate patterns in device ONC policy (Closed)
Patch Set: Addressed comments - more DCHECKs, use PostTask..WithReply in client_cert_resolver.cc. 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 4
5 #include "chromeos/network/network_cert_migrator.h" 5 #include "chromeos/network/network_cert_migrator.h"
6 6
7 #include <cert.h> 7 #include <cert.h>
8 #include <pk11pub.h> 8 #include <pk11pub.h>
9 #include <string> 9 #include <string>
10 10
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/test/scoped_task_scheduler.h"
15 #include "chromeos/cert_loader.h" 16 #include "chromeos/cert_loader.h"
16 #include "chromeos/dbus/dbus_thread_manager.h" 17 #include "chromeos/dbus/dbus_thread_manager.h"
17 #include "chromeos/dbus/shill_profile_client.h" 18 #include "chromeos/dbus/shill_profile_client.h"
18 #include "chromeos/dbus/shill_service_client.h" 19 #include "chromeos/dbus/shill_service_client.h"
19 #include "chromeos/network/network_state_handler.h" 20 #include "chromeos/network/network_state_handler.h"
20 #include "crypto/scoped_nss_types.h" 21 #include "crypto/scoped_nss_types.h"
21 #include "crypto/scoped_test_nss_db.h" 22 #include "crypto/scoped_test_nss_db.h"
22 #include "net/cert/nss_cert_database_chromeos.h" 23 #include "net/cert/nss_cert_database_chromeos.h"
23 #include "net/cert/x509_certificate.h" 24 #include "net/cert/x509_certificate.h"
24 #include "net/test/cert_test_util.h" 25 #include "net/test/cert_test_util.h"
25 #include "net/test/test_data_directory.h" 26 #include "net/test/test_data_directory.h"
26 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
27 #include "third_party/cros_system_api/dbus/service_constants.h" 28 #include "third_party/cros_system_api/dbus/service_constants.h"
28 29
29 namespace chromeos { 30 namespace chromeos {
30 31
31 namespace { 32 namespace {
32 33
33 const char* kWifiStub = "wifi_stub"; 34 const char* kWifiStub = "wifi_stub";
34 const char* kEthernetEapStub = "ethernet_eap_stub"; 35 const char* kEthernetEapStub = "ethernet_eap_stub";
35 const char* kVPNStub = "vpn_stub"; 36 const char* kVPNStub = "vpn_stub";
36 const char* kProfile = "/profile/profile1"; 37 const char* kProfile = "/profile/profile1";
37 38
38 } // namespace 39 } // namespace
39 40
40 class NetworkCertMigratorTest : public testing::Test { 41 class NetworkCertMigratorTest : public testing::Test {
41 public: 42 public:
42 NetworkCertMigratorTest() : service_test_(nullptr) {} 43 NetworkCertMigratorTest()
44 : service_test_(nullptr), scoped_task_scheduler_(&message_loop_) {}
43 ~NetworkCertMigratorTest() override {} 45 ~NetworkCertMigratorTest() override {}
44 46
45 void SetUp() override { 47 void SetUp() override {
46 ASSERT_TRUE(test_nssdb_.is_open()); 48 ASSERT_TRUE(test_nssdb_.is_open());
47 // Use the same DB for public and private slot. 49 // Use the same DB for public and private slot.
48 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( 50 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS(
49 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), 51 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())),
50 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())))); 52 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot()))));
51 test_nsscertdb_->SetSlowTaskRunnerForTest(message_loop_.task_runner()); 53 test_nsscertdb_->SetSlowTaskRunnerForTest(message_loop_.task_runner());
52 54
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 185 }
184 } 186 }
185 187
186 ShillServiceClient::TestInterface* service_test_; 188 ShillServiceClient::TestInterface* service_test_;
187 scoped_refptr<net::X509Certificate> test_client_cert_; 189 scoped_refptr<net::X509Certificate> test_client_cert_;
188 std::string test_client_cert_pkcs11_id_; 190 std::string test_client_cert_pkcs11_id_;
189 std::string test_client_cert_slot_id_; 191 std::string test_client_cert_slot_id_;
190 base::MessageLoop message_loop_; 192 base::MessageLoop message_loop_;
191 193
192 private: 194 private:
195 base::test::ScopedTaskScheduler scoped_task_scheduler_;
193 std::unique_ptr<NetworkStateHandler> network_state_handler_; 196 std::unique_ptr<NetworkStateHandler> network_state_handler_;
194 std::unique_ptr<NetworkCertMigrator> network_cert_migrator_; 197 std::unique_ptr<NetworkCertMigrator> network_cert_migrator_;
195 crypto::ScopedTestNSSDB test_nssdb_; 198 crypto::ScopedTestNSSDB test_nssdb_;
196 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; 199 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_;
197 200
198 DISALLOW_COPY_AND_ASSIGN(NetworkCertMigratorTest); 201 DISALLOW_COPY_AND_ASSIGN(NetworkCertMigratorTest);
199 }; 202 };
200 203
201 TEST_F(NetworkCertMigratorTest, MigrateOnInitialization) { 204 TEST_F(NetworkCertMigratorTest, MigrateOnInitialization) {
202 SetupTestClientCert(); 205 SetupTestClientCert();
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 base::RunLoop().RunUntilIdle(); 333 base::RunLoop().RunUntilIdle();
331 334
332 std::string pkcs11_id; 335 std::string pkcs11_id;
333 std::string slot_id; 336 std::string slot_id;
334 GetVpnCertId(false /* IPsec */, &slot_id, &pkcs11_id); 337 GetVpnCertId(false /* IPsec */, &slot_id, &pkcs11_id);
335 EXPECT_EQ(test_client_cert_pkcs11_id_, pkcs11_id); 338 EXPECT_EQ(test_client_cert_pkcs11_id_, pkcs11_id);
336 EXPECT_EQ(test_client_cert_slot_id_, slot_id); 339 EXPECT_EQ(test_client_cert_slot_id_, slot_id);
337 } 340 }
338 341
339 } // namespace chromeos 342 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_cert_migrator.cc ('k') | chromeos/network/network_connection_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698