OLD | NEW |
(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/path_builder.h" |
| 6 |
| 7 #include "net/cert/internal/cert_issuer_source_static.h" |
| 8 #include "net/cert/internal/signature_policy.h" |
| 9 #include "net/cert/internal/trust_store.h" |
| 10 #include "net/cert/internal/verify_certificate_chain_typed_unittest.h" |
| 11 |
| 12 namespace net { |
| 13 |
| 14 namespace { |
| 15 |
| 16 class PathBuilderDelegate { |
| 17 public: |
| 18 static void Verify(const ParsedCertificateList& chain, |
| 19 const ParsedCertificateList& roots, |
| 20 const der::GeneralizedTime& time, |
| 21 bool expected_result) { |
| 22 SimpleSignaturePolicy signature_policy(1024); |
| 23 ASSERT_FALSE(chain.empty()); |
| 24 |
| 25 TrustStore trust_store; |
| 26 for (const auto& root : roots) |
| 27 trust_store.AddTrustedCertificate(root); |
| 28 |
| 29 CertIssuerSourceStatic intermediate_cert_issuer_source; |
| 30 for (size_t i = 1; i < chain.size(); ++i) |
| 31 intermediate_cert_issuer_source.AddCert(chain[i]); |
| 32 |
| 33 CertPathBuilder::Result result; |
| 34 // First cert in the |chain| is the target. |
| 35 CertPathBuilder path_builder(chain.front(), &trust_store, &signature_policy, |
| 36 time, &result); |
| 37 path_builder.AddCertIssuerSource(&intermediate_cert_issuer_source); |
| 38 |
| 39 CompletionStatus rv = path_builder.Run(base::Closure()); |
| 40 EXPECT_EQ(CompletionStatus::SYNC, rv); |
| 41 |
| 42 EXPECT_EQ(expected_result, result.is_success()); |
| 43 } |
| 44 }; |
| 45 |
| 46 } // namespace |
| 47 |
| 48 INSTANTIATE_TYPED_TEST_CASE_P(PathBuilder, |
| 49 VerifyCertificateChainSingleRootTest, |
| 50 PathBuilderDelegate); |
| 51 |
| 52 INSTANTIATE_TYPED_TEST_CASE_P(PathBuilder, |
| 53 VerifyCertificateChainNonSingleRootTest, |
| 54 PathBuilderDelegate); |
| 55 |
| 56 } // namespace net |
OLD | NEW |