| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_TEST_HELPERS_H_ | 5 #ifndef NET_CERT_INTERNAL_TEST_HELPERS_H_ |
| 6 #define NET_CERT_INTERNAL_TEST_HELPERS_H_ | 6 #define NET_CERT_INTERNAL_TEST_HELPERS_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <ostream> | 10 #include <ostream> |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // This is the same as the variant above, however it uses template magic so an | 69 // This is the same as the variant above, however it uses template magic so an |
| 70 // mappings array can be passed in directly (and the correct length is | 70 // mappings array can be passed in directly (and the correct length is |
| 71 // inferred). | 71 // inferred). |
| 72 template <size_t N> | 72 template <size_t N> |
| 73 ::testing::AssertionResult ReadTestDataFromPemFile( | 73 ::testing::AssertionResult ReadTestDataFromPemFile( |
| 74 const std::string& file_path_ascii, | 74 const std::string& file_path_ascii, |
| 75 const PemBlockMapping(&mappings)[N]) { | 75 const PemBlockMapping(&mappings)[N]) { |
| 76 return ReadTestDataFromPemFile(file_path_ascii, mappings, N); | 76 return ReadTestDataFromPemFile(file_path_ascii, mappings, N); |
| 77 } | 77 } |
| 78 | 78 |
| 79 // Reads a test case from |file_path_ascii| (which is relative to //src). Test | 79 // Test cases are comprised of all the parameters to certificate |
| 80 // cases are comprised of a certificate chain, trust anchor, a timestamp to | 80 // verification, as well as the expected outputs. |
| 81 // validate at, and the expected result of verification. | 81 struct VerifyCertChainTest { |
| 82 VerifyCertChainTest(); |
| 83 ~VerifyCertChainTest(); |
| 84 |
| 85 // The chain of certificates (with the zero-th being the target). |
| 86 ParsedCertificateList chain; |
| 87 |
| 88 // The trust anchor to use when verifying the chain. |
| 89 scoped_refptr<TrustAnchor> trust_anchor; |
| 90 |
| 91 // The time to use when verifying the chain. |
| 92 der::GeneralizedTime time; |
| 93 |
| 94 // The expected result from verification. |
| 95 bool expected_result = false; |
| 96 |
| 97 // The expected errors from verification (as a string). |
| 98 std::string expected_errors; |
| 99 }; |
| 100 |
| 101 // Reads a test case from |file_path_ascii| (which is relative to //src). |
| 82 // Generally |file_path_ascii| will start with: | 102 // Generally |file_path_ascii| will start with: |
| 83 // net/data/verify_certificate_chain_unittest/ | 103 // net/data/verify_certificate_chain_unittest/ |
| 84 void ReadVerifyCertChainTestFromFile(const std::string& file_path_ascii, | 104 void ReadVerifyCertChainTestFromFile(const std::string& file_path_ascii, |
| 85 ParsedCertificateList* chain, | 105 VerifyCertChainTest* test); |
| 86 scoped_refptr<TrustAnchor>* trust_anchor, | |
| 87 der::GeneralizedTime* time, | |
| 88 bool* verify_result, | |
| 89 std::string* expected_errors); | |
| 90 | 106 |
| 91 // Reads a data file relative to the src root directory. | 107 // Reads a data file relative to the src root directory. |
| 92 std::string ReadTestFileToString(const std::string& file_path_ascii); | 108 std::string ReadTestFileToString(const std::string& file_path_ascii); |
| 93 | 109 |
| 94 } // namespace net | 110 } // namespace net |
| 95 | 111 |
| 96 #endif // NET_CERT_INTERNAL_TEST_HELPERS_H_ | 112 #endif // NET_CERT_INTERNAL_TEST_HELPERS_H_ |
| OLD | NEW |