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

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

Issue 2326923002: Introduce CertErrors::ToDebugString(). (Closed)
Patch Set: checkpoint Created 4 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 | « net/cert/internal/cert_errors.cc ('k') | net/data/verify_certificate_chain_unittest/README » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "net/cert/internal/verify_certificate_chain.h" 5 #include "net/cert/internal/verify_certificate_chain.h"
6 6
7 #include "net/cert/internal/signature_policy.h" 7 #include "net/cert/internal/signature_policy.h"
8 #include "net/cert/internal/trust_store.h" 8 #include "net/cert/internal/trust_store.h"
9 #include "net/cert/internal/verify_certificate_chain_typed_unittest.h" 9 #include "net/cert/internal/verify_certificate_chain_typed_unittest.h"
10 10
11 namespace net { 11 namespace net {
12 12
13 namespace { 13 namespace {
14 14
15 // Builds a string representation of all the errors/warnings, that matches the
16 // format used in the test files. The format is described in
17 // net/data/verify_certificate_chain_unittest/README.
18 //
19 // TODO(crbug.com/634443): Use a richer string format that includes the error
20 // parameters and context.
21 std::string MakeErrorsString(const CertErrors& errors) {
22 std::string str;
23 for (const auto& error : errors.errors()) {
24 if (!str.empty())
25 str += "\n";
26 str += error.type;
27 }
28 return str;
29 }
30
31 class VerifyCertificateChainDelegate { 15 class VerifyCertificateChainDelegate {
32 public: 16 public:
33 static void Verify(const ParsedCertificateList& chain, 17 static void Verify(const ParsedCertificateList& chain,
34 const scoped_refptr<TrustAnchor>& trust_anchor, 18 const scoped_refptr<TrustAnchor>& trust_anchor,
35 const der::GeneralizedTime& time, 19 const der::GeneralizedTime& time,
36 bool expected_result, 20 bool expected_result,
37 const std::string& expected_errors) { 21 const std::string& expected_errors) {
38 ASSERT_TRUE(trust_anchor); 22 ASSERT_TRUE(trust_anchor);
39 23
40 SimpleSignaturePolicy signature_policy(1024); 24 SimpleSignaturePolicy signature_policy(1024);
41 25
42 CertErrors errors; 26 CertErrors errors;
43 bool result = VerifyCertificateChain(chain, trust_anchor.get(), 27 bool result = VerifyCertificateChain(chain, trust_anchor.get(),
44 &signature_policy, time, &errors); 28 &signature_policy, time, &errors);
45 EXPECT_EQ(expected_result, result); 29 EXPECT_EQ(expected_result, result);
46 EXPECT_EQ(expected_errors, MakeErrorsString(errors)); 30 EXPECT_EQ(expected_errors, errors.ToDebugString());
47 } 31 }
48 }; 32 };
49 33
50 } // namespace 34 } // namespace
51 35
52 INSTANTIATE_TYPED_TEST_CASE_P(VerifyCertificateChain, 36 INSTANTIATE_TYPED_TEST_CASE_P(VerifyCertificateChain,
53 VerifyCertificateChainSingleRootTest, 37 VerifyCertificateChainSingleRootTest,
54 VerifyCertificateChainDelegate); 38 VerifyCertificateChainDelegate);
55 39
56 } // namespace net 40 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/cert_errors.cc ('k') | net/data/verify_certificate_chain_unittest/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698