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 <set> | |
9 | |
10 #include "base/strings/string_split.h" | |
mattm
2017/05/25 22:11:16
put in the .cc
eroman
2017/05/25 22:42:58
Done.
| |
8 #include "net/cert/internal/test_helpers.h" | 11 #include "net/cert/internal/test_helpers.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
10 | 13 |
14 namespace net { | |
15 | |
16 // Describes additional inputs to verification in the PKITS tests | |
17 // (which are referred to as "settings" in that document). | |
18 struct PkitsTestSettings { | |
19 // Default construction results in the "default settings". | |
20 PkitsTestSettings(); | |
21 ~PkitsTestSettings(); | |
22 | |
23 // Sets |initial_policy_set| to the specified policies. The | |
24 // policies are described as comma-separated symbolic strings like | |
25 // "anyPolicy" and "NIST-test-policy-1". | |
26 void SetInitialPolicySet(const char* const policy_names); | |
27 | |
28 // A set of policy OIDs to use for "initial-policy-set". | |
29 std::set<der::Input> initial_policy_set; | |
30 | |
31 // The value of "initial-explicit-policy". | |
32 bool initial_explicit_policy = false; | |
33 | |
34 // The value of "initial-policy-mapping-inhibit". | |
35 bool initial_policy_mapping_inhibit = false; | |
36 | |
37 // The valueo f "initial-inhibit-any-policy". | |
mattm
2017/05/25 22:11:16
value of
eroman
2017/05/25 22:42:58
Done.
| |
38 bool initial_inhibit_any_policy = false; | |
39 }; | |
40 | |
11 // Parameterized test class for PKITS tests. | 41 // Parameterized test class for PKITS tests. |
12 // The instantiating code should define a PkitsTestDelegate with an appropriate | 42 // The instantiating code should define a PkitsTestDelegate with an appropriate |
13 // static Verify method, and then INSTANTIATE_TYPED_TEST_CASE_P for each | 43 // static Verify method, and then INSTANTIATE_TYPED_TEST_CASE_P for each |
14 // testcase (each TYPED_TEST_CASE_P in pkits_testcases-inl.h). | 44 // testcase (each TYPED_TEST_CASE_P in pkits_testcases-inl.h). |
15 template <typename PkitsTestDelegate> | 45 template <typename PkitsTestDelegate> |
16 class PkitsTest : public ::testing::Test { | 46 class PkitsTest : public ::testing::Test { |
17 public: | 47 public: |
18 template <size_t num_certs, size_t num_crls> | 48 template <size_t num_certs, size_t num_crls> |
19 bool Verify(const char* const (&cert_names)[num_certs], | 49 bool Verify(const char* const (&cert_names)[num_certs], |
20 const char* const (&crl_names)[num_crls]) { | 50 const char* const (&crl_names)[num_crls], |
51 const PkitsTestSettings& settings) { | |
21 std::vector<std::string> cert_ders; | 52 std::vector<std::string> cert_ders; |
22 for (const std::string& s : cert_names) | 53 for (const std::string& s : cert_names) |
23 cert_ders.push_back(net::ReadTestFileToString( | 54 cert_ders.push_back(net::ReadTestFileToString( |
24 "net/third_party/nist-pkits/certs/" + s + ".crt")); | 55 "net/third_party/nist-pkits/certs/" + s + ".crt")); |
25 std::vector<std::string> crl_ders; | 56 std::vector<std::string> crl_ders; |
26 for (const std::string& s : crl_names) | 57 for (const std::string& s : crl_names) |
27 crl_ders.push_back(net::ReadTestFileToString( | 58 crl_ders.push_back(net::ReadTestFileToString( |
28 "net/third_party/nist-pkits/crls/" + s + ".crl")); | 59 "net/third_party/nist-pkits/crls/" + s + ".crl")); |
29 return PkitsTestDelegate::Verify(cert_ders, crl_ders); | 60 return PkitsTestDelegate::Verify(cert_ders, crl_ders, settings); |
30 } | 61 } |
31 }; | 62 }; |
32 | 63 |
33 // Inline the generated test code: | 64 // Inline the generated test code: |
34 #include "net/third_party/nist-pkits/pkits_testcases-inl.h" | 65 #include "net/third_party/nist-pkits/pkits_testcases-inl.h" |
35 | 66 |
67 } // namespace net | |
68 | |
36 #endif // NET_CERT_INTERNAL_NIST_PKITS_UNITTEST_H_ | 69 #endif // NET_CERT_INTERNAL_NIST_PKITS_UNITTEST_H_ |
OLD | NEW |