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

Unified Diff: net/test/cert_test_util.h

Issue 2670643008: Move CertVerifyProcMac unit-tests to their own file. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « net/cert/cert_verify_proc_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/test/cert_test_util.h
diff --git a/net/test/cert_test_util.h b/net/test/cert_test_util.h
index f948bd8b06c8145da9f3aa06aabcbde6eed77c74..434bd43f48d1d42e70f5565c8aef4a575f66c328 100644
--- a/net/test/cert_test_util.h
+++ b/net/test/cert_test_util.h
@@ -10,6 +10,8 @@
#include "base/memory/ref_counted.h"
#include "net/cert/x509_cert_types.h"
#include "net/cert/x509_certificate.h"
+#include "net/test/test_data_directory.h"
+#include "testing/gtest/include/gtest/gtest.h"
#if defined(USE_NSS_CERTS)
// From <pk11pub.h>
@@ -48,6 +50,22 @@ CertificateList CreateCertificateListFromFile(const base::FilePath& certs_dir,
const std::string& cert_file,
int format);
+// Template helper to load a series of certificate files into a CertificateList.
+// Like CreateCertificateListFromFile, except it can load a
+// series of individual certificates (to make the tests clearer).
+template <size_t N>
+void LoadCertificateFiles(const char* const (&cert_files)[N],
+ CertificateList* certs) {
Ryan Sleevi 2017/02/02 22:20:12 A thought: It might be worth refactoring this a li
eroman 2017/02/02 23:27:17 PTAL, I have removed the template parameter all-to
+ certs->clear();
+ for (size_t i = 0; i < N; ++i) {
+ SCOPED_TRACE(cert_files[i]);
+ scoped_refptr<X509Certificate> cert = CreateCertificateChainFromFile(
+ GetTestCertsDirectory(), cert_files[i], X509Certificate::FORMAT_AUTO);
+ ASSERT_TRUE(cert);
+ certs->push_back(cert);
+ }
+}
+
// Imports all of the certificates in |cert_file|, a file in |certs_dir|, into
// a new X509Certificate. The first certificate in the chain will be used for
// the returned cert, with any additional certificates configured as
« no previous file with comments | « net/cert/cert_verify_proc_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698