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> | 5 #include <stdint.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base64url.h" | 10 #include "base/base64url.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 path = path.AppendASCII(kContentVerifierDirectory); | 51 path = path.AppendASCII(kContentVerifierDirectory); |
52 | 52 |
53 // Initialize the VerifiedContents object. | 53 // Initialize the VerifiedContents object. |
54 std::string public_key; | 54 std::string public_key; |
55 ASSERT_TRUE(GetPublicKey(path.AppendASCII(kPublicKeyPem), &public_key)); | 55 ASSERT_TRUE(GetPublicKey(path.AppendASCII(kPublicKeyPem), &public_key)); |
56 VerifiedContents contents(reinterpret_cast<const uint8_t*>(public_key.data()), | 56 VerifiedContents contents(reinterpret_cast<const uint8_t*>(public_key.data()), |
57 public_key.size()); | 57 public_key.size()); |
58 base::FilePath verified_contents_path = | 58 base::FilePath verified_contents_path = |
59 path.AppendASCII("verified_contents.json"); | 59 path.AppendASCII("verified_contents.json"); |
60 | 60 |
61 ASSERT_TRUE(contents.InitFrom(verified_contents_path, false)); | 61 ASSERT_TRUE(contents.InitFrom(verified_contents_path)); |
62 | 62 |
63 // Make sure we get expected values. | 63 // Make sure we get expected values. |
64 EXPECT_EQ(contents.block_size(), 4096); | 64 EXPECT_EQ(contents.block_size(), 4096); |
65 EXPECT_EQ(contents.extension_id(), "abcdefghijklmnopabcdefghijklmnop"); | 65 EXPECT_EQ(contents.extension_id(), "abcdefghijklmnopabcdefghijklmnop"); |
66 EXPECT_EQ("1.2.3", contents.version().GetString()); | 66 EXPECT_EQ("1.2.3", contents.version().GetString()); |
67 | 67 |
68 EXPECT_TRUE(contents.TreeHashRootEquals( | 68 EXPECT_TRUE(contents.TreeHashRootEquals( |
69 base::FilePath::FromUTF8Unsafe("manifest.json"), | 69 base::FilePath::FromUTF8Unsafe("manifest.json"), |
70 DecodeBase64Url("-vyyIIn7iSCzg7X3ICUI5wZa3tG7w7vyiCckxZdJGfs"))); | 70 DecodeBase64Url("-vyyIIn7iSCzg7X3ICUI5wZa3tG7w7vyiCckxZdJGfs"))); |
71 | 71 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 140 |
141 // Initialize the VerifiedContents object. | 141 // Initialize the VerifiedContents object. |
142 std::string public_key; | 142 std::string public_key; |
143 ASSERT_TRUE(GetPublicKey(path.AppendASCII(kPublicKeyPem), &public_key)); | 143 ASSERT_TRUE(GetPublicKey(path.AppendASCII(kPublicKeyPem), &public_key)); |
144 VerifiedContents contents(reinterpret_cast<const uint8_t*>(public_key.data()), | 144 VerifiedContents contents(reinterpret_cast<const uint8_t*>(public_key.data()), |
145 public_key.size()); | 145 public_key.size()); |
146 | 146 |
147 base::FilePath verified_contents_path = | 147 base::FilePath verified_contents_path = |
148 path.AppendASCII("verified_contents_base64.json"); | 148 path.AppendASCII("verified_contents_base64.json"); |
149 | 149 |
150 ASSERT_FALSE(contents.InitFrom(verified_contents_path, false)); | 150 ASSERT_FALSE(contents.InitFrom(verified_contents_path)); |
151 } | 151 } |
152 | 152 |
153 } // namespace extensions | 153 } // namespace extensions |
OLD | NEW |