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 "content/public/common/content_switches.h" | 8 #include "content/public/common/content_switches.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
11 | 11 |
12 namespace autofill { | 12 namespace autofill { |
13 namespace wallet { | 13 namespace wallet { |
14 | 14 |
15 TEST(WalletServiceSandboxUrl, CheckSandboxUrls) { | 15 TEST(WalletServiceSandboxUrl, CheckSandboxUrls) { |
16 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 16 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
17 switches::kWalletServiceUseSandbox, "1"); | 17 switches::kWalletServiceUseSandbox, "1"); |
18 | 18 |
19 EXPECT_EQ( | 19 EXPECT_EQ( |
20 "https://wallet-web.sandbox.google.com/online/v2/u/1/wallet/" | 20 "https://wallet-web.sandbox.google.com/online/v2/u/1/wallet/" |
21 "autocheckout/v1/getWalletItemsJwtless", | 21 "autocheckout/v1/getWalletItemsJwtless", |
22 GetGetWalletItemsUrl(1).spec()); | 22 GetGetWalletItemsUrl(1).spec()); |
23 EXPECT_EQ("https://wallet-web.sandbox.google.com/online-secure/v2/u/1/" | 23 EXPECT_EQ("https://wallet-web.sandbox.google.com/online-secure/v2/u/1/" |
24 "autocheckout/v1/getFullWalletJwtless?s7e=otp", | 24 "autocheckout/v1/getFullWalletJwtless?s7e=otp", |
25 GetGetFullWalletUrl(1).spec()); | 25 GetGetFullWalletUrl(1).spec()); |
26 EXPECT_EQ("https://wallet-web.sandbox.google.com/manage/w/1/paymentMethods", | 26 EXPECT_EQ("https://wallet-web.sandbox.google.com/manage/w/1/paymentMethods", |
(...skipping 16 matching lines...) Expand all Loading... |
43 GetSaveToWalletNoEscrowUrl(1).spec()); | 43 GetSaveToWalletNoEscrowUrl(1).spec()); |
44 EXPECT_EQ("https://wallet-web.sandbox.google.com/online-secure/v2/u/1/" | 44 EXPECT_EQ("https://wallet-web.sandbox.google.com/online-secure/v2/u/1/" |
45 "autocheckout/v1/saveToWallet?s7e=card_number%3Bcvn", | 45 "autocheckout/v1/saveToWallet?s7e=card_number%3Bcvn", |
46 GetSaveToWalletUrl(1).spec()); | 46 GetSaveToWalletUrl(1).spec()); |
47 EXPECT_EQ("https://wallet-web.sandbox.google.com/online/v2/u/1/" | 47 EXPECT_EQ("https://wallet-web.sandbox.google.com/online/v2/u/1/" |
48 "passiveauth?isChromePayments=true", | 48 "passiveauth?isChromePayments=true", |
49 GetPassiveAuthUrl(1).spec()); | 49 GetPassiveAuthUrl(1).spec()); |
50 } | 50 } |
51 | 51 |
52 TEST(WalletServiceSandboxUrl, CheckProdUrls) { | 52 TEST(WalletServiceSandboxUrl, CheckProdUrls) { |
53 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 53 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
54 switches::kWalletServiceUseSandbox, "0"); | 54 switches::kWalletServiceUseSandbox, "0"); |
55 | 55 |
56 EXPECT_EQ("https://wallet.google.com/online/v2/u/1/wallet/" | 56 EXPECT_EQ("https://wallet.google.com/online/v2/u/1/wallet/" |
57 "autocheckout/v1/getWalletItemsJwtless", | 57 "autocheckout/v1/getWalletItemsJwtless", |
58 GetGetWalletItemsUrl(1).spec()); | 58 GetGetWalletItemsUrl(1).spec()); |
59 EXPECT_EQ("https://wallet.google.com/online-secure/v2/u/1/" | 59 EXPECT_EQ("https://wallet.google.com/online-secure/v2/u/1/" |
60 "autocheckout/v1/getFullWalletJwtless?s7e=otp", | 60 "autocheckout/v1/getFullWalletJwtless?s7e=otp", |
61 GetGetFullWalletUrl(1).spec()); | 61 GetGetFullWalletUrl(1).spec()); |
62 EXPECT_EQ("https://wallet.google.com/manage/w/1/paymentMethods", | 62 EXPECT_EQ("https://wallet.google.com/manage/w/1/paymentMethods", |
63 GetManageInstrumentsUrl(1).spec()); | 63 GetManageInstrumentsUrl(1).spec()); |
(...skipping 20 matching lines...) Expand all Loading... |
84 GetPassiveAuthUrl(1).spec()); | 84 GetPassiveAuthUrl(1).spec()); |
85 } | 85 } |
86 | 86 |
87 TEST(WalletServiceUrl, DefaultsToProd) { | 87 TEST(WalletServiceUrl, DefaultsToProd) { |
88 #if defined(GOOGLE_CHROME_BUILD) | 88 #if defined(GOOGLE_CHROME_BUILD) |
89 EXPECT_TRUE(IsUsingProd()); | 89 EXPECT_TRUE(IsUsingProd()); |
90 #else | 90 #else |
91 EXPECT_FALSE(IsUsingProd()); | 91 EXPECT_FALSE(IsUsingProd()); |
92 #endif | 92 #endif |
93 | 93 |
94 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 94 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
95 command_line->AppendSwitch(::switches::kReduceSecurityForTesting); | 95 command_line->AppendSwitch(::switches::kReduceSecurityForTesting); |
96 EXPECT_FALSE(IsUsingProd()); | 96 EXPECT_FALSE(IsUsingProd()); |
97 | 97 |
98 command_line->AppendSwitchASCII(switches::kWalletServiceUseSandbox, "0"); | 98 command_line->AppendSwitchASCII(switches::kWalletServiceUseSandbox, "0"); |
99 EXPECT_TRUE(IsUsingProd()); | 99 EXPECT_TRUE(IsUsingProd()); |
100 } | 100 } |
101 | 101 |
102 TEST(WalletServiceUrl, IsUsingProd) { | 102 TEST(WalletServiceUrl, IsUsingProd) { |
103 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 103 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
104 command_line->AppendSwitchASCII(switches::kWalletServiceUseSandbox, "1"); | 104 command_line->AppendSwitchASCII(switches::kWalletServiceUseSandbox, "1"); |
105 EXPECT_FALSE(IsUsingProd()); | 105 EXPECT_FALSE(IsUsingProd()); |
106 | 106 |
107 const GURL sandbox_get_items_url = GetGetWalletItemsUrl(0); | 107 const GURL sandbox_get_items_url = GetGetWalletItemsUrl(0); |
108 const GURL fake_service_url = GURL("http://goo.gl"); | 108 const GURL fake_service_url = GURL("http://goo.gl"); |
109 command_line->AppendSwitchASCII(switches::kWalletServiceUrl, | 109 command_line->AppendSwitchASCII(switches::kWalletServiceUrl, |
110 fake_service_url.spec()); | 110 fake_service_url.spec()); |
111 | 111 |
112 const GURL flag_get_items_url = GetGetWalletItemsUrl(0); | 112 const GURL flag_get_items_url = GetGetWalletItemsUrl(0); |
113 EXPECT_NE(sandbox_get_items_url, flag_get_items_url); | 113 EXPECT_NE(sandbox_get_items_url, flag_get_items_url); |
114 EXPECT_EQ(fake_service_url.GetOrigin(), flag_get_items_url.GetOrigin()); | 114 EXPECT_EQ(fake_service_url.GetOrigin(), flag_get_items_url.GetOrigin()); |
115 } | 115 } |
116 | 116 |
117 TEST(WalletServiceUrl, IsSignInContinueUrl) { | 117 TEST(WalletServiceUrl, IsSignInContinueUrl) { |
118 EXPECT_TRUE(GetSignInContinueUrl().SchemeIsSecure()); | 118 EXPECT_TRUE(GetSignInContinueUrl().SchemeIsSecure()); |
119 | 119 |
120 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 120 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
121 command_line->AppendSwitchASCII(switches::kWalletServiceUseSandbox, "1"); | 121 command_line->AppendSwitchASCII(switches::kWalletServiceUseSandbox, "1"); |
122 | 122 |
123 // authuser query param is respected. | 123 // authuser query param is respected. |
124 const char sign_in_url[] = "https://wallet-web.sandbox.google.com/online/v2/" | 124 const char sign_in_url[] = "https://wallet-web.sandbox.google.com/online/v2/" |
125 "u/0/passiveauth?isChromePayments=true&authuser=4"; | 125 "u/0/passiveauth?isChromePayments=true&authuser=4"; |
126 size_t user_index = 100; | 126 size_t user_index = 100; |
127 EXPECT_TRUE(IsSignInContinueUrl(GURL(sign_in_url), &user_index)); | 127 EXPECT_TRUE(IsSignInContinueUrl(GURL(sign_in_url), &user_index)); |
128 EXPECT_EQ(4U, user_index); | 128 EXPECT_EQ(4U, user_index); |
129 | 129 |
130 // No authuser query param means 0 is assumed. | 130 // No authuser query param means 0 is assumed. |
(...skipping 19 matching lines...) Expand all Loading... |
150 EXPECT_TRUE(IsSignInRelatedUrl(GetSignInUrl(0))); | 150 EXPECT_TRUE(IsSignInRelatedUrl(GetSignInUrl(0))); |
151 EXPECT_TRUE(IsSignInRelatedUrl(GetAddAccountUrl())); | 151 EXPECT_TRUE(IsSignInRelatedUrl(GetAddAccountUrl())); |
152 EXPECT_TRUE(IsSignInRelatedUrl(GURL("https://accounts.youtube.com"))); | 152 EXPECT_TRUE(IsSignInRelatedUrl(GURL("https://accounts.youtube.com"))); |
153 EXPECT_TRUE(IsSignInRelatedUrl(GURL("https://accounts.youtube.com/"))); | 153 EXPECT_TRUE(IsSignInRelatedUrl(GURL("https://accounts.youtube.com/"))); |
154 EXPECT_TRUE(IsSignInRelatedUrl(GURL("https://accounts.google.com"))); | 154 EXPECT_TRUE(IsSignInRelatedUrl(GURL("https://accounts.google.com"))); |
155 EXPECT_FALSE(IsSignInRelatedUrl(GURL("http://google.com"))); | 155 EXPECT_FALSE(IsSignInRelatedUrl(GURL("http://google.com"))); |
156 } | 156 } |
157 | 157 |
158 } // namespace wallet | 158 } // namespace wallet |
159 } // namespace autofill | 159 } // namespace autofill |
OLD | NEW |