Chromium Code Reviews| 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 |