| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "components/autofill/content/browser/wallet/wallet_service_url.h" | 6 #include "components/autofill/content/browser/wallet/wallet_service_url.h" |
| 7 #include "components/autofill/core/common/autofill_switches.h" | 7 #include "components/autofill/core/common/autofill_switches.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
| 10 | 10 |
| 11 namespace autofill { | 11 namespace autofill { |
| 12 namespace wallet { | 12 namespace wallet { |
| 13 | 13 |
| 14 TEST(WalletServiceUrl, CheckDefaultUrls) { | 14 TEST(WalletServiceUrl, CheckDefaultUrls) { |
| 15 #if defined(OS_MACOSX) |
| 16 // Default on Mac (for now) is to use sandbox servers. |
| 15 EXPECT_EQ("https://payments-form-dogfood.sandbox.google.com/online/v2/wallet/" | 17 EXPECT_EQ("https://payments-form-dogfood.sandbox.google.com/online/v2/wallet/" |
| 16 "autocheckout/v1/getWalletItemsJwtless", | 18 "autocheckout/v1/getWalletItemsJwtless", |
| 17 GetGetWalletItemsUrl().spec()); | 19 GetGetWalletItemsUrl().spec()); |
| 18 EXPECT_EQ("https://wallet-web.sandbox.google.com/online-secure/v2/" | 20 EXPECT_EQ("https://wallet-web.sandbox.google.com/online-secure/v2/" |
| 19 "autocheckout/v1/getFullWalletJwtless?s7e=otp", | 21 "autocheckout/v1/getFullWalletJwtless?s7e=otp", |
| 20 GetGetFullWalletUrl().spec()); | 22 GetGetFullWalletUrl().spec()); |
| 21 EXPECT_EQ("https://wallet-web.sandbox.google.com/manage/paymentMethods", | 23 EXPECT_EQ("https://wallet-web.sandbox.google.com/manage/paymentMethods", |
| 22 GetManageInstrumentsUrl().spec()); | 24 GetManageInstrumentsUrl().spec()); |
| 23 EXPECT_EQ("https://wallet-web.sandbox.google.com/manage/settings/addresses", | 25 EXPECT_EQ("https://wallet-web.sandbox.google.com/manage/settings/addresses", |
| 24 GetManageAddressesUrl().spec()); | 26 GetManageAddressesUrl().spec()); |
| 25 EXPECT_EQ("https://payments-form-dogfood.sandbox.google.com/online/v2/wallet/" | 27 EXPECT_EQ("https://payments-form-dogfood.sandbox.google.com/online/v2/wallet/" |
| 26 "autocheckout/v1/acceptLegalDocument", | 28 "autocheckout/v1/acceptLegalDocument", |
| 27 GetAcceptLegalDocumentsUrl().spec()); | 29 GetAcceptLegalDocumentsUrl().spec()); |
| 28 EXPECT_EQ("https://wallet-web.sandbox.google.com/online-secure/v2/" | 30 EXPECT_EQ("https://wallet-web.sandbox.google.com/online-secure/v2/" |
| 29 "autocheckout/v1/authenticateInstrument?s7e=cvn", | 31 "autocheckout/v1/authenticateInstrument?s7e=cvn", |
| 30 GetAuthenticateInstrumentUrl().spec()); | 32 GetAuthenticateInstrumentUrl().spec()); |
| 31 EXPECT_EQ("https://payments-form-dogfood.sandbox.google.com/online/v2/wallet/" | 33 EXPECT_EQ("https://payments-form-dogfood.sandbox.google.com/online/v2/wallet/" |
| 32 "autocheckout/v1/reportStatus", | 34 "autocheckout/v1/reportStatus", |
| 33 GetSendStatusUrl().spec()); | 35 GetSendStatusUrl().spec()); |
| 34 EXPECT_EQ("https://payments-form-dogfood.sandbox.google.com/online/v2/wallet/" | 36 EXPECT_EQ("https://payments-form-dogfood.sandbox.google.com/online/v2/wallet/" |
| 35 "autocheckout/v1/saveToWallet", | 37 "autocheckout/v1/saveToWallet", |
| 36 GetSaveToWalletNoEscrowUrl().spec()); | 38 GetSaveToWalletNoEscrowUrl().spec()); |
| 37 EXPECT_EQ("https://wallet-web.sandbox.google.com/online-secure/v2/" | 39 EXPECT_EQ("https://wallet-web.sandbox.google.com/online-secure/v2/" |
| 38 "autocheckout/v1/saveToWallet?s7e=card_number%3Bcvn", | 40 "autocheckout/v1/saveToWallet?s7e=card_number%3Bcvn", |
| 39 GetSaveToWalletUrl().spec()); | 41 GetSaveToWalletUrl().spec()); |
| 40 EXPECT_EQ("https://payments-form-dogfood.sandbox.google.com/online/v2/" | 42 EXPECT_EQ("https://payments-form-dogfood.sandbox.google.com/online/v2/" |
| 41 "passiveauth?isChromePayments=true", | 43 "passiveauth?isChromePayments=true", |
| 42 GetPassiveAuthUrl().spec()); | 44 GetPassiveAuthUrl().spec()); |
| 45 #else |
| 46 EXPECT_EQ("https://wallet.google.com/online/v2/wallet/" |
| 47 "autocheckout/v1/getWalletItemsJwtless", |
| 48 GetGetWalletItemsUrl().spec()); |
| 49 EXPECT_EQ("https://wallet.google.com/online-secure/v2/" |
| 50 "autocheckout/v1/getFullWalletJwtless?s7e=otp", |
| 51 GetGetFullWalletUrl().spec()); |
| 52 EXPECT_EQ("https://wallet.google.com/manage/paymentMethods", |
| 53 GetManageInstrumentsUrl().spec()); |
| 54 EXPECT_EQ("https://wallet.google.com/manage/settings/addresses", |
| 55 GetManageAddressesUrl().spec()); |
| 56 EXPECT_EQ("https://wallet.google.com/online/v2/wallet/" |
| 57 "autocheckout/v1/acceptLegalDocument", |
| 58 GetAcceptLegalDocumentsUrl().spec()); |
| 59 EXPECT_EQ("https://wallet.google.com/online-secure/v2/" |
| 60 "autocheckout/v1/authenticateInstrument?s7e=cvn", |
| 61 GetAuthenticateInstrumentUrl().spec()); |
| 62 EXPECT_EQ("https://wallet.google.com/online/v2/wallet/" |
| 63 "autocheckout/v1/reportStatus", |
| 64 GetSendStatusUrl().spec()); |
| 65 EXPECT_EQ("https://wallet.google.com/online/v2/wallet/" |
| 66 "autocheckout/v1/saveToWallet", |
| 67 GetSaveToWalletNoEscrowUrl().spec()); |
| 68 EXPECT_EQ("https://wallet.google.com/online-secure/v2/" |
| 69 "autocheckout/v1/saveToWallet?s7e=card_number%3Bcvn", |
| 70 GetSaveToWalletUrl().spec()); |
| 71 EXPECT_EQ("https://wallet.google.com/online/v2/" |
| 72 "passiveauth?isChromePayments=true", |
| 73 GetPassiveAuthUrl().spec()); |
| 74 #endif |
| 43 } | 75 } |
| 44 | 76 |
| 45 TEST(WalletServiceUrl, IsUsingProd) { | 77 TEST(WalletServiceUrl, IsUsingProd) { |
| 46 // The sandbox servers are the default (for now). Update if this changes. | 78 #if defined(OS_MACOSX) |
| 79 EXPECT_FALSE(IsUsingProd()); |
| 80 #else |
| 81 EXPECT_TRUE(IsUsingProd()); |
| 82 #endif |
| 83 |
| 84 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 85 command_line->AppendSwitchASCII(switches::kWalletServiceUseSandbox, "1"); |
| 47 EXPECT_FALSE(IsUsingProd()); | 86 EXPECT_FALSE(IsUsingProd()); |
| 48 | 87 |
| 49 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 88 const GURL sandbox_get_items_url = GetGetWalletItemsUrl(); |
| 50 command_line->AppendSwitch(switches::kWalletServiceUseProd); | 89 const GURL fake_service_url = GURL("http://goo.gl"); |
| 51 EXPECT_TRUE(IsUsingProd()); | 90 command_line->AppendSwitchASCII(switches::kWalletServiceUrl, |
| 91 fake_service_url.spec()); |
| 52 | 92 |
| 53 const GURL prod_get_items_url = GetGetWalletItemsUrl(); | 93 const GURL flag_get_items_url = GetGetWalletItemsUrl(); |
| 54 command_line->AppendSwitchASCII(switches::kWalletServiceUrl, "http://goo.gl"); | 94 ASSERT_NE(sandbox_get_items_url, flag_get_items_url); |
| 55 EXPECT_FALSE(IsUsingProd()); | 95 EXPECT_EQ(fake_service_url.GetOrigin(), flag_get_items_url.GetOrigin()); |
| 56 | |
| 57 ASSERT_NE(prod_get_items_url, GetGetWalletItemsUrl()); | |
| 58 } | 96 } |
| 59 | 97 |
| 60 } // namespace wallet | 98 } // namespace wallet |
| 61 } // namespace autofill | 99 } // namespace autofill |
| OLD | NEW |