Chromium Code Reviews| 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 "content/public/common/origin_util.h" | |
|
Dan Beam
2015/05/08 23:57:05
^ don't think this is necessary
| |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 11 | 12 |
| 12 namespace autofill { | 13 namespace autofill { |
| 13 namespace wallet { | 14 namespace wallet { |
| 14 | 15 |
| 15 TEST(WalletServiceSandboxUrl, CheckSandboxUrls) { | 16 TEST(WalletServiceSandboxUrl, CheckSandboxUrls) { |
| 16 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 17 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 17 switches::kWalletServiceUseSandbox, "1"); | 18 switches::kWalletServiceUseSandbox, "1"); |
| 18 | 19 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 const GURL fake_service_url = GURL("http://goo.gl"); | 109 const GURL fake_service_url = GURL("http://goo.gl"); |
| 109 command_line->AppendSwitchASCII(switches::kWalletServiceUrl, | 110 command_line->AppendSwitchASCII(switches::kWalletServiceUrl, |
| 110 fake_service_url.spec()); | 111 fake_service_url.spec()); |
| 111 | 112 |
| 112 const GURL flag_get_items_url = GetGetWalletItemsUrl(0); | 113 const GURL flag_get_items_url = GetGetWalletItemsUrl(0); |
| 113 EXPECT_NE(sandbox_get_items_url, flag_get_items_url); | 114 EXPECT_NE(sandbox_get_items_url, flag_get_items_url); |
| 114 EXPECT_EQ(fake_service_url.GetOrigin(), flag_get_items_url.GetOrigin()); | 115 EXPECT_EQ(fake_service_url.GetOrigin(), flag_get_items_url.GetOrigin()); |
| 115 } | 116 } |
| 116 | 117 |
| 117 TEST(WalletServiceUrl, IsSignInContinueUrl) { | 118 TEST(WalletServiceUrl, IsSignInContinueUrl) { |
| 118 EXPECT_TRUE(GetSignInContinueUrl().SchemeIsSecure()); | 119 EXPECT_TRUE(GetSignInContinueUrl().SchemeIsCryptographic()); |
| 119 | 120 |
| 120 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 121 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 121 command_line->AppendSwitchASCII(switches::kWalletServiceUseSandbox, "1"); | 122 command_line->AppendSwitchASCII(switches::kWalletServiceUseSandbox, "1"); |
| 122 | 123 |
| 123 // authuser query param is respected. | 124 // authuser query param is respected. |
| 124 const char sign_in_url[] = "https://wallet-web.sandbox.google.com/online/v2/" | 125 const char sign_in_url[] = "https://wallet-web.sandbox.google.com/online/v2/" |
| 125 "u/0/passiveauth?isChromePayments=true&authuser=4"; | 126 "u/0/passiveauth?isChromePayments=true&authuser=4"; |
| 126 size_t user_index = 100; | 127 size_t user_index = 100; |
| 127 EXPECT_TRUE(IsSignInContinueUrl(GURL(sign_in_url), &user_index)); | 128 EXPECT_TRUE(IsSignInContinueUrl(GURL(sign_in_url), &user_index)); |
| 128 EXPECT_EQ(4U, user_index); | 129 EXPECT_EQ(4U, user_index); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 150 EXPECT_TRUE(IsSignInRelatedUrl(GetSignInUrl(0))); | 151 EXPECT_TRUE(IsSignInRelatedUrl(GetSignInUrl(0))); |
| 151 EXPECT_TRUE(IsSignInRelatedUrl(GetAddAccountUrl())); | 152 EXPECT_TRUE(IsSignInRelatedUrl(GetAddAccountUrl())); |
| 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.youtube.com/"))); |
| 154 EXPECT_TRUE(IsSignInRelatedUrl(GURL("https://accounts.google.com"))); | 155 EXPECT_TRUE(IsSignInRelatedUrl(GURL("https://accounts.google.com"))); |
| 155 EXPECT_FALSE(IsSignInRelatedUrl(GURL("http://google.com"))); | 156 EXPECT_FALSE(IsSignInRelatedUrl(GURL("http://google.com"))); |
| 156 } | 157 } |
| 157 | 158 |
| 158 } // namespace wallet | 159 } // namespace wallet |
| 159 } // namespace autofill | 160 } // namespace autofill |
| OLD | NEW |