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

Side by Side Diff: chromeos/network/onc/onc_certificate_importer_unittest.cc

Issue 13473003: Rename ONC field Trust to TrustBits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chromeos/network/onc/onc_certificate_importer.cc ('k') | chromeos/network/onc/onc_constants.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/onc/onc_certificate_importer.h" 5 #include "chromeos/network/onc/onc_certificate_importer.h"
6 6
7 #include <cert.h> 7 #include <cert.h>
8 #include <certdb.h> 8 #include <certdb.h>
9 #include <keyhi.h> 9 #include <keyhi.h>
10 #include <pk11pub.h> 10 #include <pk11pub.h>
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 216
217 SECKEYPrivateKeyList* privkey_list = 217 SECKEYPrivateKeyList* privkey_list =
218 PK11_ListPrivKeysInSlot(slot_->os_module_handle(), NULL, NULL); 218 PK11_ListPrivKeysInSlot(slot_->os_module_handle(), NULL, NULL);
219 EXPECT_FALSE(privkey_list); 219 EXPECT_FALSE(privkey_list);
220 220
221 SECKEYPublicKeyList* pubkey_list = 221 SECKEYPublicKeyList* pubkey_list =
222 PK11_ListPublicKeysInSlot(slot_->os_module_handle(), NULL); 222 PK11_ListPublicKeysInSlot(slot_->os_module_handle(), NULL);
223 EXPECT_FALSE(pubkey_list); 223 EXPECT_FALSE(pubkey_list);
224 } 224 }
225 225
226 struct CertParam {
227 CertParam(net::CertType certificate_type,
228 const char* original_filename,
229 const char* update_filename)
230 : cert_type(certificate_type),
231 original_file(original_filename),
232 update_file(update_filename) {}
233
234 net::CertType cert_type;
235 const char* original_file;
236 const char* update_file;
237 };
238
226 class ONCCertificateImporterTestWithParam : 239 class ONCCertificateImporterTestWithParam :
227 public ONCCertificateImporterTest, 240 public ONCCertificateImporterTest,
228 public testing::WithParamInterface< 241 public testing::WithParamInterface<CertParam> {
229 std::pair<net::CertType, std::pair<const char*, const char*> > > {
230 protected:
231 net::CertType GetCertTypeParam() {
232 return GetParam().first;
233 }
234
235 std::string GetOriginalFilename() {
236 return GetParam().second.first;
237 }
238
239 std::string GetUpdatedFilename() {
240 return GetParam().second.second;
241 }
242 }; 242 };
243 243
244 TEST_P(ONCCertificateImporterTestWithParam, UpdateCertificate) { 244 TEST_P(ONCCertificateImporterTestWithParam, UpdateCertificate) {
245 // First we import a certificate. 245 // First we import a certificate.
246 { 246 {
247 SCOPED_TRACE("Import original certificate"); 247 SCOPED_TRACE("Import original certificate");
248 std::string guid_original; 248 std::string guid_original;
249 AddCertificateFromFile(GetOriginalFilename(), GetCertTypeParam(), 249 AddCertificateFromFile(GetParam().original_file, GetParam().cert_type,
250 &guid_original); 250 &guid_original);
251 } 251 }
252 252
253 // Now we import the same certificate with a different GUID. The cert should 253 // Now we import the same certificate with a different GUID. The cert should
254 // be retrievable via the new GUID. 254 // be retrievable via the new GUID.
255 { 255 {
256 SCOPED_TRACE("Import updated certificate"); 256 SCOPED_TRACE("Import updated certificate");
257 std::string guid_updated; 257 std::string guid_updated;
258 AddCertificateFromFile(GetUpdatedFilename(), GetCertTypeParam(), 258 AddCertificateFromFile(GetParam().update_file, GetParam().cert_type,
259 &guid_updated); 259 &guid_updated);
260 } 260 }
261 } 261 }
262 262
263 TEST_P(ONCCertificateImporterTestWithParam, ReimportCertificate) { 263 TEST_P(ONCCertificateImporterTestWithParam, ReimportCertificate) {
264 // Verify that reimporting a client certificate works. 264 // Verify that reimporting a client certificate works.
265 for (int i = 0; i < 2; ++i) { 265 for (int i = 0; i < 2; ++i) {
266 SCOPED_TRACE("Import certificate, iteration " + base::IntToString(i)); 266 SCOPED_TRACE("Import certificate, iteration " + base::IntToString(i));
267 267
268 std::string guid_original; 268 std::string guid_original;
269 AddCertificateFromFile(GetOriginalFilename(), GetCertTypeParam(), 269 AddCertificateFromFile(GetParam().original_file, GetParam().cert_type,
270 &guid_original); 270 &guid_original);
271 } 271 }
272 } 272 }
273 273
274 INSTANTIATE_TEST_CASE_P( 274 INSTANTIATE_TEST_CASE_P(
275 ONCCertificateImporterTestWithParam, 275 ONCCertificateImporterTestWithParam,
276 ONCCertificateImporterTestWithParam, 276 ONCCertificateImporterTestWithParam,
277 ::testing::Values( 277 ::testing::Values(
278 std::make_pair(net::USER_CERT, 278 CertParam(net::USER_CERT,
279 std::make_pair("certificate-client.onc", 279 "certificate-client.onc",
280 "certificate-client-update.onc")), 280 "certificate-client-update.onc"),
281 std::make_pair(net::SERVER_CERT, 281 CertParam(net::SERVER_CERT,
282 std::make_pair("certificate-server.onc", 282 "certificate-server.onc",
283 "certificate-server-update.onc")), 283 "certificate-server-update.onc"),
284 std::make_pair( 284 CertParam(net::CA_CERT,
285 net::CA_CERT, 285 "certificate-web-authority.onc",
286 std::make_pair("certificate-web-authority.onc", 286 "certificate-web-authority-update.onc")));
287 "certificate-web-authority-update.onc"))));
288 287
289 } // namespace onc 288 } // namespace onc
290 } // namespace chromeos 289 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_certificate_importer.cc ('k') | chromeos/network/onc/onc_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698