| 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 #ifndef NET_CERT_INTERNAL_NIST_PKITS_UNITTEST_H | 5 #ifndef NET_CERT_INTERNAL_NIST_PKITS_UNITTEST_H_ |
| 6 #define NET_CERT_INTERNAL_NIST_PKITS_UNITTEST_H | 6 #define NET_CERT_INTERNAL_NIST_PKITS_UNITTEST_H_ |
| 7 | 7 |
| 8 #include "net/cert/internal/test_helpers.h" | 8 #include "net/cert/internal/test_helpers.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 // Parameterized test class for PKITS tests. | 11 // Parameterized test class for PKITS tests. |
| 12 // The instantiating code should define a PkitsTestDelegate with an appropriate | 12 // The instantiating code should define a PkitsTestDelegate with an appropriate |
| 13 // static Verify method, and then INSTANTIATE_TYPED_TEST_CASE_P for each | 13 // static Verify method, and then INSTANTIATE_TYPED_TEST_CASE_P for each |
| 14 // testcase (each TYPED_TEST_CASE_P in pkits_testcases-inl.h). | 14 // testcase (each TYPED_TEST_CASE_P in pkits_testcases-inl.h). |
| 15 template <typename PkitsTestDelegate> | 15 template <typename PkitsTestDelegate> |
| 16 class PkitsTest : public ::testing::Test { | 16 class PkitsTest : public ::testing::Test { |
| 17 public: | 17 public: |
| 18 template <size_t num_certs, size_t num_crls> | 18 template <size_t num_certs, size_t num_crls> |
| 19 bool Verify(const char* const (&cert_names)[num_certs], | 19 bool Verify(const char* const (&cert_names)[num_certs], |
| 20 const char* const (&crl_names)[num_crls]) { | 20 const char* const (&crl_names)[num_crls]) { |
| 21 std::vector<std::string> cert_ders; | 21 std::vector<std::string> cert_ders; |
| 22 for (const std::string& s : cert_names) | 22 for (const std::string& s : cert_names) |
| 23 cert_ders.push_back(net::ReadTestFileToString( | 23 cert_ders.push_back(net::ReadTestFileToString( |
| 24 "net/third_party/nist-pkits/certs/" + s + ".crt")); | 24 "net/third_party/nist-pkits/certs/" + s + ".crt")); |
| 25 std::vector<std::string> crl_ders; | 25 std::vector<std::string> crl_ders; |
| 26 for (const std::string& s : crl_names) | 26 for (const std::string& s : crl_names) |
| 27 crl_ders.push_back(net::ReadTestFileToString( | 27 crl_ders.push_back(net::ReadTestFileToString( |
| 28 "net/third_party/nist-pkits/crls/" + s + ".crl")); | 28 "net/third_party/nist-pkits/crls/" + s + ".crl")); |
| 29 return PkitsTestDelegate::Verify(cert_ders, crl_ders); | 29 return PkitsTestDelegate::Verify(cert_ders, crl_ders); |
| 30 } | 30 } |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 // Inline the generated test code: | 33 // Inline the generated test code: |
| 34 #include "net/third_party/nist-pkits/pkits_testcases-inl.h" | 34 #include "net/third_party/nist-pkits/pkits_testcases-inl.h" |
| 35 | 35 |
| 36 #endif // NET_CERT_INTERNAL_NIST_PKITS_UNITTEST_H | 36 #endif // NET_CERT_INTERNAL_NIST_PKITS_UNITTEST_H_ |
| OLD | NEW |