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

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

Issue 560903003: Remove implicit conversions from scoped_refptr to T* in chromeos/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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') | chromeos/network/network_cert_migrator.cc » ('j') | 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 "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 network_state_handler_.reset(); 93 network_state_handler_.reset();
94 CertLoader::Shutdown(); 94 CertLoader::Shutdown();
95 TPMTokenLoader::Shutdown(); 95 TPMTokenLoader::Shutdown();
96 DBusThreadManager::Shutdown(); 96 DBusThreadManager::Shutdown();
97 CleanupSlotContents(); 97 CleanupSlotContents();
98 } 98 }
99 99
100 protected: 100 protected:
101 void StartCertLoader() { 101 void StartCertLoader() {
102 cert_loader_->StartWithNSSDB(test_nssdb_.get()); 102 cert_loader_->StartWithNSSDB(test_nssdb_.get());
103 if (test_client_cert_) { 103 if (test_client_cert_.get()) {
104 int slot_id = 0; 104 int slot_id = 0;
105 const std::string pkcs11_id = 105 const std::string pkcs11_id =
106 CertLoader::GetPkcs11IdAndSlotForCert(*test_client_cert_, &slot_id); 106 CertLoader::GetPkcs11IdAndSlotForCert(*test_client_cert_, &slot_id);
107 test_cert_id_ = base::StringPrintf("%i:%s", slot_id, pkcs11_id.c_str()); 107 test_cert_id_ = base::StringPrintf("%i:%s", slot_id, pkcs11_id.c_str());
108 } 108 }
109 } 109 }
110 110
111 // Imports a CA cert (stored as PEM in test_ca_cert_pem_) and a client 111 // Imports a CA cert (stored as PEM in test_ca_cert_pem_) and a client
112 // certificate signed by that CA. Its PKCS#11 ID is stored in 112 // certificate signed by that CA. Its PKCS#11 ID is stored in
113 // |test_cert_id_|. 113 // |test_cert_id_|.
(...skipping 15 matching lines...) Expand all
129 129
130 // Import a client cert signed by that CA. 130 // Import a client cert signed by that CA.
131 std::string pkcs12_data; 131 std::string pkcs12_data;
132 ASSERT_TRUE(base::ReadFileToString( 132 ASSERT_TRUE(base::ReadFileToString(
133 net::GetTestCertsDirectory().Append("websocket_client_cert.p12"), 133 net::GetTestCertsDirectory().Append("websocket_client_cert.p12"),
134 &pkcs12_data)); 134 &pkcs12_data));
135 135
136 net::CertificateList client_cert_list; 136 net::CertificateList client_cert_list;
137 scoped_refptr<net::CryptoModule> module( 137 scoped_refptr<net::CryptoModule> module(
138 net::CryptoModule::CreateFromHandle(private_slot_.get())); 138 net::CryptoModule::CreateFromHandle(private_slot_.get()));
139 ASSERT_EQ( 139 ASSERT_EQ(net::OK,
140 net::OK, 140 test_nssdb_->ImportFromPKCS12(module.get(),
141 test_nssdb_->ImportFromPKCS12( 141 pkcs12_data,
142 module, pkcs12_data, base::string16(), false, &client_cert_list)); 142 base::string16(),
143 false,
144 &client_cert_list));
143 ASSERT_TRUE(!client_cert_list.empty()); 145 ASSERT_TRUE(!client_cert_list.empty());
144 test_client_cert_ = client_cert_list[0]; 146 test_client_cert_ = client_cert_list[0];
145 } 147 }
146 148
147 void SetupNetworkHandlers() { 149 void SetupNetworkHandlers() {
148 network_state_handler_.reset(NetworkStateHandler::InitializeForTest()); 150 network_state_handler_.reset(NetworkStateHandler::InitializeForTest());
149 network_profile_handler_.reset(new NetworkProfileHandler()); 151 network_profile_handler_.reset(new NetworkProfileHandler());
150 network_config_handler_.reset(new NetworkConfigurationHandler()); 152 network_config_handler_.reset(new NetworkConfigurationHandler());
151 managed_config_handler_.reset(new ManagedNetworkConfigurationHandlerImpl()); 153 managed_config_handler_.reset(new ManagedNetworkConfigurationHandlerImpl());
152 client_cert_resolver_.reset(new ClientCertResolver()); 154 client_cert_resolver_.reset(new ClientCertResolver());
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 base::RunLoop().RunUntilIdle(); 311 base::RunLoop().RunUntilIdle();
310 312
311 // Verify that the resolver positively matched the pattern in the policy with 313 // Verify that the resolver positively matched the pattern in the policy with
312 // the test client cert and configured the network. 314 // the test client cert and configured the network.
313 std::string pkcs11_id; 315 std::string pkcs11_id;
314 GetClientCertProperties(&pkcs11_id); 316 GetClientCertProperties(&pkcs11_id);
315 EXPECT_EQ(test_cert_id_, pkcs11_id); 317 EXPECT_EQ(test_cert_id_, pkcs11_id);
316 } 318 }
317 319
318 } // namespace chromeos 320 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/client_cert_resolver.cc ('k') | chromeos/network/network_cert_migrator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698