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

Side by Side Diff: chrome/test/functional/chromeos_security.py

Issue 6969105: New security-related pyauto tests for Chrome on ChromeOS that verify extension permissions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import os 6 import os
7 7
8 import pyauto_functional 8 import pyauto_functional
9 import pyauto 9 import pyauto
10 10
11 11
12 class ChromeosSecurity(pyauto.PyUITest): 12 class ChromeosSecurity(pyauto.PyUITest):
13 """Security tests for chrome on ChromeOS. 13 """Security tests for chrome on ChromeOS.
14 14
15 Requires ChromeOS to be logged in. 15 Requires ChromeOS to be logged in.
16 """ 16 """
17 COMPONENT_EXTENSION_BASELINE = [
Nirnimesh 2011/06/03 18:30:28 Are these the same on marios, alex and zgb?
dennis_jeffrey 2011/06/03 22:04:19 I think so. I'm getting this information from Pro
18 { 'name': 'Bookmark Manager',
19 'effective_host_permissions': ['chrome://favicon/*',
20 'chrome://resources/*',],
21 'api_permissions': ['bookmarks',
22 'tabs',
23 'experimental',],
24 },
25 { 'name': 'File Manager',
26 'effective_host_permissions': ['chrome://extension-icon/*',
27 'chrome://resources/*',],
28 'api_permissions': ['fileBrowserHandler',
29 'fileBrowserPrivate',
30 'mediaPlayerPrivate',
31 'unlimitedStorage',],
32 },
33 { 'name': 'Mobile Activation',
34 'effective_host_permissions': [],
35 'api_permissions': [],
36 },
37 { 'name': 'Chrome Web Store',
38 'effective_host_permissions': [],
39 'api_permissions': ['management',
40 'webstorePrivate',],
41 },
42 ]
43
44 BUNDLED_CRX_BASELINE = [
45 { 'crx_file': 'aciahcmjmecflokailenpkdchphgkefd.crx',
46 'name': 'Entanglement',
47 'effective_host_permissions': [],
48 'api_permissions': ['unlimitedStorage',],
49 },
50 { 'crx_file': 'apdfllckaahabafndbhieahigkjlhalf.crx',
51 'name': 'Google Docs',
52 'effective_host_permissions': [],
53 'api_permissions': ['unlimitedStorage',],
54 },
55 { 'crx_file': 'blpcfgokakmgnkcojhhkbfbldkacnbeo.crx',
56 'name': 'YouTube',
57 'effective_host_permissions': [],
58 'api_permissions': [],
59 },
60 { 'crx_file': 'ejjicmeblgpmajnghnpcppodonldlgfn.crx',
61 'name': 'Google Calendar',
62 'effective_host_permissions': [],
63 'api_permissions': ['notifications',
64 'unlimitedStorage',],
65 },
66 { 'crx_file': 'hpfomeedmekonipambfkmjfacahlngjd.crx',
67 'name': 'Picasa Uploader',
68 'effective_host_permissions': ['*://www.google.com/*',
69 'https://picasaweb.google.com/*',],
70 'api_permissions': ['contextMenus',
71 'fileBrowserHandler',
72 'notifications',
73 'tabs',],
74 },
75 { 'crx_file': 'kjebfhglflhjjjiceimfkgicifkhjlnm.crx',
76 'name': 'Scratchpad',
77 'effective_host_permissions': ['https://docs.google.com/*',
78 'https://www.google.com/*',],
79 'api_permissions': ['tabs',],
80 },
81 { 'crx_file': 'nckgahadagoaajjgafhacjanaoiihapd.crx',
82 'name': 'Google Talk',
83 'effective_host_permissions': ['*://mail.google.com/*',
84 '*://talkgadget.google.com/*',],
85 'api_permissions': ['tabs',],
86 },
87 { 'crx_file': 'pjkljhegncpnkpknbcohdijeoejaedia.crx',
88 'name': 'Gmail',
89 'effective_host_permissions': [],
90 'api_permissions': ['notifications',],
91 },
92 ]
93
94 def setUp(self):
95 pyauto.PyUITest.setUp(self)
96 if self.GetBrowserInfo()['properties']['is_official']:
97 self.COMPONENT_EXTENSION_BASELINE.append(
98 { 'name': 'Help',
99 'effective_host_permissions': ['*://www.google.com/*',],
100 'api_permissions': ['chromeosInfoPrivate',
101 'tabs',],
102 })
17 103
18 def ExtraChromeFlagsOnChromeOS(self): 104 def ExtraChromeFlagsOnChromeOS(self):
19 """Override default list of extra flags typicall used with automation. 105 """Override default list of extra flags typically used with automation.
20 106
21 See the default flags used with automation in pyauto.py. 107 See the default flags used with automation in pyauto.py.
22 Chrome flags for this test should be as close to reality as possible. 108 Chrome flags for this test should be as close to reality as possible.
23 """ 109 """
24 return [ 110 return [
25 '--homepage=about:blank', 111 '--homepage=about:blank',
26 ] 112 ]
27 113
28 def testCannotViewLocalFiles(self): 114 def testCannotViewLocalFiles(self):
29 """Verify that local files cannot be accessed from the browser.""" 115 """Verify that local files cannot be accessed from the browser."""
30 urls_and_titles = { 116 urls_and_titles = {
31 'file:///': 'Index of /', 117 'file:///': 'Index of /',
32 'file:///etc/': 'Index of /etc/', 118 'file:///etc/': 'Index of /etc/',
33 self.GetFileURLForDataPath('title2.html'): 'Title Of Awesomeness', 119 self.GetFileURLForDataPath('title2.html'): 'Title Of Awesomeness',
34 } 120 }
35 for url, title in urls_and_titles.iteritems(): 121 for url, title in urls_and_titles.iteritems():
36 self.NavigateToURL(url) 122 self.NavigateToURL(url)
37 self.assertNotEqual(title, self.GetActiveTabTitle(), 123 self.assertNotEqual(title, self.GetActiveTabTitle(),
38 msg='Could access local file %s.' % url) 124 msg='Could access local file %s.' % url)
39 125
126 def _VerifyExtensionPermissions(self, baseline):
127 full_ext_actual_info = self.GetExtensionsInfo()
128 for ext_expected_info in baseline:
129 located_ext_info = [info for info in full_ext_actual_info if
130 info['name'] == ext_expected_info['name']]
131 self.assertTrue(
132 located_ext_info,
133 msg='Cannot locate extension info: ' + ext_expected_info['name'])
134 ext_actual_info = located_ext_info[0]
135 self.assertEqual(set(ext_expected_info['effective_host_permissions']),
136 set(ext_actual_info['effective_host_permissions']),
137 msg='Effective host permission info does not match for '
138 'extension: ' + ext_expected_info['name'])
139 self.assertEqual(set(ext_expected_info['api_permissions']),
140 set(ext_actual_info['api_permissions']),
141 msg='API permission info does not match for '
142 'extension: ' + ext_expected_info['name'])
143
144 def testComponentExtensionPermissions(self):
145 """Ensures component extension permissions are as expected."""
146 self._VerifyExtensionPermissions(self.COMPONENT_EXTENSION_BASELINE)
Nirnimesh 2011/06/03 18:30:28 Should there be a count match somewhere?
dennis_jeffrey 2011/06/03 22:04:19 Done. This requires that I know which installed e
147
148 def testBundledCrxPermissions(self):
149 """Ensures bundled CRX permissions are as expected."""
150 # Verify that each bundled CRX on the device is expected, then install it.
151 bundled_crx_dir = os.path.abspath(
152 os.path.join('/', 'opt', 'google', 'chrome', 'extensions'))
Nirnimesh 2011/06/03 18:30:28 This is one of the places where you don't want to
dennis_jeffrey 2011/06/03 22:04:19 Done. What is the reason for this?
153 for file_name in os.listdir(bundled_crx_dir):
154 if file_name.endswith('.crx'):
155 self.assertTrue(
156 file_name in [x['crx_file'] for x in self.BUNDLED_CRX_BASELINE],
157 msg='Unexpected CRX file: ' + file_name)
158 crx_file = pyauto.FilePath(
159 os.path.abspath(os.path.join('/', 'opt', 'google', 'chrome',
160 'extensions', file_name)))
161 self.assertTrue(self.InstallExtension(crx_file, False),
162 msg='Extension install failed.')
Nirnimesh 2011/06/03 18:30:28 add: |crx_file| in the mesg
dennis_jeffrey 2011/06/03 22:04:19 Done.
163
164 # Verify that the permissions information in the baseline matches the
165 # permissions associated with the installed bundled CRX extensions.
166 self._VerifyExtensionPermissions(self.BUNDLED_CRX_BASELINE)
167
168 def testNoUnexpectedExtensions(self):
169 """Ensures there are no unexpected bundled or component extensions."""
170 # Install all bundled extensions on the device.
171 bundled_crx_dir = os.path.abspath(
172 os.path.join('/', 'opt', 'google', 'chrome', 'extensions'))
173 for file_name in os.listdir(bundled_crx_dir):
174 if file_name.endswith('.crx'):
175 crx_file = pyauto.FilePath(
176 os.path.abspath(os.path.join('/', 'opt', 'google', 'chrome',
177 'extensions', file_name)))
178 self.assertTrue(self.InstallExtension(crx_file, False),
179 msg='Extension install failed.')
180
181 # Ensure that the set of installed extension names precisely matches the
182 # baseline.
183 expected_names = [ext['name'] for ext in self.COMPONENT_EXTENSION_BASELINE]
184 expected_names.extend([ext['name'] for ext in self.BUNDLED_CRX_BASELINE])
185 ext_actual_info = self.GetExtensionsInfo()
186 installed_names = [ext['name'] for ext in ext_actual_info]
187 self.assertEqual(set(expected_names), set(installed_names),
188 msg='Installed extension names do not match baseline:\n'
189 'Installed extensions: %s\n'
190 'Expected extensions: %s' % (installed_names,
191 expected_names))
40 192
41 if __name__ == '__main__': 193 if __name__ == '__main__':
42 pyauto_functional.Main() 194 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698