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/base64.h" |
8 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "net/cert/pem_tokenizer.h" | 11 #include "net/cert/pem_tokenizer.h" |
12 #include "net/der/parser.h" | 12 #include "net/der/parser.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 namespace der { | 17 namespace der { |
18 | 18 |
19 void PrintTo(const Input& data, ::std::ostream* os) { | 19 void PrintTo(const Input& data, ::std::ostream* os) { |
20 std::string b64; | 20 std::string b64; |
21 base::Base64Encode( | 21 base::Base64Encode( |
22 base::StringPiece(reinterpret_cast<const char*>(data.UnsafeData()), | 22 base::StringPiece(reinterpret_cast<const char*>(data.UnsafeData()), |
23 data.Length()), | 23 data.Length()), |
24 &b64); | 24 &b64); |
25 | 25 |
26 *os << "[" << b64 << "]"; | 26 *os << "[" << b64 << "]"; |
27 } | 27 } |
28 | 28 |
29 bool operator==(const Input& a, const Input& b) { | |
30 return a.Equals(b); | |
31 } | |
32 | |
33 } // namespace der | 29 } // namespace der |
34 | 30 |
35 der::Input SequenceValueFromString(const std::string* s) { | 31 der::Input SequenceValueFromString(const std::string* s) { |
36 der::Parser parser((der::Input(s))); | 32 der::Parser parser((der::Input(s))); |
37 der::Input data; | 33 der::Input data; |
38 if (!parser.ReadTag(der::kSequence, &data)) { | 34 if (!parser.ReadTag(der::kSequence, &data)) { |
39 ADD_FAILURE(); | 35 ADD_FAILURE(); |
40 return der::Input(); | 36 return der::Input(); |
41 } | 37 } |
42 if (parser.HasMore()) { | 38 if (parser.HasMore()) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 if (mapping.value && !mapping.optional) { | 94 if (mapping.value && !mapping.optional) { |
99 return ::testing::AssertionFailure() << "PEM block missing: " | 95 return ::testing::AssertionFailure() << "PEM block missing: " |
100 << mapping.block_name; | 96 << mapping.block_name; |
101 } | 97 } |
102 } | 98 } |
103 | 99 |
104 return ::testing::AssertionSuccess(); | 100 return ::testing::AssertionSuccess(); |
105 } | 101 } |
106 | 102 |
107 } // namespace net | 103 } // namespace net |
OLD | NEW |