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

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

Issue 2282183004: Add error information to VerifyCertificateChain(). (Closed)
Patch Set: fix typo in README 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
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
15 class VerifyCertificateChainDelegate { 31 class VerifyCertificateChainDelegate {
16 public: 32 public:
17 static void Verify(const ParsedCertificateList& chain, 33 static void Verify(const ParsedCertificateList& chain,
18 const scoped_refptr<TrustAnchor>& trust_anchor, 34 const scoped_refptr<TrustAnchor>& trust_anchor,
19 const der::GeneralizedTime& time, 35 const der::GeneralizedTime& time,
20 bool expected_result) { 36 bool expected_result,
37 const std::string& expected_errors) {
21 ASSERT_TRUE(trust_anchor); 38 ASSERT_TRUE(trust_anchor);
22 39
23 SimpleSignaturePolicy signature_policy(1024); 40 SimpleSignaturePolicy signature_policy(1024);
24 41
42 CertErrors errors;
25 bool result = VerifyCertificateChain(chain, trust_anchor.get(), 43 bool result = VerifyCertificateChain(chain, trust_anchor.get(),
26 &signature_policy, time); 44 &signature_policy, time, &errors);
27 45 EXPECT_EQ(expected_result, result);
28 ASSERT_EQ(expected_result, result); 46 EXPECT_EQ(expected_errors, MakeErrorsString(errors));
29 } 47 }
30 }; 48 };
31 49
32 } // namespace 50 } // namespace
33 51
34 INSTANTIATE_TYPED_TEST_CASE_P(VerifyCertificateChain, 52 INSTANTIATE_TYPED_TEST_CASE_P(VerifyCertificateChain,
35 VerifyCertificateChainSingleRootTest, 53 VerifyCertificateChainSingleRootTest,
36 VerifyCertificateChainDelegate); 54 VerifyCertificateChainDelegate);
37 55
38 } // namespace net 56 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/verify_certificate_chain_typed_unittest.h ('k') | net/data/verify_certificate_chain_unittest/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698