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

Side by Side Diff: net/cert/internal/cert_issuer_source_nss_unittest.cc

Issue 2832703002: Allow the TrustStore interface to return matching intermediates, and identify distrusted certs. (Closed)
Patch Set: address comments 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/cert/internal/cert_issuer_source_nss.h"
6
7 #include <cert.h>
8 #include <certdb.h>
9
10 #include "base/strings/string_number_conversions.h"
11 #include "crypto/scoped_test_nss_db.h"
12 #include "net/cert/internal/cert_issuer_source_sync_unittest.h"
13 #include "net/cert/scoped_nss_types.h"
14 #include "net/cert/x509_certificate.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 namespace net {
18
19 namespace {
20
21 class CertIssuerSourceNSSTestDelegate {
22 public:
23 void AddCert(scoped_refptr<ParsedCertificate> cert) {
24 ASSERT_TRUE(test_nssdb_.is_open());
25 std::string nickname = GetUniqueNickname();
26 ScopedCERTCertificate nss_cert(
27 X509Certificate::CreateOSCertHandleFromBytesWithNickname(
28 cert->der_cert().AsStringPiece().data(), cert->der_cert().Length(),
29 nickname.c_str()));
30 ASSERT_TRUE(nss_cert);
31 SECStatus srv =
32 PK11_ImportCert(test_nssdb_.slot(), nss_cert.get(), CK_INVALID_HANDLE,
33 nickname.c_str(), PR_FALSE /* includeTrust (unused) */);
34 ASSERT_EQ(SECSuccess, srv);
35 }
36
37 CertIssuerSource& source() { return cert_issuer_source_nss_; }
38
39 protected:
40 std::string GetUniqueNickname() {
41 return "cert_issuer_source_nss_unittest" +
42 base::UintToString(nickname_counter_++);
43 }
44
45 crypto::ScopedTestNSSDB test_nssdb_;
46 CertIssuerSourceNSS cert_issuer_source_nss_;
47 unsigned int nickname_counter_ = 0;
48 };
49
50 INSTANTIATE_TYPED_TEST_CASE_P(CertIssuerSourceNSSTest,
51 CertIssuerSourceSyncTest,
52 CertIssuerSourceNSSTestDelegate);
53
54 // NSS doesn't normalize UTF8String values, so use the not-normalized version of
55 // those tests.
56 INSTANTIATE_TYPED_TEST_CASE_P(CertIssuerSourceNSSNotNormalizedTest,
57 CertIssuerSourceSyncNotNormalizedTest,
58 CertIssuerSourceNSSTestDelegate);
59
60 } // namespace
61
62 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698