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

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

Issue 9791023: Allow setting of user and device policies in functional tests (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comments addressed. Created 8 years, 8 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 | « no previous file | chrome/test/functional/policy.py » ('j') | chrome/test/pyautolib/asn1der.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 # must come before pyauto. 8 import pyauto_functional # must come before pyauto.
9 import policy_base 9 import policy_base
10 import pyauto 10 import pyauto
11 11
12 12
13 class ChromeosONC(policy_base.PolicyTestBase): 13 class ChromeosONC(policy_base.PolicyTestBase):
14 """ 14 """
15 Tests for Open Network Configuration (ONC). 15 Tests for Open Network Configuration (ONC).
16 16
17 Open Network Configuration (ONC) files is a json dictionary 17 Open Network Configuration (ONC) files is a json dictionary
18 that contains network configurations and is pulled via policies. 18 that contains network configurations and is pulled via policies.
19 These tests verify that ONC files that are formatted correctly 19 These tests verify that ONC files that are formatted correctly
20 add the network/certificate to the device. 20 add the network/certificate to the device.
21 """ 21 """
22 22
23 ONC_PATH = os.path.join(pyauto.PyUITest.DataDir(), 'chromeos', 'cros') 23 ONC_PATH = os.path.join(pyauto.PyUITest.DataDir(), 'chromeos', 'cros')
24 24
25 def setUp(self): 25 def setUp(self):
26 policy_base.PolicyTestBase.setUp(self) 26 policy_base.PolicyTestBase.setUp(self)
27 self.CleanupFlimflamDirsOnChromeOS() 27 self.CleanupFlimflamDirsOnChromeOS()
28 if self.IsChromeOS():
Nirnimesh 2012/04/05 19:05:30 This file applies to chromeos only. This if is red
bartfab (slow) 2012/04/10 15:27:20 Done.
29 self.LoginWithTestAccount()
28 30
29 def _ReadONCFileAndSet(self, filename): 31 def _ReadONCFileAndSet(self, filename):
30 """Reads the specified ONC file and sends it as a policy. 32 """Reads the specified ONC file and sends it as a policy.
31 33
32 Inputs: 34 Inputs:
33 filename: The filename of the ONC file. ONC files should 35 filename: The filename of the ONC file. ONC files should
34 all be stored in the path defined by ONC_PATH. 36 all be stored in the path defined by ONC_PATH.
35 """ 37 """
36 with open(os.path.join(self.ONC_PATH, filename)) as fp: 38 with open(os.path.join(self.ONC_PATH, filename)) as fp:
37 self.SetPolicies({'OpenNetworkConfiguration': fp.read()}) 39 self.SetUserPolicy({'OpenNetworkConfiguration': fp.read()})
38 40
39 def _VerifyRememberedWifiNetworks(self, wifi_expect): 41 def _VerifyRememberedWifiNetworks(self, wifi_expect):
40 """Verify the list of remembered networks contains those in wifi_expect. 42 """Verify the list of remembered networks contains those in wifi_expect.
41 43
42 Inputs: 44 Inputs:
43 wifi_expect: A dictionary of wifi networks where the key is the ssid 45 wifi_expect: A dictionary of wifi networks where the key is the ssid
44 and the value is the encryption type of the network. 46 and the value is the encryption type of the network.
45 """ 47 """
46 # Sometimes there is a race condition where upon restarting chrome 48 # Sometimes there is a race condition where upon restarting chrome
47 # NetworkScan has not populated the network lists yet. We should 49 # NetworkScan has not populated the network lists yet. We should
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 'ssid-none': '', 114 'ssid-none': '',
113 'ssid-wpa': 'PSK' 115 'ssid-wpa': 'PSK'
114 } 116 }
115 117
116 self._ReadONCFileAndSet('network-multiple-unknown.onc') 118 self._ReadONCFileAndSet('network-multiple-unknown.onc')
117 self._VerifyRememberedWifiNetworks(wifi_networks) 119 self._VerifyRememberedWifiNetworks(wifi_networks)
118 120
119 121
120 if __name__ == '__main__': 122 if __name__ == '__main__':
121 pyauto_functional.Main() 123 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | chrome/test/functional/policy.py » ('j') | chrome/test/pyautolib/asn1der.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698