| 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 ASSERT_TRUE(trust_anchor); | 22 ASSERT_TRUE(trust_anchor); |
| 22 | 23 |
| 23 SimpleSignaturePolicy signature_policy(1024); | 24 SimpleSignaturePolicy signature_policy(1024); |
| 24 | 25 |
| 26 CertErrors errors; |
| 25 bool result = VerifyCertificateChain(chain, trust_anchor.get(), | 27 bool result = VerifyCertificateChain(chain, trust_anchor.get(), |
| 26 &signature_policy, time); | 28 &signature_policy, time, &errors); |
| 27 | 29 |
| 28 ASSERT_EQ(expected_result, result); | 30 // Check that the error types match (parameters and context is not |
| 31 // considered for simplicity). |
| 32 std::string actual_errors; |
| 33 for (const auto& error : errors.errors()) { |
| 34 if (!actual_errors.empty()) |
| 35 actual_errors += "\n"; |
| 36 actual_errors += error.type; |
| 37 } |
| 38 EXPECT_EQ(expected_errors, actual_errors); |
| 39 |
| 40 EXPECT_EQ(expected_result, result); |
| 29 } | 41 } |
| 30 }; | 42 }; |
| 31 | 43 |
| 32 } // namespace | 44 } // namespace |
| 33 | 45 |
| 34 INSTANTIATE_TYPED_TEST_CASE_P(VerifyCertificateChain, | 46 INSTANTIATE_TYPED_TEST_CASE_P(VerifyCertificateChain, |
| 35 VerifyCertificateChainSingleRootTest, | 47 VerifyCertificateChainSingleRootTest, |
| 36 VerifyCertificateChainDelegate); | 48 VerifyCertificateChainDelegate); |
| 37 | 49 |
| 38 } // namespace net | 50 } // namespace net |
| OLD | NEW |