OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> |
| 6 |
5 #include <string> | 7 #include <string> |
6 #include <vector> | 8 #include <vector> |
7 | 9 |
8 #include "base/base64url.h" | 10 #include "base/base64url.h" |
9 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
11 #include "base/path_service.h" | 13 #include "base/path_service.h" |
12 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
13 #include "extensions/browser/verified_contents.h" | 15 #include "extensions/browser/verified_contents.h" |
14 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
(...skipping 29 matching lines...) Expand all Loading... |
44 | 46 |
45 TEST(VerifiedContents, Simple) { | 47 TEST(VerifiedContents, Simple) { |
46 // Figure out our test data directory. | 48 // Figure out our test data directory. |
47 base::FilePath path; | 49 base::FilePath path; |
48 PathService::Get(DIR_TEST_DATA, &path); | 50 PathService::Get(DIR_TEST_DATA, &path); |
49 path = path.AppendASCII(kContentVerifierDirectory); | 51 path = path.AppendASCII(kContentVerifierDirectory); |
50 | 52 |
51 // Initialize the VerifiedContents object. | 53 // Initialize the VerifiedContents object. |
52 std::string public_key; | 54 std::string public_key; |
53 ASSERT_TRUE(GetPublicKey(path.AppendASCII(kPublicKeyPem), &public_key)); | 55 ASSERT_TRUE(GetPublicKey(path.AppendASCII(kPublicKeyPem), &public_key)); |
54 VerifiedContents contents(reinterpret_cast<const uint8*>(public_key.data()), | 56 VerifiedContents contents(reinterpret_cast<const uint8_t*>(public_key.data()), |
55 public_key.size()); | 57 public_key.size()); |
56 base::FilePath verified_contents_path = | 58 base::FilePath verified_contents_path = |
57 path.AppendASCII("verified_contents.json"); | 59 path.AppendASCII("verified_contents.json"); |
58 | 60 |
59 ASSERT_TRUE(contents.InitFrom(verified_contents_path, false)); | 61 ASSERT_TRUE(contents.InitFrom(verified_contents_path, false)); |
60 | 62 |
61 // Make sure we get expected values. | 63 // Make sure we get expected values. |
62 EXPECT_EQ(contents.block_size(), 4096); | 64 EXPECT_EQ(contents.block_size(), 4096); |
63 EXPECT_EQ(contents.extension_id(), "abcdefghijklmnopabcdefghijklmnop"); | 65 EXPECT_EQ(contents.extension_id(), "abcdefghijklmnopabcdefghijklmnop"); |
64 EXPECT_EQ("1.2.3", contents.version().GetString()); | 66 EXPECT_EQ("1.2.3", contents.version().GetString()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // Accepting base64-encoded input where base64url-encoded input is expected | 134 // Accepting base64-encoded input where base64url-encoded input is expected |
133 // will be considered to be invalid data. Verify that it gets rejected. | 135 // will be considered to be invalid data. Verify that it gets rejected. |
134 | 136 |
135 base::FilePath path; | 137 base::FilePath path; |
136 PathService::Get(DIR_TEST_DATA, &path); | 138 PathService::Get(DIR_TEST_DATA, &path); |
137 path = path.AppendASCII(kContentVerifierDirectory); | 139 path = path.AppendASCII(kContentVerifierDirectory); |
138 | 140 |
139 // Initialize the VerifiedContents object. | 141 // Initialize the VerifiedContents object. |
140 std::string public_key; | 142 std::string public_key; |
141 ASSERT_TRUE(GetPublicKey(path.AppendASCII(kPublicKeyPem), &public_key)); | 143 ASSERT_TRUE(GetPublicKey(path.AppendASCII(kPublicKeyPem), &public_key)); |
142 VerifiedContents contents(reinterpret_cast<const uint8*>(public_key.data()), | 144 VerifiedContents contents(reinterpret_cast<const uint8_t*>(public_key.data()), |
143 public_key.size()); | 145 public_key.size()); |
144 | 146 |
145 base::FilePath verified_contents_path = | 147 base::FilePath verified_contents_path = |
146 path.AppendASCII("verified_contents_base64.json"); | 148 path.AppendASCII("verified_contents_base64.json"); |
147 | 149 |
148 ASSERT_FALSE(contents.InitFrom(verified_contents_path, false)); | 150 ASSERT_FALSE(contents.InitFrom(verified_contents_path, false)); |
149 } | 151 } |
150 | 152 |
151 } // namespace extensions | 153 } // namespace extensions |
OLD | NEW |