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

Side by Side Diff: extensions/browser/api/web_request/web_request_permissions_unittest.cc

Issue 2845943003: Limit protection of clients[0-9]*.google.com to requests from browser. (Closed)
Patch Set: Fix unittests Created 3 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
« no previous file with comments | « extensions/browser/api/web_request/web_request_permissions.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "extensions/browser/api/web_request/web_request_permissions.h" 5 #include "extensions/browser/api/web_request/web_request_permissions.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "url/gurl.h" 8 #include "url/gurl.h"
9 9
10 namespace extensions { 10 namespace extensions {
11 11
12 TEST(ExtensionWebRequestPermissions, IsSensitiveURL) { 12 TEST(ExtensionWebRequestPermissions, IsSensitiveURL) {
13 struct TestCase { 13 struct TestCase {
14 const char* url; 14 const char* url;
15 bool is_sensitive; 15 bool is_sensitive_if_request_from_common_renderer;
16 bool is_sensitive_if_request_from_browser_or_webui_renderer;
16 } cases[] = { 17 } cases[] = {
17 {"http://www.google.com", false}, 18 {"http://www.google.com", false, false},
18 {"http://www.example.com", false}, 19 {"http://www.example.com", false, false},
19 {"http://clients.google.com", true}, 20 {"http://clients.google.com", false, true},
20 {"http://clients4.google.com", true}, 21 {"http://clients4.google.com", false, true},
21 {"http://clients9999.google.com", true}, 22 {"http://clients9999.google.com", false, true},
22 {"http://clients9999..google.com", false}, 23 {"http://clients9999..google.com", false, false},
23 {"http://clients9999.example.google.com", false}, 24 {"http://clients9999.example.google.com", false, false},
24 {"http://clients.google.com.", true}, 25 {"http://clients.google.com.", false, true},
25 {"http://.clients.google.com.", true}, 26 {"http://.clients.google.com.", false, true},
26 {"http://google.example.com", false}, 27 {"http://google.example.com", false, false},
27 {"http://www.example.com", false}, 28 {"http://www.example.com", false, false},
28 {"http://clients.google.com", true}, 29 {"http://clients.google.com", false, true},
29 {"http://sb-ssl.google.com", true}, 30 {"http://sb-ssl.google.com", true, true},
30 {"http://sb-ssl.random.google.com", false}, 31 {"http://sb-ssl.random.google.com", false, false},
31 {"http://chrome.google.com", false}, 32 {"http://chrome.google.com", false, false},
32 {"http://chrome.google.com/webstore", true}, 33 {"http://chrome.google.com/webstore", true, true},
33 {"http://chrome.google.com/webstore?query", true}, 34 {"http://chrome.google.com/webstore?query", true, true},
34 }; 35 };
35 for (const TestCase& test : cases) { 36 for (const TestCase& test : cases) {
36 EXPECT_EQ(test.is_sensitive, IsSensitiveURL(GURL(test.url))) << test.url; 37 EXPECT_EQ(
38 test.is_sensitive_if_request_from_common_renderer,
39 IsSensitiveURL(GURL(test.url),
40 false /* is_request_from_browser_or_webui_renderer */))
41 << test.url;
42 EXPECT_EQ(
43 test.is_sensitive_if_request_from_browser_or_webui_renderer,
44 IsSensitiveURL(GURL(test.url),
45 true /* is_request_from_browser_or_webui_renderer */))
46 << test.url;
37 } 47 }
38 } 48 }
39 49
40 } // namespace extensions 50 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/web_request/web_request_permissions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698