OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "extensions/common/cast/cast_cert_validator_test_helpers.h" | 5 #include "components/cast_certificate/cast_cert_validator_test_helpers.h" |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "extensions/common/extension_paths.h" | |
10 #include "net/cert/pem_tokenizer.h" | 9 #include "net/cert/pem_tokenizer.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
12 | 11 |
13 namespace cast_test_helpers { | 12 namespace cast_test_helpers { |
14 | 13 |
15 namespace { | 14 namespace { |
16 | 15 |
17 // Reads a file from the extensions test data directory | 16 // Reads a file from the test data directory |
18 // (//src/extensions/test/data/) | 17 // (//src/components/test/data/cast_certificate) |
19 std::string ReadTestFileToString(const base::StringPiece& file_name) { | 18 std::string ReadTestFileToString(const base::StringPiece& file_name) { |
20 base::FilePath filepath; | 19 base::FilePath filepath; |
21 if (!PathService::Get(extensions::DIR_TEST_DATA, &filepath)) { | 20 PathService::Get(base::DIR_SOURCE_ROOT, &filepath); |
22 ADD_FAILURE() << "Couldn't retrieve test data root"; | 21 filepath = filepath.Append(FILE_PATH_LITERAL("components")); |
23 return std::string(); | 22 filepath = filepath.Append(FILE_PATH_LITERAL("test")); |
24 } | 23 filepath = filepath.Append(FILE_PATH_LITERAL("data")); |
| 24 filepath = filepath.Append(FILE_PATH_LITERAL("cast_certificate")); |
25 filepath = filepath.AppendASCII(file_name); | 25 filepath = filepath.AppendASCII(file_name); |
26 | 26 |
27 // Read the full contents of the file. | 27 // Read the full contents of the file. |
28 std::string file_data; | 28 std::string file_data; |
29 if (!base::ReadFileToString(filepath, &file_data)) { | 29 if (!base::ReadFileToString(filepath, &file_data)) { |
30 ADD_FAILURE() << "Couldn't read file: " << filepath.value(); | 30 ADD_FAILURE() << "Couldn't read file: " << filepath.value(); |
31 return std::string(); | 31 return std::string(); |
32 } | 32 } |
33 | 33 |
34 return file_data; | 34 return file_data; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 EXPECT_FALSE(result.message.empty()); | 80 EXPECT_FALSE(result.message.empty()); |
81 EXPECT_FALSE(result.signature_sha1.empty()); | 81 EXPECT_FALSE(result.signature_sha1.empty()); |
82 EXPECT_FALSE(result.signature_sha256.empty()); | 82 EXPECT_FALSE(result.signature_sha256.empty()); |
83 | 83 |
84 return result; | 84 return result; |
85 } | 85 } |
86 | 86 |
87 } // namespace cast_test_helpers | 87 } // namespace cast_test_helpers |
OLD | NEW |