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 #include "net/cert/internal/test_helpers.h" | 5 #include "net/cert/internal/test_helpers.h" |
6 | 6 |
| 7 #include "base/base64.h" |
7 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
8 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
10 #include "net/cert/pem_tokenizer.h" | 11 #include "net/cert/pem_tokenizer.h" |
11 | 12 |
12 namespace net { | 13 namespace net { |
13 | 14 |
| 15 namespace der { |
| 16 |
| 17 void PrintTo(const Input& data, ::std::ostream* os) { |
| 18 std::string b64; |
| 19 base::Base64Encode( |
| 20 base::StringPiece(reinterpret_cast<const char*>(data.UnsafeData()), |
| 21 data.Length()), |
| 22 &b64); |
| 23 |
| 24 *os << "[" << b64 << "]"; |
| 25 } |
| 26 |
| 27 bool operator==(const Input& a, const Input& b) { |
| 28 return a.Equals(b); |
| 29 } |
| 30 |
| 31 } // namespace der |
| 32 |
14 der::Input InputFromString(const std::string* s) { | 33 der::Input InputFromString(const std::string* s) { |
15 return der::Input(reinterpret_cast<const uint8_t*>(s->data()), s->size()); | 34 return der::Input(reinterpret_cast<const uint8_t*>(s->data()), s->size()); |
16 } | 35 } |
17 | 36 |
18 ::testing::AssertionResult ReadTestDataFromPemFile( | 37 ::testing::AssertionResult ReadTestDataFromPemFile( |
19 const std::string& file_path_ascii, | 38 const std::string& file_path_ascii, |
20 const PemBlockMapping* mappings, | 39 const PemBlockMapping* mappings, |
21 size_t mappings_length) { | 40 size_t mappings_length) { |
22 // Compute the full path, relative to the src/ directory. | 41 // Compute the full path, relative to the src/ directory. |
23 base::FilePath src_root; | 42 base::FilePath src_root; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 if (mapping.value) { | 86 if (mapping.value) { |
68 return ::testing::AssertionFailure() << "PEM block missing: " | 87 return ::testing::AssertionFailure() << "PEM block missing: " |
69 << mapping.block_name; | 88 << mapping.block_name; |
70 } | 89 } |
71 } | 90 } |
72 | 91 |
73 return ::testing::AssertionSuccess(); | 92 return ::testing::AssertionSuccess(); |
74 } | 93 } |
75 | 94 |
76 } // namespace net | 95 } // namespace net |
OLD | NEW |