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