Chromium Code Reviews| Index: net/cert/internal/verify_name_match_unittest.cc |
| diff --git a/net/cert/internal/verify_name_match_unittest.cc b/net/cert/internal/verify_name_match_unittest.cc |
| index 273e2e899165989c90307f387d6cf543827744ee..7321f1612715b37b2ff7ff92fa78c90b9c1eab10 100644 |
| --- a/net/cert/internal/verify_name_match_unittest.cc |
| +++ b/net/cert/internal/verify_name_match_unittest.cc |
| @@ -4,13 +4,9 @@ |
| #include "net/cert/internal/verify_name_match.h" |
| -#include "base/base_paths.h" |
| -#include "base/files/file_path.h" |
| -#include "base/files/file_util.h" |
| -#include "base/path_service.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_util.h" |
| -#include "net/cert/pem_tokenizer.h" |
| +#include "net/cert/internal/test_helpers.h" |
| #include "net/der/input.h" |
| #include "net/der/parser.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -19,8 +15,7 @@ namespace net { |
| namespace { |
| der::Input SequenceValueFromString(const std::string& s) { |
|
mattm
2015/08/12 21:30:26
Do you want to update this to also take a pointer
eroman
2015/08/12 21:51:30
Good point!
I will make that change in this CL.
eroman
2015/08/12 22:51:00
Done.
|
| - der::Parser parser( |
| - der::Input(reinterpret_cast<const uint8_t*>(s.data()), s.size())); |
| + der::Parser parser(InputFromString(&s)); |
| der::Input data; |
| if (!parser.ReadTag(der::kSequence, &data)) { |
| ADD_FAILURE(); |
| @@ -43,29 +38,14 @@ der::Input SequenceValueFromString(const std::string& s) { |
| const std::string& value_type, |
| const std::string& suffix, |
| std::string* result) { |
| - base::FilePath src_root; |
| - PathService::Get(base::DIR_SOURCE_ROOT, &src_root); |
| - std::string filename = prefix + "-" + value_type + "-" + suffix + ".pem"; |
| - base::FilePath filepath = |
| - src_root.Append(FILE_PATH_LITERAL( |
| - "net/data/verify_name_match_unittest/names")) |
| - .AppendASCII(filename); |
| - std::string file_data; |
| - if (!base::ReadFileToString(filepath, &file_data)) { |
| - return ::testing::AssertionFailure() |
| - << "ReadFileToString returned false on " << filename; |
| - } |
| + std::string path = "net/data/verify_name_match_unittest/names/" + prefix + |
| + "-" + value_type + "-" + suffix + ".pem"; |
| - std::vector<std::string> pem_headers; |
| - pem_headers.push_back("NAME"); |
| - PEMTokenizer pem_tokenizer(file_data, pem_headers); |
| - if (!pem_tokenizer.GetNext()) { |
| - return ::testing::AssertionFailure() << "PEM.GetNext returned false on " |
| - << filename; |
| - } |
| + const PemBlockMapping mappings[] = { |
| + {"NAME", result}, |
| + }; |
| - result->assign(pem_tokenizer.data()); |
| - return ::testing::AssertionSuccess(); |
| + return ReadTestDataFromPemFile(path, mappings); |
| } |
| bool TypesAreComparable(const std::string& type_1, const std::string& type_2) { |