blob: 6a698a334483764927ed277b3fa753729961a428 [file] [log] [blame]
Rouslan Solomakhinde012532017-09-20 15:18:341// Copyright 2017 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "components/payments/content/manifest_verifier.h"
6
7#include <stdint.h>
8#include <utility>
9
Rouslan Solomakhin438d8c92017-10-26 21:33:1810#include "base/run_loop.h"
11#include "chrome/browser/profiles/profile.h"
Rouslan Solomakhinde012532017-09-20 15:18:3412#include "chrome/browser/ui/browser.h"
13#include "chrome/browser/ui/tabs/tab_strip_model.h"
14#include "chrome/browser/web_data_service_factory.h"
15#include "chrome/test/base/in_process_browser_test.h"
Rouslan Solomakhinde012532017-09-20 15:18:3416#include "components/payments/content/payment_manifest_web_data_service.h"
Jay Civellia7d22b42017-10-24 18:38:0717#include "components/payments/content/utility/payment_manifest_parser.h"
Rouslan Solomakhin438d8c92017-10-26 21:33:1818#include "components/payments/core/test_payment_manifest_downloader.h"
Rouslan Solomakhinde012532017-09-20 15:18:3419#include "content/public/browser/browser_context.h"
20#include "content/public/browser/storage_partition.h"
21#include "net/test/embedded_test_server/embedded_test_server.h"
22#include "net/url_request/url_request_context_getter.h"
23#include "testing/gtest/include/gtest/gtest.h"
Rouslan Solomakhinde012532017-09-20 15:18:3424
25namespace payments {
26namespace {
27
Rouslan Solomakhinde012532017-09-20 15:18:3428// Tests for the manifest verifier.
29class ManifestVerifierBrowserTest : public InProcessBrowserTest {
30 public:
31 ManifestVerifierBrowserTest() {}
32 ~ManifestVerifierBrowserTest() override {}
33
34 // Starts the HTTPS test server on localhost.
35 void SetUpOnMainThread() override {
36 https_server_ = std::make_unique<net::EmbeddedTestServer>(
37 net::EmbeddedTestServer::TYPE_HTTPS);
38 ASSERT_TRUE(https_server_->InitializeAndListen());
39 https_server_->ServeFilesFromSourceDirectory(
40 "components/test/data/payments");
41 https_server_->StartAcceptingConnections();
42 }
43
44 // Runs the verifier on the |apps| and blocks until the verifier has finished
45 // using all resources.
46 void Verify(content::PaymentAppProvider::PaymentApps apps) {
Rouslan Solomakhin438d8c92017-10-26 21:33:1847 content::BrowserContext* context = browser()
48 ->tab_strip_model()
49 ->GetActiveWebContents()
50 ->GetBrowserContext();
Rouslan Solomakhinde012532017-09-20 15:18:3451 auto downloader = std::make_unique<TestDownloader>(
Rouslan Solomakhin438d8c92017-10-26 21:33:1852 content::BrowserContext::GetDefaultStoragePartition(context)
Rouslan Solomakhinde012532017-09-20 15:18:3453 ->GetURLRequestContext());
Rouslan Solomakhin438d8c92017-10-26 21:33:1854 downloader->AddTestServerURL("https://", https_server_->GetURL("/"));
Rouslan Solomakhinde012532017-09-20 15:18:3455
56 ManifestVerifier verifier(
57 std::move(downloader),
Jay Civellia7d22b42017-10-24 18:38:0758 std::make_unique<payments::PaymentManifestParser>(),
Rouslan Solomakhinde012532017-09-20 15:18:3459 WebDataServiceFactory::GetPaymentManifestWebDataForProfile(
Rouslan Solomakhin438d8c92017-10-26 21:33:1860 Profile::FromBrowserContext(context),
Rouslan Solomakhinde012532017-09-20 15:18:3461 ServiceAccessType::EXPLICIT_ACCESS));
62
63 base::RunLoop run_loop;
Rouslan Solomakhinde012532017-09-20 15:18:3464 verifier.Verify(
65 std::move(apps),
66 base::BindOnce(&ManifestVerifierBrowserTest::OnPaymentAppsVerified,
67 base::Unretained(this)),
Rouslan Solomakhin438d8c92017-10-26 21:33:1868 run_loop.QuitClosure());
Rouslan Solomakhinde012532017-09-20 15:18:3469 run_loop.Run();
70 }
71
72 // Returns the apps that have been verified by the Verify() method.
73 const content::PaymentAppProvider::PaymentApps& verified_apps() const {
74 return verified_apps_;
75 }
76
77 // Expects that the verified payment app with |id| has the |expected_scope|
78 // and the |expected_methods|.
79 void ExpectApp(int64_t id,
80 const std::string& expected_scope,
81 const std::set<std::string>& expected_methods) {
82 ASSERT_NE(verified_apps().end(), verified_apps().find(id));
83 EXPECT_EQ(GURL(expected_scope), verified_apps().find(id)->second->scope);
84 std::set<std::string> actual_methods(
85 verified_apps().find(id)->second->enabled_methods.begin(),
86 verified_apps().find(id)->second->enabled_methods.end());
87 EXPECT_EQ(expected_methods, actual_methods);
88 }
89
90 private:
91 // Called by the verifier upon completed verification. These |apps| have only
92 // valid payment methods.
93 void OnPaymentAppsVerified(content::PaymentAppProvider::PaymentApps apps) {
94 verified_apps_ = std::move(apps);
95 }
96
Rouslan Solomakhinde012532017-09-20 15:18:3497 // Serves the payment method manifest files.
98 std::unique_ptr<net::EmbeddedTestServer> https_server_;
99
100 // The apps that have been verified by the Verify() method.
101 content::PaymentAppProvider::PaymentApps verified_apps_;
102
Rouslan Solomakhinde012532017-09-20 15:18:34103 DISALLOW_COPY_AND_ASSIGN(ManifestVerifierBrowserTest);
104};
105
106// Absence of payment handlers should result in absence of verified payment
107// handlers.
108IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, NoApps) {
109 {
110 Verify(content::PaymentAppProvider::PaymentApps());
111
112 EXPECT_TRUE(verified_apps().empty());
113 }
114
115 // Repeat verifications should have identical results.
116 {
117 Verify(content::PaymentAppProvider::PaymentApps());
118
119 EXPECT_TRUE(verified_apps().empty());
120 }
121}
122
123// A payment handler without any payment method names is not valid.
124IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, NoMethods) {
125 {
126 content::PaymentAppProvider::PaymentApps apps;
127 apps[0] = std::make_unique<content::StoredPaymentApp>();
128 apps[0]->scope = GURL("https://bobpay.com/webpay");
129
130 Verify(std::move(apps));
131
132 EXPECT_TRUE(verified_apps().empty());
133 }
134
135 // Repeat verifications should have identical results.
136 {
137 content::PaymentAppProvider::PaymentApps apps;
138 apps[0] = std::make_unique<content::StoredPaymentApp>();
139 apps[0]->scope = GURL("https://bobpay.com/webpay");
140
141 Verify(std::move(apps));
142
143 EXPECT_TRUE(verified_apps().empty());
144 }
145}
146
147// A payment handler with an unknown non-URL payment method name is not valid.
148IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest,
149 UnknownPaymentMethodNameIsRemoved) {
150 {
151 content::PaymentAppProvider::PaymentApps apps;
152 apps[0] = std::make_unique<content::StoredPaymentApp>();
153 apps[0]->scope = GURL("https://bobpay.com/webpay");
154 apps[0]->enabled_methods.push_back("unknown");
155
156 Verify(std::move(apps));
157
158 EXPECT_TRUE(verified_apps().empty());
159 }
160
161 // Repeat verifications should have identical results.
162 {
163 content::PaymentAppProvider::PaymentApps apps;
164 apps[0] = std::make_unique<content::StoredPaymentApp>();
165 apps[0]->scope = GURL("https://bobpay.com/webpay");
166 apps[0]->enabled_methods.push_back("unknown");
167
168 Verify(std::move(apps));
169
170 EXPECT_TRUE(verified_apps().empty());
171 }
172}
173
174// A payment handler with "basic-card" payment method name is valid.
175IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, KnownPaymentMethodName) {
176 {
177 content::PaymentAppProvider::PaymentApps apps;
178 apps[0] = std::make_unique<content::StoredPaymentApp>();
179 apps[0]->scope = GURL("https://bobpay.com/webpay");
180 apps[0]->enabled_methods.push_back("basic-card");
181
182 Verify(std::move(apps));
183
184 EXPECT_EQ(1U, verified_apps().size());
185 ExpectApp(0, "https://bobpay.com/webpay", {"basic-card"});
186 }
187
188 // Repeat verifications should have identical results.
189 {
190 content::PaymentAppProvider::PaymentApps apps;
191 apps[0] = std::make_unique<content::StoredPaymentApp>();
192 apps[0]->scope = GURL("https://bobpay.com/webpay");
193 apps[0]->enabled_methods.push_back("basic-card");
194
195 Verify(std::move(apps));
196
197 EXPECT_EQ(1U, verified_apps().size());
198 ExpectApp(0, "https://bobpay.com/webpay", {"basic-card"});
199 }
200}
201
202// A payment handler with both "basic-card" and "interledger" payment method
203// names is valid.
204IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest,
205 TwoKnownPaymentMethodNames) {
206 {
207 content::PaymentAppProvider::PaymentApps apps;
208 apps[0] = std::make_unique<content::StoredPaymentApp>();
209 apps[0]->scope = GURL("https://bobpay.com/webpay");
210 apps[0]->enabled_methods.push_back("basic-card");
211 apps[0]->enabled_methods.push_back("interledger");
212
213 Verify(std::move(apps));
214
215 EXPECT_EQ(1U, verified_apps().size());
216 ExpectApp(0, "https://bobpay.com/webpay", {"basic-card", "interledger"});
217 }
218
219 // Repeat verifications should have identical results.
220 {
221 content::PaymentAppProvider::PaymentApps apps;
222 apps[0] = std::make_unique<content::StoredPaymentApp>();
223 apps[0]->scope = GURL("https://bobpay.com/webpay");
224 apps[0]->enabled_methods.push_back("basic-card");
225 apps[0]->enabled_methods.push_back("interledger");
226
227 Verify(std::move(apps));
228
229 EXPECT_EQ(1U, verified_apps().size());
230 ExpectApp(0, "https://bobpay.com/webpay", {"basic-card", "interledger"});
231 }
232}
233
234// Two payment handlers with "basic-card" payment method names are both valid.
235IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest,
236 TwoAppsWithKnownPaymentMethodNames) {
237 {
238 content::PaymentAppProvider::PaymentApps apps;
239 apps[0] = std::make_unique<content::StoredPaymentApp>();
240 apps[0]->scope = GURL("https://bobpay.com/webpay");
241 apps[0]->enabled_methods.push_back("basic-card");
242 apps[1] = std::make_unique<content::StoredPaymentApp>();
243 apps[1]->scope = GURL("https://alicepay.com/webpay");
244 apps[1]->enabled_methods.push_back("basic-card");
245
246 Verify(std::move(apps));
247
248 EXPECT_EQ(2U, verified_apps().size());
249 ExpectApp(0, "https://bobpay.com/webpay", {"basic-card"});
250 ExpectApp(1, "https://alicepay.com/webpay", {"basic-card"});
251 }
252
253 // Repeat verifications should have identical results.
254 {
255 content::PaymentAppProvider::PaymentApps apps;
256 apps[0] = std::make_unique<content::StoredPaymentApp>();
257 apps[0]->scope = GURL("https://bobpay.com/webpay");
258 apps[0]->enabled_methods.push_back("basic-card");
259 apps[1] = std::make_unique<content::StoredPaymentApp>();
260 apps[1]->scope = GURL("https://alicepay.com/webpay");
261 apps[1]->enabled_methods.push_back("basic-card");
262 Verify(std::move(apps));
263
264 EXPECT_EQ(2U, verified_apps().size());
265 ExpectApp(0, "https://bobpay.com/webpay", {"basic-card"});
266 ExpectApp(1, "https://alicepay.com/webpay", {"basic-card"});
267 }
268}
269
270// Verify that a payment handler from https://bobpay.com/webpay can use the
271// payment method name https://frankpay.com/webpay, because
272// https://frankpay.com/payment-manifest.json contains "supported_origins": "*".
273IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest,
274 BobPayHandlerCanUseMethodThatSupportsAllOrigins) {
275 {
276 content::PaymentAppProvider::PaymentApps apps;
277 apps[0] = std::make_unique<content::StoredPaymentApp>();
278 apps[0]->scope = GURL("https://bobpay.com/webpay");
279 apps[0]->enabled_methods.push_back("https://frankpay.com/webpay");
280
281 Verify(std::move(apps));
282
283 EXPECT_EQ(1U, verified_apps().size());
284 ExpectApp(0, "https://bobpay.com/webpay", {"https://frankpay.com/webpay"});
285 }
286
287 // Repeat verifications should have identical results.
288 {
289 content::PaymentAppProvider::PaymentApps apps;
290 apps[0] = std::make_unique<content::StoredPaymentApp>();
291 apps[0]->scope = GURL("https://bobpay.com/webpay");
292 apps[0]->enabled_methods.push_back("https://frankpay.com/webpay");
293 Verify(std::move(apps));
294
295 EXPECT_EQ(1U, verified_apps().size());
296 ExpectApp(0, "https://bobpay.com/webpay", {"https://frankpay.com/webpay"});
297 }
298}
299
300// Verify that a payment handler from an unreachable website can use the payment
301// method name https://frankpay.com/webpay, because
302// https://frankpay.com/payment-manifest.json contains "supported_origins": "*".
303IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest,
304 Handler404CanUseMethodThatSupportsAllOrigins) {
305 {
306 content::PaymentAppProvider::PaymentApps apps;
307 apps[0] = std::make_unique<content::StoredPaymentApp>();
308 apps[0]->scope = GURL("https://404.com/webpay");
309 apps[0]->enabled_methods.push_back("https://frankpay.com/webpay");
310
311 Verify(std::move(apps));
312
313 EXPECT_EQ(1U, verified_apps().size());
314 ExpectApp(0, "https://404.com/webpay", {"https://frankpay.com/webpay"});
315 }
316
317 // Repeat verifications should have identical results.
318 {
319 content::PaymentAppProvider::PaymentApps apps;
320 apps[0] = std::make_unique<content::StoredPaymentApp>();
321 apps[0]->scope = GURL("https://404.com/webpay");
322 apps[0]->enabled_methods.push_back("https://frankpay.com/webpay");
323 Verify(std::move(apps));
324
325 EXPECT_EQ(1U, verified_apps().size());
326 ExpectApp(0, "https://404.com/webpay", {"https://frankpay.com/webpay"});
327 }
328}
329
330// Verify that a payment handler from anywhere on https://bobpay.com can use the
331// payment method name from anywhere else on https://bobpay.com, because of the
332// origin match.
333IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest,
334 BobPayCanUseAnyMethodOnOwnOrigin) {
335 {
336 content::PaymentAppProvider::PaymentApps apps;
337 apps[0] = std::make_unique<content::StoredPaymentApp>();
338 apps[0]->scope = GURL("https://bobpay.com/anything/here");
339 apps[0]->enabled_methods.push_back(
340 "https://bobpay.com/does/not/matter/whats/here");
341
342 Verify(std::move(apps));
343
344 EXPECT_EQ(1U, verified_apps().size());
345 ExpectApp(0, "https://bobpay.com/anything/here",
346 {"https://bobpay.com/does/not/matter/whats/here"});
347 }
348
349 // Repeat verifications should have identical results.
350 {
351 content::PaymentAppProvider::PaymentApps apps;
352 apps[0] = std::make_unique<content::StoredPaymentApp>();
353 apps[0]->scope = GURL("https://bobpay.com/anything/here");
354 apps[0]->enabled_methods.push_back(
355 "https://bobpay.com/does/not/matter/whats/here");
356 Verify(std::move(apps));
357
358 EXPECT_EQ(1U, verified_apps().size());
359 ExpectApp(0, "https://bobpay.com/anything/here",
360 {"https://bobpay.com/does/not/matter/whats/here"});
361 }
362}
363
364// Verify that a payment handler from anywhere on an unreachable website can use
365// the payment method name from anywhere else on the same unreachable website,
366// because they have identical origin.
367IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest,
368 Handler404CanUseAnyMethodOnOwnOrigin) {
369 {
370 content::PaymentAppProvider::PaymentApps apps;
371 apps[0] = std::make_unique<content::StoredPaymentApp>();
372 apps[0]->scope = GURL("https://404.com/anything/here");
373 apps[0]->enabled_methods.push_back(
374 "https://404.com/does/not/matter/whats/here");
375
376 Verify(std::move(apps));
377
378 EXPECT_EQ(1U, verified_apps().size());
379 ExpectApp(0, "https://404.com/anything/here",
380 {"https://404.com/does/not/matter/whats/here"});
381 }
382
383 // Repeat verifications should have identical results.
384 {
385 content::PaymentAppProvider::PaymentApps apps;
386 apps[0] = std::make_unique<content::StoredPaymentApp>();
387 apps[0]->scope = GURL("https://404.com/anything/here");
388 apps[0]->enabled_methods.push_back(
389 "https://404.com/does/not/matter/whats/here");
390 Verify(std::move(apps));
391
392 EXPECT_EQ(1U, verified_apps().size());
393 ExpectApp(0, "https://404.com/anything/here",
394 {"https://404.com/does/not/matter/whats/here"});
395 }
396}
397
398// Verify that only the payment handler from https://alicepay.com/webpay can use
399// payment methods https://georgepay.com/webpay and https://ikepay.com/webpay,
400// because both https://georgepay.com/payment-manifest.json and
401// https://ikepay.com/payment-manifest.json contain "supported_origins":
402// ["https://alicepay.com"]. The payment handler from https://bobpay.com/webpay
403// cannot use these payment methods, however.
404IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, OneSupportedOrigin) {
405 {
406 content::PaymentAppProvider::PaymentApps apps;
407 apps[0] = std::make_unique<content::StoredPaymentApp>();
408 apps[0]->scope = GURL("https://alicepay.com/webpay");
409 apps[0]->enabled_methods.push_back("https://georgepay.com/webpay");
410 apps[0]->enabled_methods.push_back("https://ikepay.com/webpay");
411 apps[1] = std::make_unique<content::StoredPaymentApp>();
412 apps[1]->scope = GURL("https://bobpay.com/webpay");
413 apps[1]->enabled_methods.push_back("https://georgepay.com/webpay");
414 apps[1]->enabled_methods.push_back("https://ikepay.com/webpay");
415
416 Verify(std::move(apps));
417
418 EXPECT_EQ(1U, verified_apps().size());
419 ExpectApp(0, "https://alicepay.com/webpay",
420 {"https://georgepay.com/webpay", "https://ikepay.com/webpay"});
421 }
422
423 // Repeat verifications should have identical results.
424 {
425 content::PaymentAppProvider::PaymentApps apps;
426 apps[0] = std::make_unique<content::StoredPaymentApp>();
427 apps[0]->scope = GURL("https://alicepay.com/webpay");
428 apps[0]->enabled_methods.push_back("https://georgepay.com/webpay");
429 apps[0]->enabled_methods.push_back("https://ikepay.com/webpay");
430 apps[1] = std::make_unique<content::StoredPaymentApp>();
431 apps[1]->scope = GURL("https://bobpay.com/webpay");
432 apps[1]->enabled_methods.push_back("https://georgepay.com/webpay");
433 apps[1]->enabled_methods.push_back("https://ikepay.com/webpay");
434
435 Verify(std::move(apps));
436
437 EXPECT_EQ(1U, verified_apps().size());
438 ExpectApp(0, "https://alicepay.com/webpay",
439 {"https://georgepay.com/webpay", "https://ikepay.com/webpay"});
440 }
441}
442
443// Verify that a payment handler from https://alicepay.com/webpay can use all
444// three of non-URL payment method name, same-origin URL payment method name,
445// and different-origin URL payment method name.
446IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, ThreeTypesOfMethods) {
447 {
448 content::PaymentAppProvider::PaymentApps apps;
449 apps[0] = std::make_unique<content::StoredPaymentApp>();
450 apps[0]->scope = GURL("https://alicepay.com/webpay");
451 apps[0]->enabled_methods.push_back("basic-card");
452 apps[0]->enabled_methods.push_back("https://alicepay.com/webpay2");
453 apps[0]->enabled_methods.push_back("https://ikepay.com/webpay");
454
455 Verify(std::move(apps));
456
457 EXPECT_EQ(1U, verified_apps().size());
458 ExpectApp(0, "https://alicepay.com/webpay",
459 {"basic-card", "https://alicepay.com/webpay2",
460 "https://ikepay.com/webpay"});
461 }
462
463 // Repeat verifications should have identical results.
464 {
465 content::PaymentAppProvider::PaymentApps apps;
466 apps[0] = std::make_unique<content::StoredPaymentApp>();
467 apps[0]->scope = GURL("https://alicepay.com/webpay");
468 apps[0]->enabled_methods.push_back("basic-card");
469 apps[0]->enabled_methods.push_back("https://alicepay.com/webpay2");
470 apps[0]->enabled_methods.push_back("https://ikepay.com/webpay");
471
472 Verify(std::move(apps));
473
474 EXPECT_EQ(1U, verified_apps().size());
475 ExpectApp(0, "https://alicepay.com/webpay",
476 {"basic-card", "https://alicepay.com/webpay2",
477 "https://ikepay.com/webpay"});
478 }
479}
480
481// Verify that a payment handler from https://bobpay.com/webpay cannot use
482// payment method names that are unreachable websites, the origin of which does
483// not match that of the payment handler.
484IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, PaymentMethodName404) {
485 {
486 content::PaymentAppProvider::PaymentApps apps;
487 apps[0] = std::make_unique<content::StoredPaymentApp>();
488 apps[0]->scope = GURL("https://bobpay.com/webpay");
489 apps[0]->enabled_methods.push_back("https://404.com/webpay");
490 apps[0]->enabled_methods.push_back("https://404aswell.com/webpay");
491
492 Verify(std::move(apps));
493
494 EXPECT_TRUE(verified_apps().empty());
495 }
496
497 // Repeat verifications should have identical results.
498 {
499 content::PaymentAppProvider::PaymentApps apps;
500 apps[0] = std::make_unique<content::StoredPaymentApp>();
501 apps[0]->scope = GURL("https://bobpay.com/webpay");
502 apps[0]->enabled_methods.push_back("https://404.com/webpay");
503 apps[0]->enabled_methods.push_back("https://404aswell.com/webpay");
504
505 Verify(std::move(apps));
506
507 EXPECT_TRUE(verified_apps().empty());
508 }
509}
510
511} // namespace
512} // namespace payments