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

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

Issue 11578052: Replace OncNetworkParser by the new ONC translator. (Closed) Base URL: http://git.chromium.org/chromium/src.git@extend_onc_to_shill
Patch Set: Rebased. Created 7 years, 11 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 #!/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.ChromeOSDataDir(), 'network')
24 24
25 def setUp(self): 25 def setUp(self):
26 self.CleanupFlimflamDirsOnChromeOS() 26 self.CleanupFlimflamDirsOnChromeOS()
27 policy_base.PolicyTestBase.setUp(self) 27 policy_base.PolicyTestBase.setUp(self)
28 self.LoginWithTestAccount() 28 self.LoginWithTestAccount()
29 29
30 def _ReadONCFileAndSet(self, filename): 30 def _ReadONCFileAndSet(self, filename):
31 """Reads the specified ONC file and sends it as a policy. 31 """Reads the specified ONC file and sends it as a policy.
32 32
33 Inputs: 33 Inputs:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 # Error if wifi_expect_temp is not empty. 71 # Error if wifi_expect_temp is not empty.
72 self.assertFalse(wifi_expect_temp, 'The following networks ' 72 self.assertFalse(wifi_expect_temp, 'The following networks '
73 'were not remembered: %s' % self.pformat(wifi_expect_temp)) 73 'were not remembered: %s' % self.pformat(wifi_expect_temp))
74 74
75 def testONCAddOpenWifi(self): 75 def testONCAddOpenWifi(self):
76 """Test adding open network.""" 76 """Test adding open network."""
77 wifi_networks = { 77 wifi_networks = {
78 'ssid-none': '', 78 'ssid-none': '',
79 } 79 }
80 80
81 self._ReadONCFileAndSet('network-wifi-none.onc') 81 self._ReadONCFileAndSet('toplevel_wifi_open.onc')
82 self._VerifyRememberedWifiNetworks(wifi_networks) 82 self._VerifyRememberedWifiNetworks(wifi_networks)
83 83
84 def testONCAddWEPWifi(self): 84 def testONCAddWEPWifi(self):
85 """Test adding WEP network.""" 85 """Test adding WEP network."""
86 wifi_networks = { 86 wifi_networks = {
87 'ssid-wep': 'WEP', 87 'ssid-wep': 'WEP',
88 } 88 }
89 89
90 self._ReadONCFileAndSet('network-wifi-wep.onc') 90 self._ReadONCFileAndSet('toplevel_wifi_wep_proxy.onc')
91 self._VerifyRememberedWifiNetworks(wifi_networks) 91 self._VerifyRememberedWifiNetworks(wifi_networks)
92 92
93 def testONCAddPSKWifi(self): 93 def testONCAddPSKWifi(self):
94 """Test adding WPA network.""" 94 """Test adding WPA network."""
95 wifi_networks = { 95 wifi_networks = {
96 'ssid-wpa': 'WPA', 96 'ssid-wpa': 'WPA',
97 } 97 }
98 self._ReadONCFileAndSet('network-wifi-wpa.onc') 98 self._ReadONCFileAndSet('toplevel_wifi_wpa_psk.onc')
99 self._VerifyRememberedWifiNetworks(wifi_networks) 99 self._VerifyRememberedWifiNetworks(wifi_networks)
100 100
101 def testAddBacktoBackONC(self): 101 def testAddBacktoBackONC(self):
102 """Test adding three different ONC files one after the other.""" 102 """Test adding three different ONC files one after the other."""
103 test_dict = { 103 test_dict = {
104 'network-wifi-none.onc': { 'ssid-none': '' }, 104 'toplevel_wifi_open.onc': { 'ssid-none': '' },
105 'network-wifi-wep.onc': { 'ssid-wep': 'WEP' }, 105 'toplevel_wifi_wep_proxy.onc': { 'ssid-wep': 'WEP' },
106 'network-wifi-wpa.onc': { 'ssid-wpa': 'WPA' }, 106 'toplevel_wifi_wpa_psk.onc': { 'ssid-wpa': 'WPA' },
107 } 107 }
108 108
109 for onc, wifi_networks in test_dict.iteritems(): 109 for onc, wifi_networks in test_dict.iteritems():
110 self._ReadONCFileAndSet(onc) 110 self._ReadONCFileAndSet(onc)
111 self._VerifyRememberedWifiNetworks(wifi_networks) 111 self._VerifyRememberedWifiNetworks(wifi_networks)
112 112
113 def testAddBacktoBackONC2(self): 113 def testAddBacktoBackONC2(self):
114 """Test adding three different ONC files one after the other. 114 """Test adding three different ONC files one after the other.
115 115
116 Due to inconsistent behaviors as addressed in crosbug.com/27862 116 Due to inconsistent behaviors as addressed in crosbug.com/27862
117 this test does not perform a network scan/verification between 117 this test does not perform a network scan/verification between
118 the setting of policies. 118 the setting of policies.
119 """ 119 """
120 120
121 wifi_networks = { 121 wifi_networks = {
122 'ssid-wpa': 'WPA', 122 'ssid-wpa': 'WPA',
123 } 123 }
124 124
125 self._ReadONCFileAndSet('network-wifi-none.onc') 125 self._ReadONCFileAndSet('toplevel_wifi_open.onc')
126 self._ReadONCFileAndSet('network-wifi-wep.onc') 126 self._ReadONCFileAndSet('toplevel_wifi_wep_proxy.onc')
127 self._ReadONCFileAndSet('network-wifi-wpa.onc') 127 self._ReadONCFileAndSet('toplevel_wifi_wpa_psk.onc')
128 128
129 # Verify that only the most recent onc is updated. 129 # Verify that only the most recent onc is updated.
130 self._VerifyRememberedWifiNetworks(wifi_networks) 130 self._VerifyRememberedWifiNetworks(wifi_networks)
131 131
132 def testAddONCWithUnknownFields(self): 132 def testAddONCWithUnknownFields(self):
133 """Test adding an ONC file with unknown fields.""" 133 """Test adding an ONC file with unknown fields."""
134 wifi_networks = { 134 wifi_networks = {
135 'ssid-none': '', 135 'ssid-none': '',
136 'ssid-wpa': 'WPA' 136 'ssid-wpa': 'WPA'
137 } 137 }
138 138
139 self._ReadONCFileAndSet('network-multiple-unknown.onc') 139 self._ReadONCFileAndSet('toplevel_with_unknown_fields.onc')
140 self._VerifyRememberedWifiNetworks(wifi_networks) 140 self._VerifyRememberedWifiNetworks(wifi_networks)
141 141
142 142
143 if __name__ == '__main__': 143 if __name__ == '__main__':
144 pyauto_functional.Main() 144 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « chrome/test/data/chromeos/net/shill_for_toplevel_with_unknown_fields.json ('k') | chrome/test/pyautolib/pyauto.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698