Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "components/payments/content/manifest_verifier.h" |
| 6 | |
| 7 | #include <stdint.h> |
| 8 | #include <utility> |
| 9 | |
Sebastien Marchand | f1349f5 | 2019-01-25 03:16:41 | [diff] [blame] | 10 | #include "base/bind.h" |
Rouslan Solomakhin | 438d8c9 | 2017-10-26 21:33:18 | [diff] [blame] | 11 | #include "base/run_loop.h" |
| 12 | #include "chrome/browser/profiles/profile.h" |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 13 | #include "chrome/browser/ui/browser.h" |
| 14 | #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 15 | #include "chrome/browser/web_data_service_factory.h" |
| 16 | #include "chrome/test/base/in_process_browser_test.h" |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 17 | #include "components/payments/content/payment_manifest_web_data_service.h" |
Jay Civelli | a7d22b4 | 2017-10-24 18:38:07 | [diff] [blame] | 18 | #include "components/payments/content/utility/payment_manifest_parser.h" |
Rouslan Solomakhin | 438d8c9 | 2017-10-26 21:33:18 | [diff] [blame] | 19 | #include "components/payments/core/test_payment_manifest_downloader.h" |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 20 | #include "content/public/browser/browser_context.h" |
| 21 | #include "content/public/browser/storage_partition.h" |
| 22 | #include "net/test/embedded_test_server/embedded_test_server.h" |
| 23 | #include "net/url_request/url_request_context_getter.h" |
| 24 | #include "testing/gtest/include/gtest/gtest.h" |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 25 | #include "third_party/re2/src/re2/re2.h" |
Rouslan Solomakhin | c71cca62 | 2020-01-31 22:15:35 | [diff] [blame] | 26 | #include "url/origin.h" |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 27 | |
| 28 | namespace payments { |
| 29 | namespace { |
| 30 | |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 31 | // Tests for the manifest verifier. |
| 32 | class ManifestVerifierBrowserTest : public InProcessBrowserTest { |
| 33 | public: |
| 34 | ManifestVerifierBrowserTest() {} |
| 35 | ~ManifestVerifierBrowserTest() override {} |
| 36 | |
| 37 | // Starts the HTTPS test server on localhost. |
| 38 | void SetUpOnMainThread() override { |
| 39 | https_server_ = std::make_unique<net::EmbeddedTestServer>( |
| 40 | net::EmbeddedTestServer::TYPE_HTTPS); |
| 41 | ASSERT_TRUE(https_server_->InitializeAndListen()); |
| 42 | https_server_->ServeFilesFromSourceDirectory( |
| 43 | "components/test/data/payments"); |
| 44 | https_server_->StartAcceptingConnections(); |
| 45 | } |
| 46 | |
| 47 | // Runs the verifier on the |apps| and blocks until the verifier has finished |
| 48 | // using all resources. |
| 49 | void Verify(content::PaymentAppProvider::PaymentApps apps) { |
Rouslan Solomakhin | dbf593d9 | 2017-11-21 19:20:57 | [diff] [blame] | 50 | content::WebContents* web_contents = |
| 51 | browser()->tab_strip_model()->GetActiveWebContents(); |
| 52 | content::BrowserContext* context = web_contents->GetBrowserContext(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 53 | auto downloader = std::make_unique<TestDownloader>( |
Rouslan Solomakhin | 438d8c9 | 2017-10-26 21:33:18 | [diff] [blame] | 54 | content::BrowserContext::GetDefaultStoragePartition(context) |
John Abd-El-Malek | aef36cb | 2018-06-26 17:18:23 | [diff] [blame] | 55 | ->GetURLLoaderFactoryForBrowserProcess()); |
Rouslan Solomakhin | 438d8c9 | 2017-10-26 21:33:18 | [diff] [blame] | 56 | downloader->AddTestServerURL("https://", https_server_->GetURL("/")); |
Rouslan Solomakhin | e253721 | 2018-11-14 17:07:29 | [diff] [blame] | 57 | auto parser = std::make_unique<payments::PaymentManifestParser>( |
| 58 | std::make_unique<ErrorLogger>()); |
gogerald | 84ae626 | 2018-02-06 06:21:46 | [diff] [blame] | 59 | auto cache = WebDataServiceFactory::GetPaymentManifestWebDataForProfile( |
| 60 | Profile::FromBrowserContext(context), |
| 61 | ServiceAccessType::EXPLICIT_ACCESS); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 62 | |
Rouslan Solomakhin | c71cca62 | 2020-01-31 22:15:35 | [diff] [blame] | 63 | ManifestVerifier verifier(url::Origin::Create(GURL("https://chromium.org")), |
| 64 | web_contents, downloader.get(), parser.get(), |
gogerald | 84ae626 | 2018-02-06 06:21:46 | [diff] [blame] | 65 | cache.get()); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 66 | |
| 67 | base::RunLoop run_loop; |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 68 | verifier.Verify( |
| 69 | std::move(apps), |
| 70 | base::BindOnce(&ManifestVerifierBrowserTest::OnPaymentAppsVerified, |
| 71 | base::Unretained(this)), |
Rouslan Solomakhin | 438d8c9 | 2017-10-26 21:33:18 | [diff] [blame] | 72 | run_loop.QuitClosure()); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 73 | run_loop.Run(); |
| 74 | } |
| 75 | |
| 76 | // Returns the apps that have been verified by the Verify() method. |
| 77 | const content::PaymentAppProvider::PaymentApps& verified_apps() const { |
| 78 | return verified_apps_; |
| 79 | } |
| 80 | |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 81 | const std::string& error_message() const { return error_message_; } |
| 82 | |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 83 | // Expects that the verified payment app with |id| has the |expected_scope| |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 84 | // and the |expected_methods| and the |
| 85 | // |expect_has_explicitly_verified_methods|. |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 86 | void ExpectApp(int64_t id, |
| 87 | const std::string& expected_scope, |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 88 | const std::set<std::string>& expected_methods, |
| 89 | bool expect_has_explicitly_verified_methods) { |
Rouslan Solomakhin | 478d93e3 | 2017-10-27 17:06:37 | [diff] [blame] | 90 | const auto& it = verified_apps().find(id); |
| 91 | ASSERT_NE(verified_apps().end(), it); |
| 92 | EXPECT_EQ(GURL(expected_scope), it->second->scope); |
| 93 | std::set<std::string> actual_methods(it->second->enabled_methods.begin(), |
| 94 | it->second->enabled_methods.end()); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 95 | EXPECT_EQ(expected_methods, actual_methods); |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 96 | EXPECT_EQ(expect_has_explicitly_verified_methods, |
| 97 | it->second->has_explicitly_verified_methods); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 98 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | private: |
| 102 | // Called by the verifier upon completed verification. These |apps| have only |
| 103 | // valid payment methods. |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 104 | void OnPaymentAppsVerified(content::PaymentAppProvider::PaymentApps apps, |
| 105 | const std::string& error_message) { |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 106 | verified_apps_ = std::move(apps); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 107 | error_message_ = error_message; |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 108 | } |
| 109 | |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 110 | // Serves the payment method manifest files. |
| 111 | std::unique_ptr<net::EmbeddedTestServer> https_server_; |
| 112 | |
| 113 | // The apps that have been verified by the Verify() method. |
| 114 | content::PaymentAppProvider::PaymentApps verified_apps_; |
| 115 | |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 116 | std::string error_message_; |
| 117 | |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 118 | DISALLOW_COPY_AND_ASSIGN(ManifestVerifierBrowserTest); |
| 119 | }; |
| 120 | |
| 121 | // Absence of payment handlers should result in absence of verified payment |
| 122 | // handlers. |
| 123 | IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, NoApps) { |
| 124 | { |
| 125 | Verify(content::PaymentAppProvider::PaymentApps()); |
| 126 | |
| 127 | EXPECT_TRUE(verified_apps().empty()); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 128 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | // Repeat verifications should have identical results. |
| 132 | { |
| 133 | Verify(content::PaymentAppProvider::PaymentApps()); |
| 134 | |
| 135 | EXPECT_TRUE(verified_apps().empty()); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 136 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 137 | } |
| 138 | } |
| 139 | |
| 140 | // A payment handler without any payment method names is not valid. |
| 141 | IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, NoMethods) { |
| 142 | { |
| 143 | content::PaymentAppProvider::PaymentApps apps; |
| 144 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 145 | apps[0]->scope = GURL("https://bobpay.com/webpay"); |
| 146 | |
| 147 | Verify(std::move(apps)); |
| 148 | |
| 149 | EXPECT_TRUE(verified_apps().empty()); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 150 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | // Repeat verifications should have identical results. |
| 154 | { |
| 155 | content::PaymentAppProvider::PaymentApps apps; |
| 156 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 157 | apps[0]->scope = GURL("https://bobpay.com/webpay"); |
| 158 | |
| 159 | Verify(std::move(apps)); |
| 160 | |
| 161 | EXPECT_TRUE(verified_apps().empty()); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 162 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 163 | } |
| 164 | } |
| 165 | |
| 166 | // A payment handler with an unknown non-URL payment method name is not valid. |
| 167 | IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, |
| 168 | UnknownPaymentMethodNameIsRemoved) { |
| 169 | { |
| 170 | content::PaymentAppProvider::PaymentApps apps; |
| 171 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 172 | apps[0]->scope = GURL("https://bobpay.com/webpay"); |
| 173 | apps[0]->enabled_methods.push_back("unknown"); |
| 174 | |
| 175 | Verify(std::move(apps)); |
| 176 | |
| 177 | EXPECT_TRUE(verified_apps().empty()); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 178 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | // Repeat verifications should have identical results. |
| 182 | { |
| 183 | content::PaymentAppProvider::PaymentApps apps; |
| 184 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 185 | apps[0]->scope = GURL("https://bobpay.com/webpay"); |
| 186 | apps[0]->enabled_methods.push_back("unknown"); |
| 187 | |
| 188 | Verify(std::move(apps)); |
| 189 | |
| 190 | EXPECT_TRUE(verified_apps().empty()); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 191 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 192 | } |
| 193 | } |
| 194 | |
| 195 | // A payment handler with "basic-card" payment method name is valid. |
| 196 | IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, KnownPaymentMethodName) { |
| 197 | { |
| 198 | content::PaymentAppProvider::PaymentApps apps; |
| 199 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 200 | apps[0]->scope = GURL("https://bobpay.com/webpay"); |
| 201 | apps[0]->enabled_methods.push_back("basic-card"); |
| 202 | |
| 203 | Verify(std::move(apps)); |
| 204 | |
| 205 | EXPECT_EQ(1U, verified_apps().size()); |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 206 | ExpectApp(0, "https://bobpay.com/webpay", {"basic-card"}, false); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 207 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | // Repeat verifications should have identical results. |
| 211 | { |
| 212 | content::PaymentAppProvider::PaymentApps apps; |
| 213 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 214 | apps[0]->scope = GURL("https://bobpay.com/webpay"); |
| 215 | apps[0]->enabled_methods.push_back("basic-card"); |
| 216 | |
| 217 | Verify(std::move(apps)); |
| 218 | |
| 219 | EXPECT_EQ(1U, verified_apps().size()); |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 220 | ExpectApp(0, "https://bobpay.com/webpay", {"basic-card"}, false); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 221 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 222 | } |
| 223 | } |
| 224 | |
| 225 | // A payment handler with both "basic-card" and "interledger" payment method |
| 226 | // names is valid. |
| 227 | IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, |
| 228 | TwoKnownPaymentMethodNames) { |
| 229 | { |
| 230 | content::PaymentAppProvider::PaymentApps apps; |
| 231 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 232 | apps[0]->scope = GURL("https://bobpay.com/webpay"); |
| 233 | apps[0]->enabled_methods.push_back("basic-card"); |
| 234 | apps[0]->enabled_methods.push_back("interledger"); |
| 235 | |
| 236 | Verify(std::move(apps)); |
| 237 | |
| 238 | EXPECT_EQ(1U, verified_apps().size()); |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 239 | ExpectApp(0, "https://bobpay.com/webpay", {"basic-card", "interledger"}, |
| 240 | false); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 241 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | // Repeat verifications should have identical results. |
| 245 | { |
| 246 | content::PaymentAppProvider::PaymentApps apps; |
| 247 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 248 | apps[0]->scope = GURL("https://bobpay.com/webpay"); |
| 249 | apps[0]->enabled_methods.push_back("basic-card"); |
| 250 | apps[0]->enabled_methods.push_back("interledger"); |
| 251 | |
| 252 | Verify(std::move(apps)); |
| 253 | |
| 254 | EXPECT_EQ(1U, verified_apps().size()); |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 255 | ExpectApp(0, "https://bobpay.com/webpay", {"basic-card", "interledger"}, |
| 256 | false); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 257 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 258 | } |
| 259 | } |
| 260 | |
| 261 | // Two payment handlers with "basic-card" payment method names are both valid. |
| 262 | IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, |
| 263 | TwoAppsWithKnownPaymentMethodNames) { |
| 264 | { |
| 265 | content::PaymentAppProvider::PaymentApps apps; |
| 266 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 267 | apps[0]->scope = GURL("https://bobpay.com/webpay"); |
| 268 | apps[0]->enabled_methods.push_back("basic-card"); |
| 269 | apps[1] = std::make_unique<content::StoredPaymentApp>(); |
| 270 | apps[1]->scope = GURL("https://alicepay.com/webpay"); |
| 271 | apps[1]->enabled_methods.push_back("basic-card"); |
| 272 | |
| 273 | Verify(std::move(apps)); |
| 274 | |
| 275 | EXPECT_EQ(2U, verified_apps().size()); |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 276 | ExpectApp(0, "https://bobpay.com/webpay", {"basic-card"}, false); |
| 277 | ExpectApp(1, "https://alicepay.com/webpay", {"basic-card"}, false); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 278 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | // Repeat verifications should have identical results. |
| 282 | { |
| 283 | content::PaymentAppProvider::PaymentApps apps; |
| 284 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 285 | apps[0]->scope = GURL("https://bobpay.com/webpay"); |
| 286 | apps[0]->enabled_methods.push_back("basic-card"); |
| 287 | apps[1] = std::make_unique<content::StoredPaymentApp>(); |
| 288 | apps[1]->scope = GURL("https://alicepay.com/webpay"); |
| 289 | apps[1]->enabled_methods.push_back("basic-card"); |
| 290 | Verify(std::move(apps)); |
| 291 | |
| 292 | EXPECT_EQ(2U, verified_apps().size()); |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 293 | ExpectApp(0, "https://bobpay.com/webpay", {"basic-card"}, false); |
| 294 | ExpectApp(1, "https://alicepay.com/webpay", {"basic-card"}, false); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 295 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 296 | } |
| 297 | } |
| 298 | |
| 299 | // Verify that a payment handler from https://bobpay.com/webpay can use the |
| 300 | // payment method name https://frankpay.com/webpay, because |
| 301 | // https://frankpay.com/payment-manifest.json contains "supported_origins": "*". |
| 302 | IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, |
| 303 | BobPayHandlerCanUseMethodThatSupportsAllOrigins) { |
| 304 | { |
| 305 | content::PaymentAppProvider::PaymentApps apps; |
| 306 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 307 | apps[0]->scope = GURL("https://bobpay.com/webpay"); |
| 308 | apps[0]->enabled_methods.push_back("https://frankpay.com/webpay"); |
| 309 | |
| 310 | Verify(std::move(apps)); |
| 311 | |
| 312 | EXPECT_EQ(1U, verified_apps().size()); |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 313 | ExpectApp(0, "https://bobpay.com/webpay", {"https://frankpay.com/webpay"}, |
| 314 | false); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 315 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | // Repeat verifications should have identical results. |
| 319 | { |
| 320 | content::PaymentAppProvider::PaymentApps apps; |
| 321 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 322 | apps[0]->scope = GURL("https://bobpay.com/webpay"); |
| 323 | apps[0]->enabled_methods.push_back("https://frankpay.com/webpay"); |
| 324 | Verify(std::move(apps)); |
| 325 | |
| 326 | EXPECT_EQ(1U, verified_apps().size()); |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 327 | ExpectApp(0, "https://bobpay.com/webpay", {"https://frankpay.com/webpay"}, |
| 328 | false); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 329 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 330 | } |
| 331 | } |
| 332 | |
| 333 | // Verify that a payment handler from an unreachable website can use the payment |
| 334 | // method name https://frankpay.com/webpay, because |
| 335 | // https://frankpay.com/payment-manifest.json contains "supported_origins": "*". |
| 336 | IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, |
| 337 | Handler404CanUseMethodThatSupportsAllOrigins) { |
| 338 | { |
| 339 | content::PaymentAppProvider::PaymentApps apps; |
| 340 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 341 | apps[0]->scope = GURL("https://404.com/webpay"); |
| 342 | apps[0]->enabled_methods.push_back("https://frankpay.com/webpay"); |
| 343 | |
| 344 | Verify(std::move(apps)); |
| 345 | |
| 346 | EXPECT_EQ(1U, verified_apps().size()); |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 347 | ExpectApp(0, "https://404.com/webpay", {"https://frankpay.com/webpay"}, |
| 348 | false); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 349 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | // Repeat verifications should have identical results. |
| 353 | { |
| 354 | content::PaymentAppProvider::PaymentApps apps; |
| 355 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 356 | apps[0]->scope = GURL("https://404.com/webpay"); |
| 357 | apps[0]->enabled_methods.push_back("https://frankpay.com/webpay"); |
| 358 | Verify(std::move(apps)); |
| 359 | |
| 360 | EXPECT_EQ(1U, verified_apps().size()); |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 361 | ExpectApp(0, "https://404.com/webpay", {"https://frankpay.com/webpay"}, |
| 362 | false); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 363 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 364 | } |
| 365 | } |
| 366 | |
| 367 | // Verify that a payment handler from anywhere on https://bobpay.com can use the |
| 368 | // payment method name from anywhere else on https://bobpay.com, because of the |
| 369 | // origin match. |
| 370 | IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, |
| 371 | BobPayCanUseAnyMethodOnOwnOrigin) { |
| 372 | { |
| 373 | content::PaymentAppProvider::PaymentApps apps; |
| 374 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 375 | apps[0]->scope = GURL("https://bobpay.com/anything/here"); |
| 376 | apps[0]->enabled_methods.push_back( |
| 377 | "https://bobpay.com/does/not/matter/whats/here"); |
| 378 | |
| 379 | Verify(std::move(apps)); |
| 380 | |
| 381 | EXPECT_EQ(1U, verified_apps().size()); |
| 382 | ExpectApp(0, "https://bobpay.com/anything/here", |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 383 | {"https://bobpay.com/does/not/matter/whats/here"}, true); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 384 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | // Repeat verifications should have identical results. |
| 388 | { |
| 389 | content::PaymentAppProvider::PaymentApps apps; |
| 390 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 391 | apps[0]->scope = GURL("https://bobpay.com/anything/here"); |
| 392 | apps[0]->enabled_methods.push_back( |
| 393 | "https://bobpay.com/does/not/matter/whats/here"); |
| 394 | Verify(std::move(apps)); |
| 395 | |
| 396 | EXPECT_EQ(1U, verified_apps().size()); |
| 397 | ExpectApp(0, "https://bobpay.com/anything/here", |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 398 | {"https://bobpay.com/does/not/matter/whats/here"}, true); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 399 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 400 | } |
| 401 | } |
| 402 | |
| 403 | // Verify that a payment handler from anywhere on an unreachable website can use |
| 404 | // the payment method name from anywhere else on the same unreachable website, |
| 405 | // because they have identical origin. |
| 406 | IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, |
| 407 | Handler404CanUseAnyMethodOnOwnOrigin) { |
| 408 | { |
| 409 | content::PaymentAppProvider::PaymentApps apps; |
| 410 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 411 | apps[0]->scope = GURL("https://404.com/anything/here"); |
| 412 | apps[0]->enabled_methods.push_back( |
| 413 | "https://404.com/does/not/matter/whats/here"); |
| 414 | |
| 415 | Verify(std::move(apps)); |
| 416 | |
| 417 | EXPECT_EQ(1U, verified_apps().size()); |
| 418 | ExpectApp(0, "https://404.com/anything/here", |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 419 | {"https://404.com/does/not/matter/whats/here"}, true); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 420 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 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://404.com/anything/here"); |
| 428 | apps[0]->enabled_methods.push_back( |
| 429 | "https://404.com/does/not/matter/whats/here"); |
| 430 | Verify(std::move(apps)); |
| 431 | |
| 432 | EXPECT_EQ(1U, verified_apps().size()); |
| 433 | ExpectApp(0, "https://404.com/anything/here", |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 434 | {"https://404.com/does/not/matter/whats/here"}, true); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 435 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 436 | } |
| 437 | } |
| 438 | |
| 439 | // Verify that only the payment handler from https://alicepay.com/webpay can use |
| 440 | // payment methods https://georgepay.com/webpay and https://ikepay.com/webpay, |
| 441 | // because both https://georgepay.com/payment-manifest.json and |
| 442 | // https://ikepay.com/payment-manifest.json contain "supported_origins": |
| 443 | // ["https://alicepay.com"]. The payment handler from https://bobpay.com/webpay |
| 444 | // cannot use these payment methods, however. |
| 445 | IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, OneSupportedOrigin) { |
| 446 | { |
| 447 | content::PaymentAppProvider::PaymentApps apps; |
| 448 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 449 | apps[0]->scope = GURL("https://alicepay.com/webpay"); |
| 450 | apps[0]->enabled_methods.push_back("https://georgepay.com/webpay"); |
| 451 | apps[0]->enabled_methods.push_back("https://ikepay.com/webpay"); |
| 452 | apps[1] = std::make_unique<content::StoredPaymentApp>(); |
| 453 | apps[1]->scope = GURL("https://bobpay.com/webpay"); |
| 454 | apps[1]->enabled_methods.push_back("https://georgepay.com/webpay"); |
| 455 | apps[1]->enabled_methods.push_back("https://ikepay.com/webpay"); |
| 456 | |
| 457 | Verify(std::move(apps)); |
| 458 | |
| 459 | EXPECT_EQ(1U, verified_apps().size()); |
| 460 | ExpectApp(0, "https://alicepay.com/webpay", |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 461 | {"https://georgepay.com/webpay", "https://ikepay.com/webpay"}, |
| 462 | true); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 463 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | // Repeat verifications should have identical results. |
| 467 | { |
| 468 | content::PaymentAppProvider::PaymentApps apps; |
| 469 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 470 | apps[0]->scope = GURL("https://alicepay.com/webpay"); |
| 471 | apps[0]->enabled_methods.push_back("https://georgepay.com/webpay"); |
| 472 | apps[0]->enabled_methods.push_back("https://ikepay.com/webpay"); |
| 473 | apps[1] = std::make_unique<content::StoredPaymentApp>(); |
| 474 | apps[1]->scope = GURL("https://bobpay.com/webpay"); |
| 475 | apps[1]->enabled_methods.push_back("https://georgepay.com/webpay"); |
| 476 | apps[1]->enabled_methods.push_back("https://ikepay.com/webpay"); |
| 477 | |
| 478 | Verify(std::move(apps)); |
| 479 | |
| 480 | EXPECT_EQ(1U, verified_apps().size()); |
| 481 | ExpectApp(0, "https://alicepay.com/webpay", |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 482 | {"https://georgepay.com/webpay", "https://ikepay.com/webpay"}, |
| 483 | true); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 484 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 485 | } |
| 486 | } |
| 487 | |
| 488 | // Verify that a payment handler from https://alicepay.com/webpay can use all |
| 489 | // three of non-URL payment method name, same-origin URL payment method name, |
| 490 | // and different-origin URL payment method name. |
| 491 | IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, ThreeTypesOfMethods) { |
| 492 | { |
| 493 | content::PaymentAppProvider::PaymentApps apps; |
| 494 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 495 | apps[0]->scope = GURL("https://alicepay.com/webpay"); |
| 496 | apps[0]->enabled_methods.push_back("basic-card"); |
| 497 | apps[0]->enabled_methods.push_back("https://alicepay.com/webpay2"); |
| 498 | apps[0]->enabled_methods.push_back("https://ikepay.com/webpay"); |
| 499 | |
| 500 | Verify(std::move(apps)); |
| 501 | |
| 502 | EXPECT_EQ(1U, verified_apps().size()); |
| 503 | ExpectApp(0, "https://alicepay.com/webpay", |
| 504 | {"basic-card", "https://alicepay.com/webpay2", |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 505 | "https://ikepay.com/webpay"}, |
| 506 | true); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 507 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | // Repeat verifications should have identical results. |
| 511 | { |
| 512 | content::PaymentAppProvider::PaymentApps apps; |
| 513 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 514 | apps[0]->scope = GURL("https://alicepay.com/webpay"); |
| 515 | apps[0]->enabled_methods.push_back("basic-card"); |
| 516 | apps[0]->enabled_methods.push_back("https://alicepay.com/webpay2"); |
| 517 | apps[0]->enabled_methods.push_back("https://ikepay.com/webpay"); |
| 518 | |
| 519 | Verify(std::move(apps)); |
| 520 | |
| 521 | EXPECT_EQ(1U, verified_apps().size()); |
| 522 | ExpectApp(0, "https://alicepay.com/webpay", |
| 523 | {"basic-card", "https://alicepay.com/webpay2", |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 524 | "https://ikepay.com/webpay"}, |
| 525 | true); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 526 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 527 | } |
| 528 | } |
| 529 | |
| 530 | // Verify that a payment handler from https://bobpay.com/webpay cannot use |
| 531 | // payment method names that are unreachable websites, the origin of which does |
| 532 | // not match that of the payment handler. |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 533 | IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, |
| 534 | SinglePaymentMethodName404) { |
| 535 | std::string expected_pattern = |
| 536 | "Unable to make a HEAD request to " |
| 537 | "\"https://127.0.0.1:\\d+/404.test/webpay\" for payment method manifest."; |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 538 | { |
| 539 | content::PaymentAppProvider::PaymentApps apps; |
| 540 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 541 | apps[0]->scope = GURL("https://bobpay.test/webpay"); |
| 542 | apps[0]->enabled_methods.push_back("https://404.test/webpay"); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 543 | |
| 544 | Verify(std::move(apps)); |
| 545 | |
| 546 | EXPECT_TRUE(verified_apps().empty()); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 547 | EXPECT_TRUE(RE2::FullMatch(error_message(), expected_pattern)) |
| 548 | << "Actual error message \"" << error_message() |
| 549 | << "\" did not match expected pattern \"" << expected_pattern << "\"."; |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | // Repeat verifications should have identical results. |
| 553 | { |
| 554 | content::PaymentAppProvider::PaymentApps apps; |
| 555 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 556 | apps[0]->scope = GURL("https://bobpay.test/webpay"); |
| 557 | apps[0]->enabled_methods.push_back("https://404.test/webpay"); |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 558 | |
| 559 | Verify(std::move(apps)); |
| 560 | |
| 561 | EXPECT_TRUE(verified_apps().empty()); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 562 | EXPECT_TRUE(RE2::FullMatch(error_message(), expected_pattern)) |
| 563 | << "Actual error message \"" << error_message() |
| 564 | << "\" did not match expected pattern \"" << expected_pattern << "\"."; |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | // Verify that a payment handler from https://bobpay.com/webpay cannot use |
| 569 | // payment method names that are unreachable websites, the origin of which does |
| 570 | // not match that of the payment handler. Since multiple downloads fail, the |
| 571 | // error message will describe the first failure. |
| 572 | IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, |
| 573 | MultiplePaymentMethodName404) { |
| 574 | std::string expected_pattern = |
| 575 | "Unable to make a HEAD request to " |
| 576 | "\"https://127.0.0.1:\\d+/404(aswell)?.test/webpay\" for payment method " |
| 577 | "manifest."; |
| 578 | { |
| 579 | content::PaymentAppProvider::PaymentApps apps; |
| 580 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 581 | apps[0]->scope = GURL("https://bobpay.test/webpay"); |
| 582 | apps[0]->enabled_methods.push_back("https://404.test/webpay"); |
| 583 | apps[0]->enabled_methods.push_back("https://404aswell.test/webpay"); |
| 584 | |
| 585 | Verify(std::move(apps)); |
| 586 | |
| 587 | EXPECT_TRUE(verified_apps().empty()); |
| 588 | EXPECT_TRUE(RE2::FullMatch(error_message(), expected_pattern)) |
| 589 | << "Actual error message \"" << error_message() |
| 590 | << "\" did not match expected pattern \"" << expected_pattern << "\"."; |
| 591 | } |
| 592 | |
| 593 | // Repeat verifications should have identical results. |
| 594 | { |
| 595 | content::PaymentAppProvider::PaymentApps apps; |
| 596 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 597 | apps[0]->scope = GURL("https://bobpay.test/webpay"); |
| 598 | apps[0]->enabled_methods.push_back("https://404.test/webpay"); |
| 599 | apps[0]->enabled_methods.push_back("https://404aswell.test/webpay"); |
| 600 | |
| 601 | Verify(std::move(apps)); |
| 602 | |
| 603 | EXPECT_TRUE(verified_apps().empty()); |
| 604 | EXPECT_TRUE(RE2::FullMatch(error_message(), expected_pattern)) |
| 605 | << "Actual error message \"" << error_message() |
| 606 | << "\" did not match expected pattern \"" << expected_pattern << "\"."; |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 607 | } |
| 608 | } |
| 609 | |
Rouslan Solomakhin | 478d93e3 | 2017-10-27 17:06:37 | [diff] [blame] | 610 | // All known payment method names are valid. |
| 611 | IN_PROC_BROWSER_TEST_F(ManifestVerifierBrowserTest, |
| 612 | AllKnownPaymentMethodNames) { |
| 613 | { |
| 614 | content::PaymentAppProvider::PaymentApps apps; |
| 615 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 616 | apps[0]->scope = GURL("https://bobpay.com/webpay"); |
| 617 | apps[0]->enabled_methods.push_back("basic-card"); |
| 618 | apps[0]->enabled_methods.push_back("interledger"); |
| 619 | apps[0]->enabled_methods.push_back("payee-credit-transfer"); |
| 620 | apps[0]->enabled_methods.push_back("payer-credit-transfer"); |
Rouslan Solomakhin | 901a184 | 2018-07-30 22:25:37 | [diff] [blame] | 621 | apps[0]->enabled_methods.push_back("tokenized-card"); |
Rouslan Solomakhin | 478d93e3 | 2017-10-27 17:06:37 | [diff] [blame] | 622 | apps[0]->enabled_methods.push_back("not-supported"); |
| 623 | |
| 624 | Verify(std::move(apps)); |
| 625 | |
| 626 | EXPECT_EQ(1U, verified_apps().size()); |
| 627 | ExpectApp(0, "https://bobpay.com/webpay", |
| 628 | {"basic-card", "interledger", "payee-credit-transfer", |
Rouslan Solomakhin | 901a184 | 2018-07-30 22:25:37 | [diff] [blame] | 629 | "payer-credit-transfer", "tokenized-card"}, |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 630 | false); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 631 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | 478d93e3 | 2017-10-27 17:06:37 | [diff] [blame] | 632 | } |
| 633 | |
| 634 | // Repeat verifications should have identical results. |
| 635 | { |
| 636 | content::PaymentAppProvider::PaymentApps apps; |
| 637 | apps[0] = std::make_unique<content::StoredPaymentApp>(); |
| 638 | apps[0]->scope = GURL("https://bobpay.com/webpay"); |
| 639 | apps[0]->enabled_methods.push_back("basic-card"); |
| 640 | apps[0]->enabled_methods.push_back("interledger"); |
| 641 | apps[0]->enabled_methods.push_back("payee-credit-transfer"); |
| 642 | apps[0]->enabled_methods.push_back("payer-credit-transfer"); |
Rouslan Solomakhin | 901a184 | 2018-07-30 22:25:37 | [diff] [blame] | 643 | apps[0]->enabled_methods.push_back("tokenized-card"); |
Rouslan Solomakhin | 478d93e3 | 2017-10-27 17:06:37 | [diff] [blame] | 644 | apps[0]->enabled_methods.push_back("not-supported"); |
| 645 | |
| 646 | Verify(std::move(apps)); |
| 647 | |
| 648 | EXPECT_EQ(1U, verified_apps().size()); |
| 649 | ExpectApp(0, "https://bobpay.com/webpay", |
| 650 | {"basic-card", "interledger", "payee-credit-transfer", |
Rouslan Solomakhin | 901a184 | 2018-07-30 22:25:37 | [diff] [blame] | 651 | "payer-credit-transfer", "tokenized-card"}, |
gogerald | a74f9dec | 2018-04-10 00:33:47 | [diff] [blame] | 652 | false); |
Rouslan Solomakhin | d5dcc32 | 2019-07-11 21:47:20 | [diff] [blame] | 653 | EXPECT_TRUE(error_message().empty()) << error_message(); |
Rouslan Solomakhin | 478d93e3 | 2017-10-27 17:06:37 | [diff] [blame] | 654 | } |
| 655 | } |
| 656 | |
Rouslan Solomakhin | de01253 | 2017-09-20 15:18:34 | [diff] [blame] | 657 | } // namespace |
| 658 | } // namespace payments |