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

Side by Side Diff: components/payments/content/utility/payment_manifest_parser_unittest.cc

Issue 2802043002: Use web-app manifest format for Android payment apps. (Closed)
Patch Set: Address java comments. Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "components/payments/content/utility/payment_manifest_parser.h" 5 #include "components/payments/content/utility/payment_manifest_parser.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace payments { 9 namespace payments {
10 namespace { 10 namespace {
11 11
12 // Payment method manifest parsing:
13
14 TEST(PaymentManifestParserTest, NullPaymentMethodManifestIsMalformed) {
15 EXPECT_TRUE(
16 PaymentManifestParser::ParsePaymentMethodManifestIntoVector(std::string())
17 .empty());
18 }
19
20 TEST(PaymentManifestParserTest, NonJsonPaymentMethodManifestIsMalformed) {
21 EXPECT_TRUE(PaymentManifestParser::ParsePaymentMethodManifestIntoVector(
22 "this is not json")
23 .empty());
24 }
25
26 TEST(PaymentManifestParserTest, StringPaymentMethodManifestIsMalformed) {
27 EXPECT_TRUE(PaymentManifestParser::ParsePaymentMethodManifestIntoVector(
28 "\"this is a string\"")
29 .empty());
30 }
31
32 TEST(PaymentManifestParserTest,
33 EmptyDictionaryPaymentMethodManifestIsMalformed) {
34 EXPECT_TRUE(PaymentManifestParser::ParsePaymentMethodManifestIntoVector("{}")
35 .empty());
36 }
37
38 TEST(PaymentManifestParserTest, NullDefaultApplicationIsMalformed) {
39 EXPECT_TRUE(PaymentManifestParser::ParsePaymentMethodManifestIntoVector(
40 "{\"default_applications\": null}")
41 .empty());
42 }
43
44 TEST(PaymentManifestParserTest, NumberDefaultApplicationIsMalformed) {
45 EXPECT_TRUE(PaymentManifestParser::ParsePaymentMethodManifestIntoVector(
46 "{\"default_applications\": 0}")
47 .empty());
48 }
49
50 TEST(PaymentManifestParserTest, ListOfNumbersDefaultApplicationIsMalformed) {
51 EXPECT_TRUE(PaymentManifestParser::ParsePaymentMethodManifestIntoVector(
52 "{\"default_applications\": [0]}")
53 .empty());
54 }
55
56 TEST(PaymentManifestParserTest, EmptyListOfDefaultApplicationsIsMalformed) {
57 EXPECT_TRUE(PaymentManifestParser::ParsePaymentMethodManifestIntoVector(
58 "{\"default_applications\": []}")
59 .empty());
60 }
61
62 TEST(PaymentManifestParserTest, ListOfEmptyDefaultApplicationsIsMalformed) {
63 EXPECT_TRUE(PaymentManifestParser::ParsePaymentMethodManifestIntoVector(
64 "{\"default_applications\": [\"\"]}")
65 .empty());
66 }
67
68 TEST(PaymentManifestParserTest, DefaultApplicationsShouldNotHaveNulCharacters) {
69 EXPECT_TRUE(
70 PaymentManifestParser::ParsePaymentMethodManifestIntoVector(
71 "{\"default_applications\": [\"https://bobpay.com/app\0json\"]}")
72 .empty());
73 }
74
75 TEST(PaymentManifestParserTest, DefaultApplicationKeyShouldBeLowercase) {
76 EXPECT_TRUE(
77 PaymentManifestParser::ParsePaymentMethodManifestIntoVector(
78 "{\"Default_Applications\": [\"https://bobpay.com/app.json\"]}")
79 .empty());
80 }
81
82 TEST(PaymentManifestParserTest, DefaultApplicationsShouldBeAbsoluteUrls) {
83 EXPECT_TRUE(PaymentManifestParser::ParsePaymentMethodManifestIntoVector(
84 "{\"default_applications\": ["
85 "\"https://bobpay.com/app.json\","
86 "\"app.json\"]}")
87 .empty());
88 }
89
90 TEST(PaymentManifestParserTest, DefaultApplicationsShouldBeHttps) {
91 EXPECT_TRUE(PaymentManifestParser::ParsePaymentMethodManifestIntoVector(
92 "{\"default_applications\": ["
93 "\"https://bobpay.com/app.json\","
94 "\"http://alicepay.com/app.json\"]}")
95 .empty());
96 }
97
98 TEST(PaymentManifestParserTest, WellFormedPaymentMethodManifest) {
99 std::vector<GURL> expected = {GURL("https://bobpay.com/app.json"),
100 GURL("https://alicepay.com/app.json")};
101 EXPECT_EQ(expected,
102 PaymentManifestParser::ParsePaymentMethodManifestIntoVector(
103 "{\"default_applications\": ["
104 "\"https://bobpay.com/app.json\","
105 "\"https://alicepay.com/app.json\"]}"));
106 }
107
108 // Web app manifest parsing:
109
12 void ExpectUnableToParse(const std::string& input) { 110 void ExpectUnableToParse(const std::string& input) {
13 std::vector<mojom::PaymentManifestSectionPtr> actual_output = 111 std::vector<mojom::WebAppManifestSectionPtr> actual_output =
14 PaymentManifestParser::ParseIntoVector(input); 112 PaymentManifestParser::ParseWebAppManifestIntoVector(input);
15 EXPECT_TRUE(actual_output.empty()); 113 EXPECT_TRUE(actual_output.empty());
16 } 114 }
17 115
18 void ExpectParsed( 116 void ExpectParsed(
19 const std::string& input, 117 const std::string& input,
20 const std::string& expected_package_name, 118 const std::string& expected_id,
21 int expected_version, 119 int64_t expected_min_version,
22 const std::vector<std::vector<uint8_t>>& expected_fingerprints) { 120 const std::vector<std::vector<uint8_t>>& expected_fingerprints) {
23 std::vector<mojom::PaymentManifestSectionPtr> actual_output = 121 std::vector<mojom::WebAppManifestSectionPtr> actual_output =
24 PaymentManifestParser::ParseIntoVector(input); 122 PaymentManifestParser::ParseWebAppManifestIntoVector(input);
25 ASSERT_EQ(1U, actual_output.size()); 123 ASSERT_EQ(1U, actual_output.size());
26 EXPECT_EQ(expected_package_name, actual_output.front()->package_name); 124 EXPECT_EQ(expected_id, actual_output.front()->id);
27 EXPECT_EQ(expected_version, actual_output.front()->version); 125 EXPECT_EQ(expected_min_version, actual_output.front()->min_version);
28 EXPECT_EQ(expected_fingerprints, 126 EXPECT_EQ(expected_fingerprints, actual_output.front()->fingerprints);
29 actual_output.front()->sha256_cert_fingerprints);
30 } 127 }
31 128
32 TEST(PaymentManifestParserTest, NullContentIsMalformed) { 129 TEST(PaymentManifestParserTest, NullContentIsMalformed) {
33 ExpectUnableToParse(std::string()); 130 ExpectUnableToParse(std::string());
34 } 131 }
35 132
36 TEST(PaymentManifestParserTest, NonJsonContentIsMalformed) { 133 TEST(PaymentManifestParserTest, NonJsonContentIsMalformed) {
37 ExpectUnableToParse("this is not json"); 134 ExpectUnableToParse("this is not json");
38 } 135 }
39 136
40 TEST(PaymentManifestParserTest, StringContentIsMalformed) { 137 TEST(PaymentManifestParserTest, StringContentIsMalformed) {
41 ExpectUnableToParse("\"this is a string\""); 138 ExpectUnableToParse("\"this is a string\"");
42 } 139 }
43 140
44 TEST(PaymentManifestParserTest, EmptyDictionaryIsMalformed) { 141 TEST(PaymentManifestParserTest, EmptyDictionaryIsMalformed) {
45 ExpectUnableToParse("{}"); 142 ExpectUnableToParse("{}");
46 } 143 }
47 144
48 TEST(PaymentManifestParserTest, NullAndroidSectionIsMalformed) { 145 TEST(PaymentManifestParserTest, NullRelatedApplicationsSectionIsMalformed) {
49 ExpectUnableToParse("{\"android\": null}"); 146 ExpectUnableToParse("{\"related_applications\": null}");
50 } 147 }
51 148
52 TEST(PaymentManifestParserTest, NumberAndroidSectionIsMalformed) { 149 TEST(PaymentManifestParserTest, NumberRelatedApplicationsectionIsMalformed) {
53 ExpectUnableToParse("{\"android\": 0}"); 150 ExpectUnableToParse("{\"related_applications\": 0}");
54 }
55
56 TEST(PaymentManifestParserTest, ListOfNumbersAndroidSectionIsMalformed) {
57 ExpectUnableToParse("{\"android\": [0]}");
58 } 151 }
59 152
60 TEST(PaymentManifestParserTest, 153 TEST(PaymentManifestParserTest,
61 ListOfEmptyDictionariesAndroidSectionIsMalformed) { 154 ListOfNumbersRelatedApplicationsSectionIsMalformed) {
62 ExpectUnableToParse("{\"android\": [{}]}"); 155 ExpectUnableToParse("{\"related_applications\": [0]}");
156 }
157
158 TEST(PaymentManifestParserTest,
159 ListOfEmptyDictionariesRelatedApplicationsSectionIsMalformed) {
160 ExpectUnableToParse("{\"related_applications\": [{}]}");
161 }
162
163 TEST(PaymentManifestParserTest, NoPlayPlatformIsMalformed) {
164 ExpectUnableToParse(
165 "{"
166 " \"related_applications\": [{"
167 " \"id\": \"com.bobpay.app\", "
168 " \"min_version\": \"1\", "
169 " \"fingerprints\": [{"
170 " \"type\": \"sha256_cert\", "
171 " \"value\": \"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7"
172 ":A8:A9:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:C0:C1\""
173 " }]"
174 " }]"
175 "}");
63 } 176 }
64 177
65 TEST(PaymentManifestParserTest, NoPackageNameIsMalformed) { 178 TEST(PaymentManifestParserTest, NoPackageNameIsMalformed) {
66 ExpectUnableToParse("{\"android\": [{\"version\": 3}]}"); 179 ExpectUnableToParse(
67 } 180 "{"
68 181 " \"related_applications\": [{"
69 TEST(PaymentManifestParserTest, OnlyPackageNameIsWellFormed) { 182 " \"platform\": \"play\", "
70 ExpectParsed("{\"android\": [{\"package\": \"*\"}]}", "*", 0, 183 " \"min_version\": \"1\", "
71 std::vector<std::vector<uint8_t>>()); 184 " \"fingerprints\": [{"
185 " \"type\": \"sha256_cert\", "
186 " \"value\": \"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7"
187 ":A8:A9:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:C0:C1\""
188 " }]"
189 " }]"
190 "}");
191 }
192
193 TEST(PaymentManifestParserTest, NoVersionIsMalformed) {
194 ExpectUnableToParse(
195 "{"
196 " \"related_applications\": [{"
197 " \"platform\": \"play\", "
198 " \"id\": \"com.bobpay.app\", "
199 " \"fingerprints\": [{"
200 " \"type\": \"sha256_cert\", "
201 " \"value\": \"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7"
202 ":A8:A9:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:C0:C1\""
203 " }]"
204 " }]"
205 "}");
206 }
207
208 TEST(PaymentManifestParserTest, NoFingerprintIsMalformed) {
209 ExpectUnableToParse(
210 "{"
211 " \"related_applications\": [{"
212 " \"platform\": \"play\", "
213 " \"id\": \"com.bobpay.app\", "
214 " \"min_version\": \"1\""
215 " }]"
216 "}");
217 }
218
219 TEST(PaymentManifestParserTest, EmptyFingerprintsIsMalformed) {
220 ExpectUnableToParse(
221 "{"
222 " \"related_applications\": [{"
223 " \"platform\": \"play\", "
224 " \"id\": \"com.bobpay.app\", "
225 " \"min_version\": \"1\", "
226 " \"fingerprints\": []"
227 " }]"
228 "}");
229 }
230
231 TEST(PaymentManifestParserTest, EmptyFingerprintsDictionaryIsMalformed) {
232 ExpectUnableToParse(
233 "{"
234 " \"related_applications\": [{"
235 " \"platform\": \"play\", "
236 " \"id\": \"com.bobpay.app\", "
237 " \"min_version\": \"1\", "
238 " \"fingerprints\": [{}]"
239 " }]"
240 "}");
241 }
242
243 TEST(PaymentManifestParserTest, NoFingerprintTypeIsMalformed) {
244 ExpectUnableToParse(
245 "{"
246 " \"related_applications\": [{"
247 " \"platform\": \"play\", "
248 " \"id\": \"com.bobpay.app\", "
249 " \"min_version\": \"1\", "
250 " \"fingerprints\": [{"
251 " \"value\": \"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7"
252 ":A8:A9:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:C0:C1\""
253 " }]"
254 " }]"
255 "}");
256 }
257
258 TEST(PaymentManifestParserTest, NoFingerprintValueIsMalformed) {
259 ExpectUnableToParse(
260 "{"
261 " \"related_applications\": [{"
262 " \"platform\": \"play\", "
263 " \"id\": \"com.bobpay.app\", "
264 " \"min_version\": \"1\", "
265 " \"fingerprints\": [{"
266 " \"type\": \"sha256_cert\""
267 " }]"
268 " }]"
269 "}");
270 }
271
272 TEST(PaymentManifestParserTest, PlatformShouldNotHaveNullCharacters) {
273 ExpectUnableToParse(
274 "{"
275 " \"related_applications\": [{"
276 " \"platform\": \"pl\0ay\", "
277 " \"id\": \"com.bobpay.app\", "
278 " \"min_version\": \"1\", "
279 " \"fingerprints\": [{"
280 " \"type\": \"sha256_cert\", "
281 " \"value\": \"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7"
282 ":A8:A9:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:C0:C1\""
283 " }]"
284 " }]"
285 "}");
286 }
287
288 TEST(PaymentManifestParserTest, PackageNameShouldNotHaveNullCharacters) {
289 ExpectUnableToParse(
290 "{"
291 " \"related_applications\": [{"
292 " \"platform\": \"play\", "
293 " \"id\": \"com.bob\0pay.app\", "
294 " \"min_version\": \"1\", "
295 " \"fingerprints\": [{"
296 " \"type\": \"sha256_cert\", "
297 " \"value\": \"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7"
298 ":A8:A9:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:C0:C1\""
299 " }]"
300 " }]"
301 "}");
302 }
303
304 TEST(PaymentManifestParserTest, VersionShouldNotHaveNullCharacters) {
305 ExpectUnableToParse(
306 "{"
307 " \"related_applications\": [{"
308 " \"platform\": \"play\", "
309 " \"id\": \"com.bobpay.app\", "
310 " \"min_version\": \"1\01\", "
311 " \"fingerprints\": [{"
312 " \"type\": \"sha256_cert\", "
313 " \"value\": \"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7"
314 ":A8:A9:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:C0:C1\""
315 " }]"
316 " }]"
317 "}");
318 }
319
320 TEST(PaymentManifestParserTest, FingerprintTypeShouldNotHaveNullCharacters) {
321 ExpectUnableToParse(
322 "{"
323 " \"related_applications\": [{"
324 " \"platform\": \"play\", "
325 " \"id\": \"com.bobpay.app\", "
326 " \"min_version\": \"1\", "
327 " \"fingerprints\": [{"
328 " \"type\": \"sha256_c\0ert\", "
329 " \"value\": \"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7"
330 ":A8:A9:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:C0:C1\""
331 " }]"
332 " }]"
333 "}");
334 }
335
336 TEST(PaymentManifestParserTest, FingerprintValueShouldNotHaveNullCharacters) {
337 ExpectUnableToParse(
338 "{"
339 " \"related_applications\": [{"
340 " \"platform\": \"play\", "
341 " \"id\": \"com.bobpay.app\", "
342 " \"min_version\": \"1\", "
343 " \"fingerprints\": [{"
344 " \"type\": \"sha256_cert\", "
345 " \"value\": "
346 "\"00:01:02:0\0:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7"
347 ":A8:A9:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:C0:C1\""
348 " }]"
349 " }]"
350 "}");
351 }
352
353 TEST(PaymentManifestParserTest, KeysShouldBeLowerCase) {
354 ExpectUnableToParse(
355 "{"
356 " \"Related_applications\": [{"
357 " \"Platform\": \"play\", "
358 " \"Id\": \"com.bobpay.app\", "
359 " \"Min_version\": \"1\", "
360 " \"Fingerprints\": [{"
361 " \"Type\": \"sha256_cert\", "
362 " \"Value\": \"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7"
363 ":A8:A9:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:C0:C1\""
364 " }]"
365 " }]"
366 "}");
367 }
368
369 TEST(PaymentManifestParserTest, FingerprintsShouldBeSha256) {
370 ExpectUnableToParse(
371 "{"
372 " \"related_applications\": [{"
373 " \"platform\": \"play\", "
374 " \"id\": \"com.bobpay.app\", "
375 " \"min_version\": \"1\", "
376 " \"fingerprints\": [{"
377 " \"type\": \"sha1_cert\", "
378 " \"value\": \"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7"
379 ":A8:A9\""
380 " }]"
381 " }]"
382 "}");
383 }
384
385 TEST(PaymentManifestParserTest, FingerprintBytesShouldBeColonSeparated) {
386 ExpectUnableToParse(
387 "{"
388 " \"related_applications\": [{"
389 " \"platform\": \"play\", "
390 " \"id\": \"com.bobpay.app\", "
391 " \"min_version\": \"1\", "
392 " \"fingerprints\": [{"
393 " \"type\": \"sha256_cert\", "
394 " \"value\" \"00010203040506070809A0A1A2A3A4A5A6A7A8A9B0B1B2B3B4B5B6"
395 "B7B8B9C0C1\""
396 " }]"
397 " }]"
398 "}");
399 }
400
401 TEST(PaymentManifestParserTest, FingerprintBytesShouldBeUpperCase) {
402 ExpectUnableToParse(
403 "{"
404 " \"related_applications\": [{"
405 " \"platform\": \"play\", "
406 " \"id\": \"com.bobpay.app\", "
407 " \"min_version\": \"1\", "
408 " \"fingerprints\": [{"
409 " \"type\": \"sha256_cert\", "
410 " \"value\": \"00:01:02:03:04:05:06:07:08:09:a0:a1:a2:a3:a4:a5:a6:a7"
411 ":a8:a9:b0:b1:b2:b3:b4:b5:b6:b7:b8:b9:c0:c1\""
412 " }]"
413 " }]"
414 "}");
415 }
416
417 TEST(PaymentManifestParserTest, FingerprintsShouldContainsThirtyTwoBytes) {
418 ExpectUnableToParse(
419 "{"
420 " \"related_applications\": [{"
421 " \"platform\": \"play\", "
422 " \"id\": \"com.bobpay.app\", "
423 " \"min_version\": \"1\", "
424 " \"fingerprints\": [{"
425 " \"type\": \"sha256_cert\", "
426 " \"value\": \"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7"
427 ":A8:A9:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:C0:C1:C2\""
428 " }]"
429 " }]"
430 "}");
431 ExpectUnableToParse(
432 "{"
433 " \"related_applications\": [{"
434 " \"platform\": \"play\", "
435 " \"id\": \"com.bobpay.app\", "
436 " \"min_version\": \"1\", "
437 " \"fingerprints\": [{"
438 " \"type\": \"sha256_cert\", "
439 " \"value\": \"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7"
440 ":A8:A9:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:C0\""
441 " }]"
442 " }]"
443 "}");
72 } 444 }
73 445
74 TEST(PaymentManifestParserTest, WellFormed) { 446 TEST(PaymentManifestParserTest, WellFormed) {
75 ExpectParsed( 447 ExpectParsed(
76 "{\"android\": [{" 448 "{"
77 "\"package\": \"com.bobpay.app\"," 449 " \"related_applications\": [{"
78 "\"version\": 3," 450 " \"platform\": \"play\", "
79 "\"sha256_cert_fingerprints\": " 451 " \"id\": \"com.bobpay.app\", "
80 "[\"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:B0:B1:B2:" 452 " \"min_version\": \"1\", "
81 "B3:B4:B5:B6:B7:B8:B9:C0:C1\"]}]}", 453 " \"fingerprints\": [{"
82 "com.bobpay.app", 3, 454 " \"type\": \"sha256_cert\", "
455 " \"value\": \"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7"
456 ":A8:A9:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:C0:C1\""
457 " }]"
458 " }]"
459 "}",
460 "com.bobpay.app", 1,
83 {{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xA0, 461 {{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xA0,
84 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xB0, 0xB1, 462 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xB0, 0xB1,
85 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xC0, 0xC1}}); 463 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xC0, 0xC1}});
86 } 464 }
87 465
88 TEST(PaymentManifestParserTest, ValuesShouldNotHaveNulCharacters) {
89 ExpectUnableToParse(
90 "{\"android\": [{"
91 "\"package\": \"com.bob\0pay.app\","
92 "\"version\": 3,"
93 "\"sha256_cert_fingerprints\": "
94 "[\"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:B0:B1:B2:"
95 "B3:B4:B5:B6:B7:B8:B9:C0:C1\"]}]}");
96 }
97
98 TEST(PaymentManifestParserTest, StarPackageShouldBeTheOnlySection) {
99 ExpectUnableToParse(
100 "{\"android\": [{"
101 "\"package\": \"com.bobpay.app\","
102 "\"version\": 3,"
103 "\"sha256_cert_fingerprints\": "
104 "[\"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:B0:B1:B2:"
105 "B3:B4:B5:B6:B7:B8:B9:C0:C1\"]}, {"
106 "\"package\": \"*\"}]}");
107 }
108
109 TEST(PaymentManifestParserTest, DuplicateSignaturesWellFormed) { 466 TEST(PaymentManifestParserTest, DuplicateSignaturesWellFormed) {
110 ExpectParsed( 467 ExpectParsed(
111 "{\"android\": [{" 468 "{"
112 "\"package\": \"com.bobpay.app\"," 469 " \"related_applications\": [{"
113 "\"version\": 3," 470 " \"platform\": \"play\", "
114 "\"sha256_cert_fingerprints\": " 471 " \"id\": \"com.bobpay.app\", "
115 "[\"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:B0:B1:B2:" 472 " \"min_version\": \"1\", "
116 "B3:B4:B5:B6:B7:B8:B9:C0:C1\"," 473 " \"fingerprints\": [{"
117 "\"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:B0:B1:B2:" 474 " \"type\": \"sha256_cert\", "
118 "B3:B4:B5:B6:B7:B8:B9:C0:C1\"]}]}", 475 " \"value\": \"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7"
119 "com.bobpay.app", 3, 476 ":A8:A9:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:C0:C1\""
477 " }, {"
478 " \"type\": \"sha256_cert\", "
479 " \"value\": \"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7"
480 ":A8:A9:B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:C0:C1\""
481 " }]"
482 " }]"
483 "}",
484 "com.bobpay.app", 1,
120 {{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xA0, 485 {{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xA0,
121 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xB0, 0xB1, 486 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xB0, 0xB1,
122 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xC0, 0xC1}, 487 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xC0, 0xC1},
123 {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xA0, 488 {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xA0,
124 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xB0, 0xB1, 489 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xB0, 0xB1,
125 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xC0, 0xC1}}); 490 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xC0, 0xC1}});
126 } 491 }
127 492
128 TEST(PaymentManifestParserTest, KeysShouldBeLowerCase) {
129 ExpectUnableToParse(
130 "{\"android\": [{"
131 "\"package\": \"com.bobpay.app\","
132 "\"version\": 3,"
133 "\"sha256_CERT_fingerprints\": "
134 "[\"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:B0:B1:B2:"
135 "B3:B4:B5:B6:B7:B8:B9:C0:C1\"]}]}");
136 }
137
138 TEST(PaymentManifestParserTest, FingerprintsShouldBeUpperCase) {
139 ExpectUnableToParse(
140 "{\"android\": [{"
141 "\"package\": \"com.bobpay.app\","
142 "\"version\": 3,"
143 "\"sha256_cert_fingerprints\": "
144 "[\"00:01:02:03:04:05:06:07:08:09:a0:a1:a2:a3:a4:a5:a6:a7:a8:a9:b0:b1:b2:"
145 "b3:b4:b5:b6:b7:b8:b9:c0:c1\"]}]}");
146 }
147
148 TEST(PaymentManifestParserTest, FingerprintBytesShouldBeColonSeparated) {
149 ExpectUnableToParse(
150 "{\"android\": [{"
151 "\"package\": \"com.bobpay.app\","
152 "\"version\": 3,"
153 "\"sha256_cert_fingerprints\":"
154 "[\"00010203040506070809A0A1A2A3A4A5A6A7A8A9B0B1B2B3B4B5B6B7B8B9C0C1\"]}]"
155 "}");
156 }
157
158 TEST(PaymentManifestParserTest, FingerprintsShouldBeHex) {
159 ExpectUnableToParse(
160 "{\"android\": [{"
161 "\"package\": \"com.bobpay.app\","
162 "\"version\": 3,"
163 "\"sha256_cert_fingerprints\": "
164 "[\"GG:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:B0:B1:B2:"
165 "B3:B4:B5:B6:B7:B8:B9:C0:C1\"]}]}");
166 }
167
168 TEST(PaymentManifestParserTest, FingerprintsShouldContainsThirtyTwoBytes) {
169 ExpectUnableToParse(
170 "{\"android\": [{"
171 "\"package\": \"com.bobpay.app\","
172 "\"version\": 3,"
173 "\"sha256_cert_fingerprints\": "
174 "[\"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:B0:B1:B2:"
175 "B3:B4:B5:B6:B7:B8:B9:C0\"]}]}");
176 ExpectUnableToParse(
177 "{\"android\": [{"
178 "\"package\": \"com.bobpay.app\","
179 "\"version\": 3,"
180 "\"sha256_cert_fingerprints\": "
181 "[\"00:01:02:03:04:05:06:07:08:09:A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:B0:B1:B2:"
182 "B3:B4:B5:B6:B7:B8:B9:C0:C1:C2\"]}]}");
183 }
184
185 } // namespace 493 } // namespace
186 } // namespace payments 494 } // namespace payments
OLDNEW
« no previous file with comments | « components/payments/content/utility/payment_manifest_parser.cc ('k') | components/payments_strings.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698