Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(592)

Side by Side Diff: components/autofill/content/browser/wallet/wallet_service_url_unittest.cc

Issue 1099453005: Switch web API/permission code to use IsOriginSecure() instead of SchemeIsSecure(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase onto the moved version of IsOriginSecure (https://codereview.chromium.org/1101033003/). Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
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
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(IsOriginSecure(GetSignInContinueUrl()));
Dan Beam 2015/05/07 20:50:53 the intent of this is to ensure the transmission o
lgarron 2015/05/07 20:55:33 Is the intent to ensure that it is literally encry
palmer 2015/05/07 20:57:10 Correct: |IsOriginSecure| will also return true fo
Dan Beam 2015/05/07 20:58:29 it'd probably allow http:// trusted origins as wel
lgarron 2015/05/07 21:08:32 It allows HTTP origins if the host is localhost, o
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698