| 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 <ostream> | 8 #include <ostream> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // Creates a der::Input from an std::string. The lifetimes are a bit subtle | 26 // Creates a der::Input from an std::string. The lifetimes are a bit subtle |
| 27 // when using this function: | 27 // when using this function: |
| 28 // | 28 // |
| 29 // The returned der::Input() is only valid so long as the input string is alive | 29 // The returned der::Input() is only valid so long as the input string is alive |
| 30 // and is not mutated. | 30 // and is not mutated. |
| 31 // | 31 // |
| 32 // Note that the input parameter has been made a pointer to prevent callers | 32 // Note that the input parameter has been made a pointer to prevent callers |
| 33 // from accidentally passing an r-value. | 33 // from accidentally passing an r-value. |
| 34 der::Input InputFromString(const std::string* s); | 34 der::Input InputFromString(const std::string* s); |
| 35 | 35 |
| 36 // Parses |s| as a DER SEQUENCE TLV and returns a der::Input corresponding to |
| 37 // the value portion. On error returns an empty der::Input and adds a gtest |
| 38 // failure. |
| 39 // |
| 40 // The returned der::Input() is only valid so long as the input string is alive |
| 41 // and is not mutated. |
| 42 der::Input SequenceValueFromString(const std::string* s); |
| 43 |
| 36 // Helper structure that maps a PEM block header (for instance "CERTIFICATE") to | 44 // Helper structure that maps a PEM block header (for instance "CERTIFICATE") to |
| 37 // the destination where the value for that block should be written. | 45 // the destination where the value for that block should be written. |
| 38 struct PemBlockMapping { | 46 struct PemBlockMapping { |
| 39 // The name of the PEM header. Example "CERTIFICATE". | 47 // The name of the PEM header. Example "CERTIFICATE". |
| 40 const char* block_name; | 48 const char* block_name; |
| 41 | 49 |
| 42 // The destination where the read value should be written to. | 50 // The destination where the read value should be written to. |
| 43 std::string* value; | 51 std::string* value; |
| 44 | 52 |
| 45 // True to indicate that the block is not required to be present. If the | 53 // True to indicate that the block is not required to be present. If the |
| (...skipping 26 matching lines...) Expand all Loading... |
| 72 template <size_t N> | 80 template <size_t N> |
| 73 ::testing::AssertionResult ReadTestDataFromPemFile( | 81 ::testing::AssertionResult ReadTestDataFromPemFile( |
| 74 const std::string& file_path_ascii, | 82 const std::string& file_path_ascii, |
| 75 const PemBlockMapping(&mappings)[N]) { | 83 const PemBlockMapping(&mappings)[N]) { |
| 76 return ReadTestDataFromPemFile(file_path_ascii, mappings, N); | 84 return ReadTestDataFromPemFile(file_path_ascii, mappings, N); |
| 77 } | 85 } |
| 78 | 86 |
| 79 } // namespace net | 87 } // namespace net |
| 80 | 88 |
| 81 #endif // NET_CERT_INTERNAL_TEST_HELPERS_H_ | 89 #endif // NET_CERT_INTERNAL_TEST_HELPERS_H_ |
| OLD | NEW |