| 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 InputFromString(const std::string* s) { | 31 der::Input InputFromString(const std::string* s) { |
| 36 return der::Input(reinterpret_cast<const uint8_t*>(s->data()), s->size()); | 32 return der::Input(reinterpret_cast<const uint8_t*>(s->data()), s->size()); |
| 37 } | 33 } |
| 38 | 34 |
| 39 der::Input SequenceValueFromString(const std::string* s) { | 35 der::Input SequenceValueFromString(const std::string* s) { |
| 40 der::Parser parser(InputFromString(s)); | 36 der::Parser parser(InputFromString(s)); |
| 41 der::Input data; | 37 der::Input data; |
| 42 if (!parser.ReadTag(der::kSequence, &data)) { | 38 if (!parser.ReadTag(der::kSequence, &data)) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 if (mapping.value && !mapping.optional) { | 98 if (mapping.value && !mapping.optional) { |
| 103 return ::testing::AssertionFailure() << "PEM block missing: " | 99 return ::testing::AssertionFailure() << "PEM block missing: " |
| 104 << mapping.block_name; | 100 << mapping.block_name; |
| 105 } | 101 } |
| 106 } | 102 } |
| 107 | 103 |
| 108 return ::testing::AssertionSuccess(); | 104 return ::testing::AssertionSuccess(); |
| 109 } | 105 } |
| 110 | 106 |
| 111 } // namespace net | 107 } // namespace net |
| OLD | NEW |