Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: components/cast_certificate/cast_cert_validator_test_helpers.cc

Issue 1924323002: Move Cast certificate verification code from extensions to components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplified OWNERS files Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_certificate {
13
14 namespace testing {
14 15
15 namespace { 16 namespace {
16 17
17 // Reads a file from the extensions test data directory 18 // Reads a file from the test data directory
18 // (//src/extensions/test/data/) 19 // (//src/components/test/data/cast_certificate)
19 std::string ReadTestFileToString(const base::StringPiece& file_name) { 20 std::string ReadTestFileToString(const base::StringPiece& file_name) {
20 base::FilePath filepath; 21 base::FilePath filepath;
21 if (!PathService::Get(extensions::DIR_TEST_DATA, &filepath)) { 22 PathService::Get(base::DIR_SOURCE_ROOT, &filepath);
22 ADD_FAILURE() << "Couldn't retrieve test data root"; 23 filepath = filepath.Append(FILE_PATH_LITERAL("components"));
23 return std::string(); 24 filepath = filepath.Append(FILE_PATH_LITERAL("test"));
24 } 25 filepath = filepath.Append(FILE_PATH_LITERAL("data"));
26 filepath = filepath.Append(FILE_PATH_LITERAL("cast_certificate"));
25 filepath = filepath.AppendASCII(file_name); 27 filepath = filepath.AppendASCII(file_name);
26 28
27 // Read the full contents of the file. 29 // Read the full contents of the file.
28 std::string file_data; 30 std::string file_data;
29 if (!base::ReadFileToString(filepath, &file_data)) { 31 if (!base::ReadFileToString(filepath, &file_data)) {
30 ADD_FAILURE() << "Couldn't read file: " << filepath.value(); 32 ADD_FAILURE() << "Couldn't read file: " << filepath.value();
31 return std::string(); 33 return std::string();
32 } 34 }
33 35
34 return file_data; 36 return file_data;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 79 }
78 } 80 }
79 81
80 EXPECT_FALSE(result.message.empty()); 82 EXPECT_FALSE(result.message.empty());
81 EXPECT_FALSE(result.signature_sha1.empty()); 83 EXPECT_FALSE(result.signature_sha1.empty());
82 EXPECT_FALSE(result.signature_sha256.empty()); 84 EXPECT_FALSE(result.signature_sha256.empty());
83 85
84 return result; 86 return result;
85 } 87 }
86 88
87 } // namespace cast_test_helpers 89 } // namespace testing
90
91 } // namespace cast_certificate
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698