Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python3.4 |
| 2 | # |
| 3 | # Copyright 2018 - The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | import itertools |
| 18 | import pprint |
| 19 | import queue |
| 20 | import time |
| 21 | |
| 22 | import acts.base_test |
| 23 | import acts.signals as signals |
| 24 | import acts.test_utils.wifi.wifi_test_utils as wutils |
| 25 | import acts.utils |
| 26 | |
| 27 | from acts import asserts |
Roshan Pius | 3e3bd34 | 2019-01-09 13:55:17 -0800 | [diff] [blame] | 28 | from acts.controllers.android_device import SL4A_APK_NAME |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 29 | from acts.test_decorators import test_tracker_info |
| 30 | from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest |
| 31 | from acts.test_utils.wifi import wifi_constants |
| 32 | |
| 33 | WifiEnums = wutils.WifiEnums |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 34 | # EAP Macros |
| 35 | EAP = WifiEnums.Eap |
| 36 | EapPhase2 = WifiEnums.EapPhase2 |
| 37 | # Enterprise Config Macros |
| 38 | Ent = WifiEnums.Enterprise |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame^] | 39 | BOINGO = 0 |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 40 | |
| 41 | # Default timeout used for reboot, toggle WiFi and Airplane mode, |
| 42 | # for the system to settle down after the operation. |
| 43 | DEFAULT_TIMEOUT = 10 |
| 44 | |
Nate Jiang | 1ef58c3 | 2019-07-15 19:13:26 -0700 | [diff] [blame] | 45 | |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 46 | class WifiNetworkSuggestionTest(WifiBaseTest): |
| 47 | """Tests for WifiNetworkSuggestion API surface. |
| 48 | |
| 49 | Test Bed Requirement: |
| 50 | * one Android device |
| 51 | * Several Wi-Fi networks visible to the device, including an open Wi-Fi |
| 52 | network. |
| 53 | """ |
| 54 | |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 55 | def setup_class(self): |
Xianyuan Jia | 168103b | 2019-09-06 12:22:52 -0700 | [diff] [blame] | 56 | super().setup_class() |
| 57 | |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 58 | self.dut = self.android_devices[0] |
| 59 | wutils.wifi_test_device_init(self.dut) |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 60 | req_params = [] |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 61 | opt_param = [ |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 62 | "open_network", "reference_networks", "radius_conf_2g", "radius_conf_5g", "ca_cert", |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame^] | 63 | "eap_identity", "eap_password", "hidden_networks", "passpoint_networks" |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 64 | ] |
| 65 | self.unpack_userparams( |
| 66 | req_param_names=req_params, opt_param_names=opt_param) |
| 67 | |
| 68 | if "AccessPoint" in self.user_params: |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 69 | self.legacy_configure_ap_and_start( |
| 70 | wpa_network=True, ent_network=True, |
| 71 | radius_conf_2g=self.radius_conf_2g, |
| 72 | radius_conf_5g=self.radius_conf_5g,) |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 73 | |
| 74 | asserts.assert_true( |
| 75 | len(self.reference_networks) > 0, |
| 76 | "Need at least one reference network with psk.") |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 77 | if hasattr(self, "reference_networks"): |
| 78 | self.wpa_psk_2g = self.reference_networks[0]["2g"] |
| 79 | self.wpa_psk_5g = self.reference_networks[0]["5g"] |
| 80 | if hasattr(self, "open_network"): |
| 81 | self.open_2g = self.open_network[0]["2g"] |
| 82 | self.open_5g = self.open_network[0]["5g"] |
| 83 | if hasattr(self, "ent_networks"): |
| 84 | self.ent_network_2g = self.ent_networks[0]["2g"] |
| 85 | self.ent_network_5g = self.ent_networks[0]["5g"] |
| 86 | self.config_aka = { |
| 87 | Ent.EAP: int(EAP.AKA), |
| 88 | WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY], |
| 89 | } |
| 90 | self.config_ttls = { |
| 91 | Ent.EAP: int(EAP.TTLS), |
| 92 | Ent.CA_CERT: self.ca_cert, |
| 93 | Ent.IDENTITY: self.eap_identity, |
| 94 | Ent.PASSWORD: self.eap_password, |
| 95 | Ent.PHASE2: int(EapPhase2.MSCHAPV2), |
| 96 | WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY], |
| 97 | } |
Nate Jiang | 20af5e8 | 2019-08-08 12:45:24 -0700 | [diff] [blame] | 98 | if hasattr(self, "hidden_networks"): |
| 99 | self.hidden_network = self.hidden_networks[0] |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 100 | self.dut.droid.wifiRemoveNetworkSuggestions([]) |
| 101 | |
| 102 | def setup_test(self): |
| 103 | self.dut.droid.wakeLockAcquireBright() |
| 104 | self.dut.droid.wakeUpNow() |
Roshan Pius | 89b22bd | 2019-01-24 14:12:49 -0800 | [diff] [blame] | 105 | self.clear_deleted_ephemeral_networks() |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 106 | wutils.wifi_toggle_state(self.dut, True) |
Roshan Pius | 159222c | 2019-02-07 10:33:32 -0800 | [diff] [blame] | 107 | self.dut.ed.clear_all_events() |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 108 | |
| 109 | def teardown_test(self): |
| 110 | self.dut.droid.wakeLockRelease() |
| 111 | self.dut.droid.goToSleepNow() |
| 112 | self.dut.droid.wifiRemoveNetworkSuggestions([]) |
Roshan Pius | ffc2991 | 2019-01-18 13:39:49 -0800 | [diff] [blame] | 113 | self.dut.droid.wifiDisconnect() |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 114 | wutils.reset_wifi(self.dut) |
Nate Jiang | 1ef58c3 | 2019-07-15 19:13:26 -0700 | [diff] [blame] | 115 | wutils.wifi_toggle_state(self.dut, False) |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 116 | self.dut.ed.clear_all_events() |
| 117 | |
| 118 | def on_fail(self, test_name, begin_time): |
| 119 | self.dut.take_bug_report(test_name, begin_time) |
| 120 | self.dut.cat_adb_log(test_name, begin_time) |
| 121 | |
| 122 | def teardown_class(self): |
| 123 | if "AccessPoint" in self.user_params: |
| 124 | del self.user_params["reference_networks"] |
| 125 | del self.user_params["open_network"] |
| 126 | |
| 127 | """Helper Functions""" |
Roshan Pius | 3e3bd34 | 2019-01-09 13:55:17 -0800 | [diff] [blame] | 128 | def set_approved(self, approved): |
| 129 | self.dut.log.debug("Setting suggestions from sl4a app " |
| 130 | + "approved" if approved else "not approved") |
| 131 | self.dut.adb.shell("cmd wifi network-suggestions-set-user-approved" |
| 132 | + " " + SL4A_APK_NAME |
| 133 | + " " + ("yes" if approved else "no")) |
| 134 | |
| 135 | def is_approved(self): |
| 136 | is_approved_str = self.dut.adb.shell( |
| 137 | "cmd wifi network-suggestions-has-user-approved" |
| 138 | + " " + SL4A_APK_NAME) |
| 139 | return True if (is_approved_str == "yes") else False |
| 140 | |
Roshan Pius | 89b22bd | 2019-01-24 14:12:49 -0800 | [diff] [blame] | 141 | def clear_deleted_ephemeral_networks(self): |
| 142 | self.dut.log.debug("Clearing deleted ephemeral networks") |
| 143 | self.dut.adb.shell( |
| 144 | "cmd wifi clear-deleted-ephemeral-networks") |
| 145 | |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 146 | def add_suggestions_and_ensure_connection(self, network_suggestions, |
| 147 | expected_ssid, |
| 148 | expect_post_connection_broadcast): |
Roshan Pius | 3702f24 | 2019-02-28 09:14:40 -0800 | [diff] [blame] | 149 | if expect_post_connection_broadcast is not None: |
| 150 | self.dut.droid.wifiStartTrackingNetworkSuggestionStateChange() |
| 151 | |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 152 | self.dut.log.info("Adding network suggestions"); |
| 153 | asserts.assert_true( |
| 154 | self.dut.droid.wifiAddNetworkSuggestions(network_suggestions), |
| 155 | "Failed to add suggestions") |
Roshan Pius | 3e3bd34 | 2019-01-09 13:55:17 -0800 | [diff] [blame] | 156 | # Enable suggestions by the app. |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame^] | 157 | self.dut.log.debug("Enabling suggestions from test") |
Roshan Pius | 3e3bd34 | 2019-01-09 13:55:17 -0800 | [diff] [blame] | 158 | self.set_approved(True) |
lutina | 49d3e51 | 2019-07-05 14:42:33 +0800 | [diff] [blame] | 159 | wutils.start_wifi_connection_scan_and_return_status(self.dut) |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 160 | wutils.wait_for_connect(self.dut, expected_ssid) |
| 161 | |
| 162 | if expect_post_connection_broadcast is None: |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame^] | 163 | return |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 164 | |
| 165 | # Check if we expected to get the broadcast. |
| 166 | try: |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 167 | event = self.dut.ed.pop_event( |
| 168 | wifi_constants.WIFI_NETWORK_SUGGESTION_POST_CONNECTION, 60) |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 169 | except queue.Empty: |
| 170 | if expect_post_connection_broadcast: |
| 171 | raise signals.TestFailure( |
| 172 | "Did not receive post connection broadcast") |
| 173 | else: |
| 174 | if not expect_post_connection_broadcast: |
| 175 | raise signals.TestFailure( |
| 176 | "Received post connection broadcast") |
Roshan Pius | 3702f24 | 2019-02-28 09:14:40 -0800 | [diff] [blame] | 177 | finally: |
| 178 | self.dut.droid.wifiStopTrackingNetworkSuggestionStateChange() |
Roshan Pius | ff6ca4c | 2019-03-26 13:53:31 -0700 | [diff] [blame] | 179 | self.dut.ed.clear_all_events() |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 180 | |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 181 | def remove_suggestions_disconnect_and_ensure_no_connection_back(self, |
| 182 | network_suggestions, |
| 183 | expected_ssid): |
| 184 | # Remove suggestion trigger disconnect and wait for the disconnect. |
| 185 | self.dut.log.info("Removing network suggestions") |
| 186 | asserts.assert_true( |
| 187 | self.dut.droid.wifiRemoveNetworkSuggestions(network_suggestions), |
| 188 | "Failed to remove suggestions") |
| 189 | wutils.wait_for_disconnect(self.dut) |
| 190 | self.dut.ed.clear_all_events() |
| 191 | |
| 192 | # Now ensure that we didn't connect back. |
| 193 | asserts.assert_false( |
| 194 | wutils.wait_for_connect(self.dut, expected_ssid, assert_on_fail=False), |
| 195 | "Device should not connect back") |
| 196 | |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 197 | def _test_connect_to_wifi_network_reboot_config_store(self, |
| 198 | network_suggestions, |
| 199 | wifi_network): |
| 200 | """ Test network suggestion with reboot config store |
| 201 | |
| 202 | Args: |
| 203 | 1. network_suggestions: network suggestions in list to add to the device. |
| 204 | 2. wifi_network: expected wifi network to connect to |
| 205 | """ |
| 206 | |
| 207 | self.add_suggestions_and_ensure_connection( |
| 208 | network_suggestions, wifi_network[WifiEnums.SSID_KEY], None) |
| 209 | |
| 210 | # Reboot and wait for connection back to the same suggestion. |
| 211 | self.dut.reboot() |
| 212 | time.sleep(DEFAULT_TIMEOUT) |
| 213 | |
| 214 | wutils.wait_for_connect(self.dut, wifi_network[WifiEnums.SSID_KEY]) |
| 215 | |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 216 | self.remove_suggestions_disconnect_and_ensure_no_connection_back( |
| 217 | network_suggestions, wifi_network[WifiEnums.SSID_KEY]) |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 218 | |
Roshan Pius | f028bd3 | 2018-12-06 15:18:21 -0800 | [diff] [blame] | 219 | @test_tracker_info(uuid="bda8ed20-4382-4380-831a-64cf77eca108") |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 220 | def test_connect_to_wpa_psk_2g(self): |
| 221 | """ Adds a network suggestion and ensure that the device connected. |
| 222 | |
| 223 | Steps: |
| 224 | 1. Send a network suggestion to the device. |
| 225 | 2. Wait for the device to connect to it. |
| 226 | 3. Ensure that we did not receive the post connection broadcast |
| 227 | (isAppInteractionRequired = False). |
Roshan Pius | ffc2991 | 2019-01-18 13:39:49 -0800 | [diff] [blame] | 228 | 4. Remove the suggestions and ensure the device does not connect back. |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 229 | """ |
| 230 | self.add_suggestions_and_ensure_connection( |
| 231 | [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY], |
| 232 | False) |
Nate Jiang | 1ef58c3 | 2019-07-15 19:13:26 -0700 | [diff] [blame] | 233 | |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 234 | self.remove_suggestions_disconnect_and_ensure_no_connection_back( |
| 235 | [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY]) |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 236 | |
Roshan Pius | c6fceca | 2019-03-22 13:23:58 -0700 | [diff] [blame] | 237 | @test_tracker_info(uuid="f54bc250-d9e9-4f00-8b5b-b866e8550b43") |
| 238 | def test_connect_to_highest_priority(self): |
| 239 | """ |
| 240 | Adds network suggestions and ensures that device connects to |
| 241 | the suggestion with the highest priority. |
| 242 | |
| 243 | Steps: |
| 244 | 1. Send 2 network suggestions to the device (with different priorities). |
| 245 | 2. Wait for the device to connect to the network with the highest |
| 246 | priority. |
Nate Jiang | 172c690 | 2019-09-09 17:54:33 -0700 | [diff] [blame] | 247 | 3. In-place modify network suggestions with priorities reversed |
| 248 | 4. Restart wifi, wait for the device to connect to the network with the highest |
| 249 | priority. |
| 250 | 5. Re-add the suggestions with the priorities reversed again. |
| 251 | 6. Again wait for the device to connect to the network with the highest |
Roshan Pius | c6fceca | 2019-03-22 13:23:58 -0700 | [diff] [blame] | 252 | priority. |
| 253 | """ |
| 254 | network_suggestion_2g = self.wpa_psk_2g |
| 255 | network_suggestion_5g = self.wpa_psk_5g |
| 256 | |
| 257 | # Add suggestions & wait for the connection event. |
| 258 | network_suggestion_2g[WifiEnums.PRIORITY] = 5 |
| 259 | network_suggestion_5g[WifiEnums.PRIORITY] = 2 |
| 260 | self.add_suggestions_and_ensure_connection( |
| 261 | [network_suggestion_2g, network_suggestion_5g], |
| 262 | self.wpa_psk_2g[WifiEnums.SSID_KEY], |
| 263 | None) |
| 264 | |
Nate Jiang | 172c690 | 2019-09-09 17:54:33 -0700 | [diff] [blame] | 265 | # In-place modify Reverse the priority, should be no disconnect |
| 266 | network_suggestion_2g[WifiEnums.PRIORITY] = 2 |
| 267 | network_suggestion_5g[WifiEnums.PRIORITY] = 5 |
| 268 | self.dut.log.info("Modifying network suggestions"); |
| 269 | asserts.assert_true( |
| 270 | self.dut.droid.wifiAddNetworkSuggestions([network_suggestion_2g, |
| 271 | network_suggestion_5g]), |
| 272 | "Failed to add suggestions") |
| 273 | wutils.ensure_no_disconnect(self.dut) |
| 274 | |
| 275 | # Disable and re-enable wifi, should connect to higher priority |
| 276 | wutils.wifi_toggle_state(self.dut, False) |
| 277 | time.sleep(DEFAULT_TIMEOUT) |
| 278 | wutils.wifi_toggle_state(self.dut, True) |
| 279 | wutils.start_wifi_connection_scan_and_return_status(self.dut) |
| 280 | wutils.wait_for_connect(self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY]) |
| 281 | |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 282 | self.remove_suggestions_disconnect_and_ensure_no_connection_back( |
Nate Jiang | 0878aef | 2019-09-16 13:33:26 -0700 | [diff] [blame] | 283 | [], self.wpa_psk_5g[WifiEnums.SSID_KEY]) |
Roshan Pius | c6fceca | 2019-03-22 13:23:58 -0700 | [diff] [blame] | 284 | |
| 285 | # Reverse the priority. |
| 286 | # Add suggestions & wait for the connection event. |
Nate Jiang | 172c690 | 2019-09-09 17:54:33 -0700 | [diff] [blame] | 287 | network_suggestion_2g[WifiEnums.PRIORITY] = 5 |
| 288 | network_suggestion_5g[WifiEnums.PRIORITY] = 2 |
Roshan Pius | c6fceca | 2019-03-22 13:23:58 -0700 | [diff] [blame] | 289 | self.add_suggestions_and_ensure_connection( |
| 290 | [network_suggestion_2g, network_suggestion_5g], |
Nate Jiang | 0878aef | 2019-09-16 13:33:26 -0700 | [diff] [blame] | 291 | self.wpa_psk_2g[WifiEnums.SSID_KEY], |
Roshan Pius | c6fceca | 2019-03-22 13:23:58 -0700 | [diff] [blame] | 292 | None) |
| 293 | |
Roshan Pius | f028bd3 | 2018-12-06 15:18:21 -0800 | [diff] [blame] | 294 | @test_tracker_info(uuid="b1d27eea-23c8-4c4f-b944-ef118e4cc35f") |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 295 | def test_connect_to_wpa_psk_2g_with_post_connection_broadcast(self): |
| 296 | """ Adds a network suggestion and ensure that the device connected. |
| 297 | |
| 298 | Steps: |
| 299 | 1. Send a network suggestion to the device with |
| 300 | isAppInteractionRequired set. |
| 301 | 2. Wait for the device to connect to it. |
| 302 | 3. Ensure that we did receive the post connection broadcast |
| 303 | (isAppInteractionRequired = True). |
Roshan Pius | ffc2991 | 2019-01-18 13:39:49 -0800 | [diff] [blame] | 304 | 4. Remove the suggestions and ensure the device does not connect back. |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 305 | """ |
| 306 | network_suggestion = self.wpa_psk_2g |
| 307 | network_suggestion[WifiEnums.IS_APP_INTERACTION_REQUIRED] = True |
| 308 | self.add_suggestions_and_ensure_connection( |
| 309 | [network_suggestion], self.wpa_psk_2g[WifiEnums.SSID_KEY], |
| 310 | True) |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 311 | self.remove_suggestions_disconnect_and_ensure_no_connection_back( |
| 312 | [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY]) |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 313 | |
Roshan Pius | f028bd3 | 2018-12-06 15:18:21 -0800 | [diff] [blame] | 314 | @test_tracker_info(uuid="a036a24d-29c0-456d-ae6a-afdde34da710") |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 315 | def test_connect_to_wpa_psk_5g_reboot_config_store(self): |
| 316 | """ |
| 317 | Adds a network suggestion and ensure that the device connects to it |
| 318 | after reboot. |
| 319 | |
| 320 | Steps: |
| 321 | 1. Send a network suggestion to the device. |
| 322 | 2. Wait for the device to connect to it. |
| 323 | 3. Ensure that we did not receive the post connection broadcast |
| 324 | (isAppInteractionRequired = False). |
| 325 | 4. Reboot the device. |
| 326 | 5. Wait for the device to connect to back to it. |
Roshan Pius | ffc2991 | 2019-01-18 13:39:49 -0800 | [diff] [blame] | 327 | 6. Remove the suggestions and ensure the device does not connect back. |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 328 | """ |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 329 | self._test_connect_to_wifi_network_reboot_config_store( |
| 330 | [self.wpa_psk_5g], self.wpa_psk_5g) |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 331 | |
Girish Moturu | c2033ae | 2019-07-31 09:04:36 -0700 | [diff] [blame] | 332 | @test_tracker_info(uuid="61649a2b-0f00-4272-9b9b-40ad5944da31") |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 333 | def test_connect_to_wpa_ent_config_aka_reboot_config_store(self): |
| 334 | """ |
| 335 | Adds a network suggestion and ensure that the device connects to it |
| 336 | after reboot. |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 337 | |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 338 | Steps: |
| 339 | 1. Send a Enterprise AKA network suggestion to the device. |
| 340 | 2. Wait for the device to connect to it. |
| 341 | 3. Ensure that we did not receive the post connection broadcast. |
| 342 | 4. Reboot the device. |
| 343 | 5. Wait for the device to connect to the wifi network. |
| 344 | 6. Remove suggestions and ensure device doesn't connect back to it. |
| 345 | """ |
| 346 | self._test_connect_to_wifi_network_reboot_config_store( |
| 347 | [self.config_aka], self.ent_network_2g) |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 348 | |
Girish Moturu | c2033ae | 2019-07-31 09:04:36 -0700 | [diff] [blame] | 349 | @test_tracker_info(uuid="98b2d40a-acb4-4a2f-aba1-b069e2a1d09d") |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 350 | def test_connect_to_wpa_ent_config_ttls_pap_reboot_config_store(self): |
| 351 | """ |
| 352 | Adds a network suggestion and ensure that the device connects to it |
| 353 | after reboot. |
Roshan Pius | ffc2991 | 2019-01-18 13:39:49 -0800 | [diff] [blame] | 354 | |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 355 | Steps: |
| 356 | 1. Send a Enterprise TTLS PAP network suggestion to the device. |
| 357 | 2. Wait for the device to connect to it. |
| 358 | 3. Ensure that we did not receive the post connection broadcast. |
| 359 | 4. Reboot the device. |
| 360 | 5. Wait for the device to connect to the wifi network. |
| 361 | 6. Remove suggestions and ensure device doesn't connect back to it. |
| 362 | """ |
| 363 | config = dict(self.config_ttls) |
| 364 | config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.PAP.value |
| 365 | |
| 366 | self._test_connect_to_wifi_network_reboot_config_store( |
| 367 | [config], self.ent_network_2g) |
Roshan Pius | ffc2991 | 2019-01-18 13:39:49 -0800 | [diff] [blame] | 368 | |
Roshan Pius | 3e3bd34 | 2019-01-09 13:55:17 -0800 | [diff] [blame] | 369 | @test_tracker_info(uuid="554b5861-22d0-4922-a5f4-712b4cf564eb") |
| 370 | def test_fail_to_connect_to_wpa_psk_5g_when_not_approved(self): |
| 371 | """ |
| 372 | Adds a network suggestion and ensure that the device does not |
| 373 | connect to it until we approve the app. |
| 374 | |
| 375 | Steps: |
| 376 | 1. Send a network suggestion to the device with the app not approved. |
| 377 | 2. Ensure the network is present in scan results, but we don't connect |
| 378 | to it. |
| 379 | 3. Now approve the app. |
| 380 | 4. Wait for the device to connect to it. |
| 381 | """ |
| 382 | self.dut.log.info("Adding network suggestions"); |
| 383 | asserts.assert_true( |
| 384 | self.dut.droid.wifiAddNetworkSuggestions([self.wpa_psk_5g]), |
| 385 | "Failed to add suggestions") |
| 386 | |
| 387 | # Disable suggestions by the app. |
| 388 | self.set_approved(False) |
| 389 | |
| 390 | # Ensure the app is not approved. |
| 391 | asserts.assert_false( |
| 392 | self.is_approved(), |
| 393 | "Suggestions should be disabled") |
| 394 | |
| 395 | # Start a new scan to trigger auto-join. |
| 396 | wutils.start_wifi_connection_scan_and_ensure_network_found( |
| 397 | self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY]) |
| 398 | |
| 399 | # Ensure we don't connect to the network. |
| 400 | asserts.assert_false( |
| 401 | wutils.wait_for_connect( |
| 402 | self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY], assert_on_fail=False), |
| 403 | "Should not connect to network suggestions from unapproved app") |
| 404 | |
| 405 | self.dut.log.info("Enabling suggestions from test"); |
| 406 | # Now Enable suggestions by the app & ensure we connect to the network. |
| 407 | self.set_approved(True) |
| 408 | |
| 409 | # Ensure the app is approved. |
| 410 | asserts.assert_true( |
| 411 | self.is_approved(), |
| 412 | "Suggestions should be enabled") |
| 413 | |
| 414 | # Start a new scan to trigger auto-join. |
| 415 | wutils.start_wifi_connection_scan_and_ensure_network_found( |
| 416 | self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY]) |
| 417 | |
| 418 | wutils.wait_for_connect(self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY]) |
Roshan Pius | 89b22bd | 2019-01-24 14:12:49 -0800 | [diff] [blame] | 419 | |
Roshan Pius | 3d57f13 | 2019-01-28 10:25:18 -0800 | [diff] [blame] | 420 | @test_tracker_info(uuid="98400dea-776e-4a0a-9024-18845b27331c") |
Roshan Pius | 89b22bd | 2019-01-24 14:12:49 -0800 | [diff] [blame] | 421 | def test_fail_to_connect_to_wpa_psk_2g_after_user_forgot_network(self): |
| 422 | """ |
| 423 | Adds a network suggestion and ensures that the device does not |
| 424 | connect to it after the user forgot the network previously. |
| 425 | |
| 426 | Steps: |
| 427 | 1. Send a network suggestion to the device with |
| 428 | isAppInteractionRequired set. |
| 429 | 2. Wait for the device to connect to it. |
| 430 | 3. Ensure that we did receive the post connection broadcast |
| 431 | (isAppInteractionRequired = True). |
| 432 | 4. Simulate user forgetting the network and the device does not |
| 433 | connecting back even though the suggestion is active from the app. |
| 434 | """ |
| 435 | network_suggestion = self.wpa_psk_2g |
| 436 | network_suggestion[WifiEnums.IS_APP_INTERACTION_REQUIRED] = True |
| 437 | self.add_suggestions_and_ensure_connection( |
| 438 | [network_suggestion], self.wpa_psk_2g[WifiEnums.SSID_KEY], |
| 439 | True) |
| 440 | |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 441 | # Simulate user forgetting the ephemeral network. |
Roshan Pius | 89b22bd | 2019-01-24 14:12:49 -0800 | [diff] [blame] | 442 | self.dut.droid.wifiDisableEphemeralNetwork( |
| 443 | self.wpa_psk_2g[WifiEnums.SSID_KEY]) |
| 444 | wutils.wait_for_disconnect(self.dut) |
| 445 | self.dut.log.info("Disconnected from network %s", self.wpa_psk_2g) |
| 446 | self.dut.ed.clear_all_events() |
| 447 | |
| 448 | # Now ensure that we don't connect back even though the suggestion |
| 449 | # is still active. |
| 450 | asserts.assert_false( |
| 451 | wutils.wait_for_connect(self.dut, |
| 452 | self.wpa_psk_2g[WifiEnums.SSID_KEY], |
| 453 | assert_on_fail=False), |
| 454 | "Device should not connect back") |
Nate Jiang | 20af5e8 | 2019-08-08 12:45:24 -0700 | [diff] [blame] | 455 | |
| 456 | @test_tracker_info(uuid="93c86b05-fa56-4d79-ad27-009a16f691b1") |
| 457 | def test_connect_to_hidden_network(self): |
| 458 | """ |
| 459 | Adds a network suggestion with hidden SSID config, ensure device can scan |
| 460 | and connect to this network. |
| 461 | |
| 462 | Steps: |
| 463 | 1. Send a hidden network suggestion to the device. |
| 464 | 2. Wait for the device to connect to it. |
| 465 | 3. Ensure that we did not receive the post connection broadcast |
| 466 | (isAppInteractionRequired = False). |
| 467 | 4. Remove the suggestions and ensure the device does not connect back. |
| 468 | """ |
| 469 | asserts.skip_if(not hasattr(self, "hidden_networks"), "No hidden networks, skip this test") |
| 470 | |
| 471 | network_suggestion = self.hidden_network |
| 472 | self.add_suggestions_and_ensure_connection( |
| 473 | [network_suggestion], network_suggestion[WifiEnums.SSID_KEY], False) |
| 474 | self.remove_suggestions_disconnect_and_ensure_no_connection_back( |
| 475 | [network_suggestion], network_suggestion[WifiEnums.SSID_KEY]) |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame^] | 476 | |
| 477 | @test_tracker_info(uuid="") |
| 478 | def test_connect_to_passpoint_network_with_post_connection_broadcast(self): |
| 479 | """ Adds a passpoint network suggestion and ensure that the device connected. |
| 480 | |
| 481 | Steps: |
| 482 | 1. Send a network suggestion to the device. |
| 483 | 2. Wait for the device to connect to it. |
| 484 | 3. Ensure that we did receive the post connection broadcast |
| 485 | (isAppInteractionRequired = true). |
| 486 | 4. Remove the suggestions and ensure the device does not connect back. |
| 487 | """ |
| 488 | asserts.skip_if(not hasattr(self, "passpoint_networks"), |
| 489 | "No passpoint networks, skip this test") |
| 490 | passpoint_config = self.passpoint_networks[BOINGO] |
| 491 | passpoint_config[WifiEnums.IS_APP_INTERACTION_REQUIRED] = True |
| 492 | self.add_suggestions_and_ensure_connection([passpoint_config], |
| 493 | passpoint_config[WifiEnums.SSID_KEY], True) |
| 494 | self.remove_suggestions_disconnect_and_ensure_no_connection_back( |
| 495 | [passpoint_config], passpoint_config[WifiEnums.SSID_KEY]) |
| 496 | |
| 497 | @test_tracker_info(uuid="") |
| 498 | def test_connect_to_passpoint_network_reboot_config_store(self): |
| 499 | """ |
| 500 | Adds a passpoint network suggestion and ensure that the device connects to it |
| 501 | after reboot. |
| 502 | |
| 503 | Steps: |
| 504 | 1. Send a network suggestion to the device. |
| 505 | 2. Wait for the device to connect to it. |
| 506 | 3. Ensure that we did not receive the post connection broadcast |
| 507 | (isAppInteractionRequired = False). |
| 508 | 4. Reboot the device. |
| 509 | 5. Wait for the device to connect to back to it. |
| 510 | 6. Remove the suggestions and ensure the device does not connect back. |
| 511 | """ |
| 512 | asserts.skip_if(not hasattr(self, "passpoint_networks"), |
| 513 | "No passpoint networks, skip this test") |
| 514 | passpoint_config = self.passpoint_networks[BOINGO] |
| 515 | self._test_connect_to_wifi_network_reboot_config_store([passpoint_config], |
| 516 | passpoint_config) |
| 517 | |
| 518 | @test_tracker_info(uuid="554b5861-22d0-4922-a5f4-712b4cf564eb") |
| 519 | def test_fail_to_connect_to_passpoint_network_when_not_approved(self): |
| 520 | """ |
| 521 | Adds a passpoint network suggestion and ensure that the device does not |
| 522 | connect to it until we approve the app. |
| 523 | |
| 524 | Steps: |
| 525 | 1. Send a network suggestion to the device with the app not approved. |
| 526 | 2. Ensure the network is present in scan results, but we don't connect |
| 527 | to it. |
| 528 | 3. Now approve the app. |
| 529 | 4. Wait for the device to connect to it. |
| 530 | """ |
| 531 | asserts.skip_if(not hasattr(self, "passpoint_networks"), |
| 532 | "No passpoint networks, skip this test") |
| 533 | passpoint_config = self.passpoint_networks[BOINGO] |
| 534 | self.dut.log.info("Adding network suggestions") |
| 535 | asserts.assert_true( |
| 536 | self.dut.droid.wifiAddNetworkSuggestions([passpoint_config]), |
| 537 | "Failed to add suggestions") |
| 538 | |
| 539 | # Disable suggestions by the app. |
| 540 | self.set_approved(False) |
| 541 | |
| 542 | # Ensure the app is not approved. |
| 543 | asserts.assert_false( |
| 544 | self.is_approved(), |
| 545 | "Suggestions should be disabled") |
| 546 | |
| 547 | # Start a new scan to trigger auto-join. |
| 548 | wutils.start_wifi_connection_scan_and_ensure_network_found( |
| 549 | self.dut, passpoint_config[WifiEnums.SSID_KEY]) |
| 550 | |
| 551 | # Ensure we don't connect to the network. |
| 552 | asserts.assert_false( |
| 553 | wutils.wait_for_connect( |
| 554 | self.dut, passpoint_config[WifiEnums.SSID_KEY], assert_on_fail=False), |
| 555 | "Should not connect to network suggestions from unapproved app") |
| 556 | |
| 557 | self.dut.log.info("Enabling suggestions from test"); |
| 558 | # Now Enable suggestions by the app & ensure we connect to the network. |
| 559 | self.set_approved(True) |
| 560 | |
| 561 | # Ensure the app is approved. |
| 562 | asserts.assert_true( |
| 563 | self.is_approved(), |
| 564 | "Suggestions should be enabled") |
| 565 | |
| 566 | # Start a new scan to trigger auto-join. |
| 567 | wutils.start_wifi_connection_scan_and_ensure_network_found( |
| 568 | self.dut, passpoint_config[WifiEnums.SSID_KEY]) |
| 569 | |
| 570 | wutils.wait_for_connect(self.dut, passpoint_config[WifiEnums.SSID_KEY]) |
| 571 | |