OLD | NEW |
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 class VerifyCertificateChainDelegate { | 15 class VerifyCertificateChainDelegate { |
16 public: | 16 public: |
17 static void Verify(const ParsedCertificateList& chain, | 17 static void Verify(const ParsedCertificateList& chain, |
18 const scoped_refptr<TrustAnchor>& trust_anchor, | 18 const scoped_refptr<TrustAnchor>& trust_anchor, |
19 const der::GeneralizedTime& time, | 19 const der::GeneralizedTime& time, |
20 bool expected_result, | 20 bool expected_result, |
21 const std::string& expected_errors, | 21 const std::string& expected_errors, |
22 const std::string& test_file_path) { | 22 const std::string& test_file_path) { |
23 ASSERT_TRUE(trust_anchor); | 23 ASSERT_TRUE(trust_anchor); |
24 | 24 |
25 SimpleSignaturePolicy signature_policy(1024); | 25 SimpleSignaturePolicy signature_policy(1024); |
26 | 26 |
27 CertErrors errors; | 27 CertPathErrors errors; |
28 bool result = VerifyCertificateChain(chain, trust_anchor.get(), | 28 bool result = VerifyCertificateChain(chain, trust_anchor.get(), |
29 &signature_policy, time, &errors); | 29 &signature_policy, time, &errors); |
30 EXPECT_EQ(expected_result, result); | 30 EXPECT_EQ(expected_result, result); |
31 EXPECT_EQ(expected_errors, errors.ToDebugString()) << "Test file: " | 31 EXPECT_EQ(expected_errors, errors.ToDebugString(chain)) |
32 << test_file_path; | 32 << "Test file: " << test_file_path; |
33 if (!result) | 33 EXPECT_EQ(result, !errors.ContainsHighSeverityErrors()); |
34 EXPECT_FALSE(errors.empty()); | |
35 } | 34 } |
36 }; | 35 }; |
37 | 36 |
38 } // namespace | 37 } // namespace |
39 | 38 |
40 INSTANTIATE_TYPED_TEST_CASE_P(VerifyCertificateChain, | 39 INSTANTIATE_TYPED_TEST_CASE_P(VerifyCertificateChain, |
41 VerifyCertificateChainSingleRootTest, | 40 VerifyCertificateChainSingleRootTest, |
42 VerifyCertificateChainDelegate); | 41 VerifyCertificateChainDelegate); |
43 | 42 |
44 } // namespace net | 43 } // namespace net |
OLD | NEW |