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

Unified Diff: net/cert/internal/path_builder_verify_certificate_chain_unittest.cc

Issue 1923433002: Certificate path builder for new certificate verification library (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: net/cert/internal/path_builder_verify_certificate_chain_unittest.cc
diff --git a/net/cert/internal/path_builder_verify_certificate_chain_unittest.cc b/net/cert/internal/path_builder_verify_certificate_chain_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8308330c1a51cc21fa720d78efca1ceba22b8263
--- /dev/null
+++ b/net/cert/internal/path_builder_verify_certificate_chain_unittest.cc
@@ -0,0 +1,59 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/cert/internal/path_builder.h"
+
+#include "net/cert/internal/cert_issuer_source_static.h"
+#include "net/cert/internal/signature_policy.h"
+#include "net/cert/internal/trust_store.h"
+#include "net/cert/internal/verify_certificate_chain_typed_unittest.h"
+
+namespace net {
+
+namespace {
+
+class PathBuilderDelegate {
+ public:
+ static void Verify(const std::vector<scoped_refptr<ParsedCertificate>>& chain,
+ const std::vector<scoped_refptr<ParsedCertificate>>& roots,
+ const der::GeneralizedTime& time,
+ bool expected_result) {
+ SimpleSignaturePolicy signature_policy(1024);
+ ASSERT_FALSE(chain.empty());
+
+ TrustStore trust_store;
+ for (const auto& root : roots)
+ trust_store.AddTrustedCertificate(root);
+
+ CertIssuerSourceStatic intermediate_cert_issuer_source;
+ for (size_t i = 1; i < chain.size(); ++i)
+ intermediate_cert_issuer_source.AddCert(chain[i]);
+
+ CertPathBuilder::Result result;
+ // First cert in the |chain| is the target.
+ CertPathBuilder path_builder(chain.front(), &trust_store, &signature_policy,
+ time, &result);
+ path_builder.AddCertIssuerSource(&intermediate_cert_issuer_source);
+
+ CompletionStatus rv = path_builder.Run(base::Closure());
+ EXPECT_EQ(CompletionStatus::SYNC, rv);
+
+ if (expected_result)
+ EXPECT_EQ(OK, result.result());
+ else
+ EXPECT_NE(OK, result.result());
+ }
+};
+
+} // namespace
+
+INSTANTIATE_TYPED_TEST_CASE_P(PathBuilder,
+ VerifyCertificateChainSingleRootTest,
+ PathBuilderDelegate);
+
+INSTANTIATE_TYPED_TEST_CASE_P(PathBuilder,
+ VerifyCertificateChainNonSingleRootTest,
+ PathBuilderDelegate);
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698