| OLD | NEW |
| 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 self.CleanupFlimflamDirsOnChromeOS() |
| 26 policy_base.PolicyTestBase.setUp(self) | 27 policy_base.PolicyTestBase.setUp(self) |
| 27 self.CleanupFlimflamDirsOnChromeOS() | |
| 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: |
| 34 filename: The filename of the ONC file. ONC files should | 34 filename: The filename of the ONC file. ONC files should |
| 35 all be stored in the path defined by ONC_PATH. | 35 all be stored in the path defined by ONC_PATH. |
| 36 """ | 36 """ |
| 37 with open(os.path.join(self.ONC_PATH, filename)) as fp: | 37 with open(os.path.join(self.ONC_PATH, filename)) as fp: |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 def testONCAddPSKWifi(self): | 89 def testONCAddPSKWifi(self): |
| 90 """Test adding WPA network.""" | 90 """Test adding WPA network.""" |
| 91 wifi_networks = { | 91 wifi_networks = { |
| 92 'ssid-wpa': 'PSK', | 92 'ssid-wpa': 'PSK', |
| 93 } | 93 } |
| 94 self._ReadONCFileAndSet('network-wifi-wpa.onc') | 94 self._ReadONCFileAndSet('network-wifi-wpa.onc') |
| 95 self._VerifyRememberedWifiNetworks(wifi_networks) | 95 self._VerifyRememberedWifiNetworks(wifi_networks) |
| 96 | 96 |
| 97 def testAddBacktoBackONC(self): | 97 def testAddBacktoBackONC(self): |
| 98 """Test adding three different ONC files one after the other.""" | 98 """Test adding three different ONC files one after the other. |
| 99 |
| 100 TODO(stanleyw): crosbug.com/29422 This test checks for buggy behavior that |
| 101 has since been fiex in crosbug.com/27862. |
| 102 """ |
| 99 wifi_networks = { | 103 wifi_networks = { |
| 100 'ssid-none': '', | 104 'ssid-none': '', |
| 101 'ssid-wep': 'WEP', | 105 'ssid-wep': 'WEP', |
| 102 'ssid-wpa': 'PSK', | 106 'ssid-wpa': 'PSK', |
| 103 } | 107 } |
| 104 | 108 |
| 105 self._ReadONCFileAndSet('network-wifi-none.onc') | 109 self._ReadONCFileAndSet('network-wifi-none.onc') |
| 106 self._ReadONCFileAndSet('network-wifi-wep.onc') | 110 self._ReadONCFileAndSet('network-wifi-wep.onc') |
| 107 self._ReadONCFileAndSet('network-wifi-wpa.onc') | 111 self._ReadONCFileAndSet('network-wifi-wpa.onc') |
| 108 self._VerifyRememberedWifiNetworks(wifi_networks) | 112 self._VerifyRememberedWifiNetworks(wifi_networks) |
| 109 | 113 |
| 110 def testAddONCWithUnknownFields(self): | 114 def testAddONCWithUnknownFields(self): |
| 111 """Test adding an ONC file with unknown fields.""" | 115 """Test adding an ONC file with unknown fields.""" |
| 112 wifi_networks = { | 116 wifi_networks = { |
| 113 'ssid-none': '', | 117 'ssid-none': '', |
| 114 'ssid-wpa': 'PSK' | 118 'ssid-wpa': 'PSK' |
| 115 } | 119 } |
| 116 | 120 |
| 117 self._ReadONCFileAndSet('network-multiple-unknown.onc') | 121 self._ReadONCFileAndSet('network-multiple-unknown.onc') |
| 118 self._VerifyRememberedWifiNetworks(wifi_networks) | 122 self._VerifyRememberedWifiNetworks(wifi_networks) |
| 119 | 123 |
| 120 | 124 |
| 121 if __name__ == '__main__': | 125 if __name__ == '__main__': |
| 122 pyauto_functional.Main() | 126 pyauto_functional.Main() |
| OLD | NEW |