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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "components/autofill/content/browser/wallet/wallet_service_url.h"
7 #include "components/autofill/core/common/autofill_switches.h"
8 #include "testing/gtest/include/gtest/gtest.h"
14 TEST(WalletServiceSandboxUrl, CheckSandboxUrls) {
15 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
16 switches::kWalletServiceUseSandbox, "1");
18 EXPECT_EQ("https://wallet-web.sandbox.google.com/online/v2/u/1/wallet/"
19 "autocheckout/v1/getWalletItemsJwtless",
20 GetGetWalletItemsUrl(1).spec());
21 EXPECT_EQ("https://wallet-web.sandbox.google.com/online-secure/v2/u/1/"
22 "autocheckout/v1/getFullWalletJwtless?s7e=otp",
23 GetGetFullWalletUrl(1).spec());
24 EXPECT_EQ("https://wallet-web.sandbox.google.com/manage/w/1/paymentMethods",
25 GetManageInstrumentsUrl(1).spec());
26 EXPECT_EQ("https://wallet-web.sandbox.google.com/manage/w/1/settings/"
28 GetManageAddressesUrl(1).spec());
29 EXPECT_EQ("https://wallet-web.sandbox.google.com/online/v2/u/1/wallet/"
30 "autocheckout/v1/acceptLegalDocument",
31 GetAcceptLegalDocumentsUrl(1).spec());
32 EXPECT_EQ("https://wallet-web.sandbox.google.com/online-secure/v2/u/2/"
33 "autocheckout/v1/authenticateInstrument?s7e=cvn",
34 GetAuthenticateInstrumentUrl(2).spec());
35 EXPECT_EQ("https://wallet-web.sandbox.google.com/online/v2/u/1/wallet/"
36 "autocheckout/v1/reportStatus",
37 GetSendStatusUrl(1).spec());
38 EXPECT_EQ("https://wallet-web.sandbox.google.com/online/v2/u/1/wallet/"
39 "autocheckout/v1/saveToWallet",
40 GetSaveToWalletNoEscrowUrl(1).spec());
41 EXPECT_EQ("https://wallet-web.sandbox.google.com/online-secure/v2/u/1/"
42 "autocheckout/v1/saveToWallet?s7e=card_number%3Bcvn",
43 GetSaveToWalletUrl(1).spec());
44 EXPECT_EQ("https://wallet-web.sandbox.google.com/online/v2/u/0/"
45 "passiveauth?isChromePayments=true",
46 GetPassiveAuthUrl().spec());
49 TEST(WalletServiceSandboxUrl, CheckProdUrls) {
50 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
51 switches::kWalletServiceUseSandbox, "0");
53 EXPECT_EQ("https://wallet.google.com/online/v2/u/1/wallet/"
54 "autocheckout/v1/getWalletItemsJwtless",
55 GetGetWalletItemsUrl(1).spec());
56 EXPECT_EQ("https://wallet.google.com/online-secure/v2/u/1/"
57 "autocheckout/v1/getFullWalletJwtless?s7e=otp",
58 GetGetFullWalletUrl(1).spec());
59 EXPECT_EQ("https://wallet.google.com/manage/w/1/paymentMethods",
60 GetManageInstrumentsUrl(1).spec());
61 EXPECT_EQ("https://wallet.google.com/manage/w/1/settings/addresses",
62 GetManageAddressesUrl(1).spec());
63 EXPECT_EQ("https://wallet.google.com/online/v2/u/1/wallet/"
64 "autocheckout/v1/acceptLegalDocument",
65 GetAcceptLegalDocumentsUrl(1).spec());
66 EXPECT_EQ("https://wallet.google.com/online-secure/v2/u/4/"
67 "autocheckout/v1/authenticateInstrument?s7e=cvn",
68 GetAuthenticateInstrumentUrl(4).spec());
69 EXPECT_EQ("https://wallet.google.com/online/v2/u/1/wallet/"
70 "autocheckout/v1/reportStatus",
71 GetSendStatusUrl(1).spec());
72 EXPECT_EQ("https://wallet.google.com/online/v2/u/1/wallet/"
73 "autocheckout/v1/saveToWallet",
74 GetSaveToWalletNoEscrowUrl(1).spec());
75 EXPECT_EQ("https://wallet.google.com/online-secure/v2/u/1/"
76 "autocheckout/v1/saveToWallet?s7e=card_number%3Bcvn",
77 GetSaveToWalletUrl(1).spec());
78 EXPECT_EQ("https://wallet.google.com/online/v2/u/0/"
79 "passiveauth?isChromePayments=true",
80 GetPassiveAuthUrl().spec());
83 TEST(WalletServiceUrl, IsUsingProd) {
84 #if defined(OS_MACOSX)
85 EXPECT_FALSE(IsUsingProd());
87 EXPECT_TRUE(IsUsingProd());
90 CommandLine* command_line = CommandLine::ForCurrentProcess();
91 command_line->AppendSwitchASCII(switches::kWalletServiceUseSandbox, "1");
92 EXPECT_FALSE(IsUsingProd());
94 const GURL sandbox_get_items_url = GetGetWalletItemsUrl(0);
95 const GURL fake_service_url = GURL("http://goo.gl");
96 command_line->AppendSwitchASCII(switches::kWalletServiceUrl,
97 fake_service_url.spec());
99 const GURL flag_get_items_url = GetGetWalletItemsUrl(0);
100 EXPECT_NE(sandbox_get_items_url, flag_get_items_url);
101 EXPECT_EQ(fake_service_url.GetOrigin(), flag_get_items_url.GetOrigin());
104 } // namespace wallet
105 } // namespace autofill