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