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 |
Girish Moturu | a069a4a | 2019-10-23 13:21:42 -0700 | [diff] [blame] | 39 | ATT = 2 |
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 |
Nate(Qiang) Jiang | 051b814 | 2019-11-01 17:23:33 -0700 | [diff] [blame] | 44 | PASSPOINT_TIMEOUT = 30 |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 45 | |
Nate Jiang | 1ef58c3 | 2019-07-15 19:13:26 -0700 | [diff] [blame] | 46 | |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 47 | class WifiNetworkSuggestionTest(WifiBaseTest): |
| 48 | """Tests for WifiNetworkSuggestion API surface. |
| 49 | |
| 50 | Test Bed Requirement: |
| 51 | * one Android device |
| 52 | * Several Wi-Fi networks visible to the device, including an open Wi-Fi |
| 53 | network. |
| 54 | """ |
| 55 | |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 56 | def setup_class(self): |
Xianyuan Jia | 168103b | 2019-09-06 12:22:52 -0700 | [diff] [blame] | 57 | super().setup_class() |
| 58 | |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 59 | self.dut = self.android_devices[0] |
| 60 | wutils.wifi_test_device_init(self.dut) |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 61 | req_params = [] |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 62 | opt_param = [ |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 63 | "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] | 64 | "eap_identity", "eap_password", "hidden_networks", "passpoint_networks" |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 65 | ] |
| 66 | self.unpack_userparams( |
| 67 | req_param_names=req_params, opt_param_names=opt_param) |
| 68 | |
| 69 | if "AccessPoint" in self.user_params: |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 70 | self.legacy_configure_ap_and_start( |
| 71 | wpa_network=True, ent_network=True, |
| 72 | radius_conf_2g=self.radius_conf_2g, |
| 73 | radius_conf_5g=self.radius_conf_5g,) |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 74 | |
Girish Moturu | a069a4a | 2019-10-23 13:21:42 -0700 | [diff] [blame] | 75 | if hasattr(self, "reference_networks") and \ |
| 76 | isinstance(self.reference_networks, list): |
| 77 | self.wpa_psk_2g = self.reference_networks[0]["2g"] |
| 78 | self.wpa_psk_5g = self.reference_networks[0]["5g"] |
| 79 | if hasattr(self, "open_network") and isinstance(self.open_network,list): |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 80 | self.open_2g = self.open_network[0]["2g"] |
| 81 | self.open_5g = self.open_network[0]["5g"] |
Girish Moturu | a069a4a | 2019-10-23 13:21:42 -0700 | [diff] [blame] | 82 | if hasattr(self, "ent_networks") and isinstance(self.ent_networks,list): |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 83 | self.ent_network_2g = self.ent_networks[0]["2g"] |
| 84 | self.ent_network_5g = self.ent_networks[0]["5g"] |
| 85 | self.config_aka = { |
| 86 | Ent.EAP: int(EAP.AKA), |
| 87 | WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY], |
Girish Moturu | 7e30c78 | 2020-02-05 12:37:06 -0800 | [diff] [blame^] | 88 | "carrierId": str(self.dut.droid.telephonyGetSimCarrierId()), |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 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 | } |
Girish Moturu | a069a4a | 2019-10-23 13:21:42 -0700 | [diff] [blame] | 98 | if hasattr(self, "hidden_networks") and \ |
| 99 | isinstance(self.hidden_networks, list): |
| 100 | self.hidden_network = self.hidden_networks[0] |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 101 | self.dut.droid.wifiRemoveNetworkSuggestions([]) |
| 102 | |
| 103 | def setup_test(self): |
| 104 | self.dut.droid.wakeLockAcquireBright() |
| 105 | self.dut.droid.wakeUpNow() |
Roshan Pius | 89b22bd | 2019-01-24 14:12:49 -0800 | [diff] [blame] | 106 | self.clear_deleted_ephemeral_networks() |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 107 | wutils.wifi_toggle_state(self.dut, True) |
Roshan Pius | 159222c | 2019-02-07 10:33:32 -0800 | [diff] [blame] | 108 | self.dut.ed.clear_all_events() |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 109 | |
| 110 | def teardown_test(self): |
| 111 | self.dut.droid.wakeLockRelease() |
| 112 | self.dut.droid.goToSleepNow() |
| 113 | self.dut.droid.wifiRemoveNetworkSuggestions([]) |
Roshan Pius | ffc2991 | 2019-01-18 13:39:49 -0800 | [diff] [blame] | 114 | self.dut.droid.wifiDisconnect() |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 115 | wutils.reset_wifi(self.dut) |
Nate Jiang | 1ef58c3 | 2019-07-15 19:13:26 -0700 | [diff] [blame] | 116 | wutils.wifi_toggle_state(self.dut, False) |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 117 | self.dut.ed.clear_all_events() |
| 118 | |
| 119 | def on_fail(self, test_name, begin_time): |
| 120 | self.dut.take_bug_report(test_name, begin_time) |
| 121 | self.dut.cat_adb_log(test_name, begin_time) |
| 122 | |
| 123 | def teardown_class(self): |
| 124 | if "AccessPoint" in self.user_params: |
| 125 | del self.user_params["reference_networks"] |
| 126 | del self.user_params["open_network"] |
| 127 | |
| 128 | """Helper Functions""" |
Roshan Pius | 3e3bd34 | 2019-01-09 13:55:17 -0800 | [diff] [blame] | 129 | def set_approved(self, approved): |
| 130 | self.dut.log.debug("Setting suggestions from sl4a app " |
| 131 | + "approved" if approved else "not approved") |
| 132 | self.dut.adb.shell("cmd wifi network-suggestions-set-user-approved" |
| 133 | + " " + SL4A_APK_NAME |
| 134 | + " " + ("yes" if approved else "no")) |
| 135 | |
| 136 | def is_approved(self): |
| 137 | is_approved_str = self.dut.adb.shell( |
| 138 | "cmd wifi network-suggestions-has-user-approved" |
| 139 | + " " + SL4A_APK_NAME) |
| 140 | return True if (is_approved_str == "yes") else False |
| 141 | |
Nate(Qiang) Jiang | acaf889 | 2020-01-29 14:04:12 -0800 | [diff] [blame] | 142 | def set_carrier_approved(self, carrier_id, approved): |
| 143 | self.dut.log.debug(("Setting IMSI protection exemption for carrier: " + carrier_id |
| 144 | + "approved" if approved else "not approved")) |
| 145 | self.dut.adb.shell("cmd wifi imsi-protection-exemption-set-user-approved-for-carrier" |
| 146 | + " " + carrier_id |
| 147 | + " " + ("yes" if approved else "no")) |
| 148 | |
| 149 | def is_carrier_approved(self, carrier_id): |
| 150 | is_approved_str = self.dut.adb.shell( |
| 151 | "cmd wifi imsi-protection-exemption-has-user-approved-for-carrier" |
| 152 | + " " + carrier_id) |
| 153 | return True if (is_approved_str == "yes") else False |
| 154 | |
| 155 | def clear_carrier_approved(self, carrier_id): |
| 156 | self.dut.adb.shell( |
| 157 | "cmd wifi imsi-protection-exemption-clear-user-approved-for-carrier" |
| 158 | + " " + carrier_id) |
| 159 | |
Roshan Pius | 89b22bd | 2019-01-24 14:12:49 -0800 | [diff] [blame] | 160 | def clear_deleted_ephemeral_networks(self): |
| 161 | self.dut.log.debug("Clearing deleted ephemeral networks") |
| 162 | self.dut.adb.shell( |
| 163 | "cmd wifi clear-deleted-ephemeral-networks") |
| 164 | |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 165 | def add_suggestions_and_ensure_connection(self, network_suggestions, |
| 166 | expected_ssid, |
| 167 | expect_post_connection_broadcast): |
Roshan Pius | 3702f24 | 2019-02-28 09:14:40 -0800 | [diff] [blame] | 168 | if expect_post_connection_broadcast is not None: |
| 169 | self.dut.droid.wifiStartTrackingNetworkSuggestionStateChange() |
| 170 | |
Nate(Qiang) Jiang | e7a400e | 2020-01-16 17:27:23 -0800 | [diff] [blame] | 171 | self.dut.log.info("Adding network suggestions") |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 172 | asserts.assert_true( |
| 173 | self.dut.droid.wifiAddNetworkSuggestions(network_suggestions), |
| 174 | "Failed to add suggestions") |
Roshan Pius | 3e3bd34 | 2019-01-09 13:55:17 -0800 | [diff] [blame] | 175 | # Enable suggestions by the app. |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame] | 176 | self.dut.log.debug("Enabling suggestions from test") |
Roshan Pius | 3e3bd34 | 2019-01-09 13:55:17 -0800 | [diff] [blame] | 177 | self.set_approved(True) |
lutina | 49d3e51 | 2019-07-05 14:42:33 +0800 | [diff] [blame] | 178 | wutils.start_wifi_connection_scan_and_return_status(self.dut) |
Nate(Qiang) Jiang | 051b814 | 2019-11-01 17:23:33 -0700 | [diff] [blame] | 179 | # if suggestion is passpoint wait longer for connection. |
| 180 | if "profile" in network_suggestions: |
| 181 | time.sleep(PASSPOINT_TIMEOUT) |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 182 | wutils.wait_for_connect(self.dut, expected_ssid) |
| 183 | |
| 184 | if expect_post_connection_broadcast is None: |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame] | 185 | return |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 186 | |
| 187 | # Check if we expected to get the broadcast. |
| 188 | try: |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 189 | event = self.dut.ed.pop_event( |
| 190 | wifi_constants.WIFI_NETWORK_SUGGESTION_POST_CONNECTION, 60) |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 191 | except queue.Empty: |
| 192 | if expect_post_connection_broadcast: |
| 193 | raise signals.TestFailure( |
| 194 | "Did not receive post connection broadcast") |
| 195 | else: |
| 196 | if not expect_post_connection_broadcast: |
| 197 | raise signals.TestFailure( |
| 198 | "Received post connection broadcast") |
Roshan Pius | 3702f24 | 2019-02-28 09:14:40 -0800 | [diff] [blame] | 199 | finally: |
| 200 | self.dut.droid.wifiStopTrackingNetworkSuggestionStateChange() |
Roshan Pius | ff6ca4c | 2019-03-26 13:53:31 -0700 | [diff] [blame] | 201 | self.dut.ed.clear_all_events() |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 202 | |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 203 | def remove_suggestions_disconnect_and_ensure_no_connection_back(self, |
| 204 | network_suggestions, |
| 205 | expected_ssid): |
| 206 | # Remove suggestion trigger disconnect and wait for the disconnect. |
| 207 | self.dut.log.info("Removing network suggestions") |
| 208 | asserts.assert_true( |
| 209 | self.dut.droid.wifiRemoveNetworkSuggestions(network_suggestions), |
| 210 | "Failed to remove suggestions") |
| 211 | wutils.wait_for_disconnect(self.dut) |
| 212 | self.dut.ed.clear_all_events() |
| 213 | |
| 214 | # Now ensure that we didn't connect back. |
| 215 | asserts.assert_false( |
| 216 | wutils.wait_for_connect(self.dut, expected_ssid, assert_on_fail=False), |
| 217 | "Device should not connect back") |
| 218 | |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 219 | def _test_connect_to_wifi_network_reboot_config_store(self, |
| 220 | network_suggestions, |
| 221 | wifi_network): |
| 222 | """ Test network suggestion with reboot config store |
| 223 | |
| 224 | Args: |
| 225 | 1. network_suggestions: network suggestions in list to add to the device. |
| 226 | 2. wifi_network: expected wifi network to connect to |
| 227 | """ |
| 228 | |
| 229 | self.add_suggestions_and_ensure_connection( |
| 230 | network_suggestions, wifi_network[WifiEnums.SSID_KEY], None) |
| 231 | |
| 232 | # Reboot and wait for connection back to the same suggestion. |
| 233 | self.dut.reboot() |
| 234 | time.sleep(DEFAULT_TIMEOUT) |
| 235 | |
| 236 | wutils.wait_for_connect(self.dut, wifi_network[WifiEnums.SSID_KEY]) |
| 237 | |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 238 | self.remove_suggestions_disconnect_and_ensure_no_connection_back( |
| 239 | network_suggestions, wifi_network[WifiEnums.SSID_KEY]) |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 240 | |
Nate(Qiang) Jiang | 8a62e37 | 2019-12-19 11:04:05 -0800 | [diff] [blame] | 241 | # Reboot with empty suggestion, verify user approval is kept. |
| 242 | self.dut.reboot() |
| 243 | time.sleep(DEFAULT_TIMEOUT) |
| 244 | asserts.assert_true(self.is_approved(), "User approval should be kept") |
| 245 | |
Roshan Pius | f028bd3 | 2018-12-06 15:18:21 -0800 | [diff] [blame] | 246 | @test_tracker_info(uuid="bda8ed20-4382-4380-831a-64cf77eca108") |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 247 | def test_connect_to_wpa_psk_2g(self): |
| 248 | """ Adds a network suggestion and ensure that the device connected. |
| 249 | |
| 250 | Steps: |
| 251 | 1. Send a network suggestion to the device. |
| 252 | 2. Wait for the device to connect to it. |
| 253 | 3. Ensure that we did not receive the post connection broadcast |
| 254 | (isAppInteractionRequired = False). |
Roshan Pius | ffc2991 | 2019-01-18 13:39:49 -0800 | [diff] [blame] | 255 | 4. Remove the suggestions and ensure the device does not connect back. |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 256 | """ |
| 257 | self.add_suggestions_and_ensure_connection( |
| 258 | [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY], |
| 259 | False) |
Nate Jiang | 1ef58c3 | 2019-07-15 19:13:26 -0700 | [diff] [blame] | 260 | |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 261 | self.remove_suggestions_disconnect_and_ensure_no_connection_back( |
| 262 | [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY]) |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 263 | |
Roshan Pius | c6fceca | 2019-03-22 13:23:58 -0700 | [diff] [blame] | 264 | @test_tracker_info(uuid="f54bc250-d9e9-4f00-8b5b-b866e8550b43") |
| 265 | def test_connect_to_highest_priority(self): |
| 266 | """ |
| 267 | Adds network suggestions and ensures that device connects to |
| 268 | the suggestion with the highest priority. |
| 269 | |
| 270 | Steps: |
| 271 | 1. Send 2 network suggestions to the device (with different priorities). |
| 272 | 2. Wait for the device to connect to the network with the highest |
| 273 | priority. |
Nate Jiang | 172c690 | 2019-09-09 17:54:33 -0700 | [diff] [blame] | 274 | 3. In-place modify network suggestions with priorities reversed |
| 275 | 4. Restart wifi, wait for the device to connect to the network with the highest |
| 276 | priority. |
| 277 | 5. Re-add the suggestions with the priorities reversed again. |
| 278 | 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] | 279 | priority. |
| 280 | """ |
| 281 | network_suggestion_2g = self.wpa_psk_2g |
| 282 | network_suggestion_5g = self.wpa_psk_5g |
| 283 | |
| 284 | # Add suggestions & wait for the connection event. |
| 285 | network_suggestion_2g[WifiEnums.PRIORITY] = 5 |
| 286 | network_suggestion_5g[WifiEnums.PRIORITY] = 2 |
| 287 | self.add_suggestions_and_ensure_connection( |
| 288 | [network_suggestion_2g, network_suggestion_5g], |
| 289 | self.wpa_psk_2g[WifiEnums.SSID_KEY], |
| 290 | None) |
| 291 | |
Nate Jiang | 172c690 | 2019-09-09 17:54:33 -0700 | [diff] [blame] | 292 | # In-place modify Reverse the priority, should be no disconnect |
| 293 | network_suggestion_2g[WifiEnums.PRIORITY] = 2 |
| 294 | network_suggestion_5g[WifiEnums.PRIORITY] = 5 |
| 295 | self.dut.log.info("Modifying network suggestions"); |
| 296 | asserts.assert_true( |
| 297 | self.dut.droid.wifiAddNetworkSuggestions([network_suggestion_2g, |
| 298 | network_suggestion_5g]), |
| 299 | "Failed to add suggestions") |
| 300 | wutils.ensure_no_disconnect(self.dut) |
| 301 | |
| 302 | # Disable and re-enable wifi, should connect to higher priority |
| 303 | wutils.wifi_toggle_state(self.dut, False) |
| 304 | time.sleep(DEFAULT_TIMEOUT) |
| 305 | wutils.wifi_toggle_state(self.dut, True) |
| 306 | wutils.start_wifi_connection_scan_and_return_status(self.dut) |
| 307 | wutils.wait_for_connect(self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY]) |
| 308 | |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 309 | self.remove_suggestions_disconnect_and_ensure_no_connection_back( |
Nate Jiang | 0878aef | 2019-09-16 13:33:26 -0700 | [diff] [blame] | 310 | [], self.wpa_psk_5g[WifiEnums.SSID_KEY]) |
Roshan Pius | c6fceca | 2019-03-22 13:23:58 -0700 | [diff] [blame] | 311 | |
| 312 | # Reverse the priority. |
| 313 | # Add suggestions & wait for the connection event. |
Nate Jiang | 172c690 | 2019-09-09 17:54:33 -0700 | [diff] [blame] | 314 | network_suggestion_2g[WifiEnums.PRIORITY] = 5 |
| 315 | network_suggestion_5g[WifiEnums.PRIORITY] = 2 |
Roshan Pius | c6fceca | 2019-03-22 13:23:58 -0700 | [diff] [blame] | 316 | self.add_suggestions_and_ensure_connection( |
| 317 | [network_suggestion_2g, network_suggestion_5g], |
Nate Jiang | 0878aef | 2019-09-16 13:33:26 -0700 | [diff] [blame] | 318 | self.wpa_psk_2g[WifiEnums.SSID_KEY], |
Roshan Pius | c6fceca | 2019-03-22 13:23:58 -0700 | [diff] [blame] | 319 | None) |
| 320 | |
Roshan Pius | f028bd3 | 2018-12-06 15:18:21 -0800 | [diff] [blame] | 321 | @test_tracker_info(uuid="b1d27eea-23c8-4c4f-b944-ef118e4cc35f") |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 322 | def test_connect_to_wpa_psk_2g_with_post_connection_broadcast(self): |
| 323 | """ Adds a network suggestion and ensure that the device connected. |
| 324 | |
| 325 | Steps: |
| 326 | 1. Send a network suggestion to the device with |
| 327 | isAppInteractionRequired set. |
| 328 | 2. Wait for the device to connect to it. |
| 329 | 3. Ensure that we did receive the post connection broadcast |
| 330 | (isAppInteractionRequired = True). |
Roshan Pius | ffc2991 | 2019-01-18 13:39:49 -0800 | [diff] [blame] | 331 | 4. Remove the suggestions and ensure the device does not connect back. |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 332 | """ |
| 333 | network_suggestion = self.wpa_psk_2g |
| 334 | network_suggestion[WifiEnums.IS_APP_INTERACTION_REQUIRED] = True |
| 335 | self.add_suggestions_and_ensure_connection( |
| 336 | [network_suggestion], self.wpa_psk_2g[WifiEnums.SSID_KEY], |
| 337 | True) |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 338 | self.remove_suggestions_disconnect_and_ensure_no_connection_back( |
| 339 | [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY]) |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 340 | |
Roshan Pius | f028bd3 | 2018-12-06 15:18:21 -0800 | [diff] [blame] | 341 | @test_tracker_info(uuid="a036a24d-29c0-456d-ae6a-afdde34da710") |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 342 | def test_connect_to_wpa_psk_5g_reboot_config_store(self): |
| 343 | """ |
| 344 | Adds a network suggestion and ensure that the device connects to it |
| 345 | after reboot. |
| 346 | |
| 347 | Steps: |
| 348 | 1. Send a network suggestion to the device. |
| 349 | 2. Wait for the device to connect to it. |
| 350 | 3. Ensure that we did not receive the post connection broadcast |
| 351 | (isAppInteractionRequired = False). |
| 352 | 4. Reboot the device. |
| 353 | 5. Wait for the device to connect to back to it. |
Roshan Pius | ffc2991 | 2019-01-18 13:39:49 -0800 | [diff] [blame] | 354 | 6. Remove the suggestions and ensure the device does not connect back. |
Nate(Qiang) Jiang | 8a62e37 | 2019-12-19 11:04:05 -0800 | [diff] [blame] | 355 | 7. Reboot the device again, ensure user approval is kept |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 356 | """ |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 357 | self._test_connect_to_wifi_network_reboot_config_store( |
| 358 | [self.wpa_psk_5g], self.wpa_psk_5g) |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 359 | |
Girish Moturu | c2033ae | 2019-07-31 09:04:36 -0700 | [diff] [blame] | 360 | @test_tracker_info(uuid="61649a2b-0f00-4272-9b9b-40ad5944da31") |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 361 | def test_connect_to_wpa_ent_config_aka_reboot_config_store(self): |
| 362 | """ |
| 363 | Adds a network suggestion and ensure that the device connects to it |
| 364 | after reboot. |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 365 | |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 366 | Steps: |
| 367 | 1. Send a Enterprise AKA network suggestion to the device. |
| 368 | 2. Wait for the device to connect to it. |
| 369 | 3. Ensure that we did not receive the post connection broadcast. |
| 370 | 4. Reboot the device. |
| 371 | 5. Wait for the device to connect to the wifi network. |
| 372 | 6. Remove suggestions and ensure device doesn't connect back to it. |
Nate(Qiang) Jiang | 8a62e37 | 2019-12-19 11:04:05 -0800 | [diff] [blame] | 373 | 7. Reboot the device again, ensure user approval is kept |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 374 | """ |
Nate(Qiang) Jiang | acaf889 | 2020-01-29 14:04:12 -0800 | [diff] [blame] | 375 | if "carrierId" in self.config_aka: |
| 376 | self.set_carrier_approved(self.config_aka["carrierId"], True) |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 377 | self._test_connect_to_wifi_network_reboot_config_store( |
| 378 | [self.config_aka], self.ent_network_2g) |
Nate(Qiang) Jiang | acaf889 | 2020-01-29 14:04:12 -0800 | [diff] [blame] | 379 | if "carrierId" in self.config_aka: |
| 380 | self.clear_carrier_approved(self.config_aka["carrierId"]) |
Roshan Pius | d120444 | 2018-11-12 12:20:39 -0800 | [diff] [blame] | 381 | |
Girish Moturu | c2033ae | 2019-07-31 09:04:36 -0700 | [diff] [blame] | 382 | @test_tracker_info(uuid="98b2d40a-acb4-4a2f-aba1-b069e2a1d09d") |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 383 | def test_connect_to_wpa_ent_config_ttls_pap_reboot_config_store(self): |
| 384 | """ |
| 385 | Adds a network suggestion and ensure that the device connects to it |
| 386 | after reboot. |
Roshan Pius | ffc2991 | 2019-01-18 13:39:49 -0800 | [diff] [blame] | 387 | |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 388 | Steps: |
| 389 | 1. Send a Enterprise TTLS PAP network suggestion to the device. |
| 390 | 2. Wait for the device to connect to it. |
| 391 | 3. Ensure that we did not receive the post connection broadcast. |
| 392 | 4. Reboot the device. |
| 393 | 5. Wait for the device to connect to the wifi network. |
| 394 | 6. Remove suggestions and ensure device doesn't connect back to it. |
Nate(Qiang) Jiang | 8a62e37 | 2019-12-19 11:04:05 -0800 | [diff] [blame] | 395 | 7. Reboot the device again, ensure user approval is kept |
Girish Moturu | b1e7a5c | 2019-07-29 13:48:11 -0700 | [diff] [blame] | 396 | """ |
| 397 | config = dict(self.config_ttls) |
| 398 | config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.PAP.value |
| 399 | |
| 400 | self._test_connect_to_wifi_network_reboot_config_store( |
| 401 | [config], self.ent_network_2g) |
Roshan Pius | ffc2991 | 2019-01-18 13:39:49 -0800 | [diff] [blame] | 402 | |
Roshan Pius | 3e3bd34 | 2019-01-09 13:55:17 -0800 | [diff] [blame] | 403 | @test_tracker_info(uuid="554b5861-22d0-4922-a5f4-712b4cf564eb") |
| 404 | def test_fail_to_connect_to_wpa_psk_5g_when_not_approved(self): |
| 405 | """ |
| 406 | Adds a network suggestion and ensure that the device does not |
| 407 | connect to it until we approve the app. |
| 408 | |
| 409 | Steps: |
| 410 | 1. Send a network suggestion to the device with the app not approved. |
| 411 | 2. Ensure the network is present in scan results, but we don't connect |
| 412 | to it. |
| 413 | 3. Now approve the app. |
| 414 | 4. Wait for the device to connect to it. |
| 415 | """ |
| 416 | self.dut.log.info("Adding network suggestions"); |
| 417 | asserts.assert_true( |
| 418 | self.dut.droid.wifiAddNetworkSuggestions([self.wpa_psk_5g]), |
| 419 | "Failed to add suggestions") |
| 420 | |
| 421 | # Disable suggestions by the app. |
| 422 | self.set_approved(False) |
| 423 | |
| 424 | # Ensure the app is not approved. |
| 425 | asserts.assert_false( |
| 426 | self.is_approved(), |
| 427 | "Suggestions should be disabled") |
| 428 | |
| 429 | # Start a new scan to trigger auto-join. |
| 430 | wutils.start_wifi_connection_scan_and_ensure_network_found( |
| 431 | self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY]) |
| 432 | |
| 433 | # Ensure we don't connect to the network. |
| 434 | asserts.assert_false( |
| 435 | wutils.wait_for_connect( |
| 436 | self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY], assert_on_fail=False), |
| 437 | "Should not connect to network suggestions from unapproved app") |
| 438 | |
| 439 | self.dut.log.info("Enabling suggestions from test"); |
| 440 | # Now Enable suggestions by the app & ensure we connect to the network. |
| 441 | self.set_approved(True) |
| 442 | |
| 443 | # Ensure the app is approved. |
| 444 | asserts.assert_true( |
| 445 | self.is_approved(), |
| 446 | "Suggestions should be enabled") |
| 447 | |
| 448 | # Start a new scan to trigger auto-join. |
| 449 | wutils.start_wifi_connection_scan_and_ensure_network_found( |
| 450 | self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY]) |
| 451 | |
| 452 | 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] | 453 | |
Roshan Pius | 3d57f13 | 2019-01-28 10:25:18 -0800 | [diff] [blame] | 454 | @test_tracker_info(uuid="98400dea-776e-4a0a-9024-18845b27331c") |
Roshan Pius | 89b22bd | 2019-01-24 14:12:49 -0800 | [diff] [blame] | 455 | def test_fail_to_connect_to_wpa_psk_2g_after_user_forgot_network(self): |
| 456 | """ |
| 457 | Adds a network suggestion and ensures that the device does not |
| 458 | connect to it after the user forgot the network previously. |
| 459 | |
| 460 | Steps: |
| 461 | 1. Send a network suggestion to the device with |
| 462 | isAppInteractionRequired set. |
| 463 | 2. Wait for the device to connect to it. |
| 464 | 3. Ensure that we did receive the post connection broadcast |
| 465 | (isAppInteractionRequired = True). |
| 466 | 4. Simulate user forgetting the network and the device does not |
| 467 | connecting back even though the suggestion is active from the app. |
| 468 | """ |
| 469 | network_suggestion = self.wpa_psk_2g |
| 470 | network_suggestion[WifiEnums.IS_APP_INTERACTION_REQUIRED] = True |
| 471 | self.add_suggestions_and_ensure_connection( |
| 472 | [network_suggestion], self.wpa_psk_2g[WifiEnums.SSID_KEY], |
| 473 | True) |
| 474 | |
Nate Jiang | 68f3ffa | 2019-08-07 15:23:49 -0700 | [diff] [blame] | 475 | # Simulate user forgetting the ephemeral network. |
Roshan Pius | 89b22bd | 2019-01-24 14:12:49 -0800 | [diff] [blame] | 476 | self.dut.droid.wifiDisableEphemeralNetwork( |
| 477 | self.wpa_psk_2g[WifiEnums.SSID_KEY]) |
| 478 | wutils.wait_for_disconnect(self.dut) |
| 479 | self.dut.log.info("Disconnected from network %s", self.wpa_psk_2g) |
| 480 | self.dut.ed.clear_all_events() |
| 481 | |
| 482 | # Now ensure that we don't connect back even though the suggestion |
| 483 | # is still active. |
| 484 | asserts.assert_false( |
| 485 | wutils.wait_for_connect(self.dut, |
| 486 | self.wpa_psk_2g[WifiEnums.SSID_KEY], |
| 487 | assert_on_fail=False), |
| 488 | "Device should not connect back") |
Nate Jiang | 20af5e8 | 2019-08-08 12:45:24 -0700 | [diff] [blame] | 489 | |
| 490 | @test_tracker_info(uuid="93c86b05-fa56-4d79-ad27-009a16f691b1") |
| 491 | def test_connect_to_hidden_network(self): |
| 492 | """ |
| 493 | Adds a network suggestion with hidden SSID config, ensure device can scan |
| 494 | and connect to this network. |
| 495 | |
| 496 | Steps: |
| 497 | 1. Send a hidden network suggestion to the device. |
| 498 | 2. Wait for the device to connect to it. |
| 499 | 3. Ensure that we did not receive the post connection broadcast |
| 500 | (isAppInteractionRequired = False). |
| 501 | 4. Remove the suggestions and ensure the device does not connect back. |
| 502 | """ |
| 503 | asserts.skip_if(not hasattr(self, "hidden_networks"), "No hidden networks, skip this test") |
| 504 | |
| 505 | network_suggestion = self.hidden_network |
| 506 | self.add_suggestions_and_ensure_connection( |
| 507 | [network_suggestion], network_suggestion[WifiEnums.SSID_KEY], False) |
| 508 | self.remove_suggestions_disconnect_and_ensure_no_connection_back( |
| 509 | [network_suggestion], network_suggestion[WifiEnums.SSID_KEY]) |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame] | 510 | |
Girish Moturu | a5d2848 | 2019-10-23 10:15:37 -0700 | [diff] [blame] | 511 | @test_tracker_info(uuid="806dff14-7543-482b-bd0a-598de59374b3") |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame] | 512 | def test_connect_to_passpoint_network_with_post_connection_broadcast(self): |
| 513 | """ Adds a passpoint network suggestion and ensure that the device connected. |
| 514 | |
| 515 | Steps: |
| 516 | 1. Send a network suggestion to the device. |
| 517 | 2. Wait for the device to connect to it. |
| 518 | 3. Ensure that we did receive the post connection broadcast |
| 519 | (isAppInteractionRequired = true). |
| 520 | 4. Remove the suggestions and ensure the device does not connect back. |
| 521 | """ |
| 522 | asserts.skip_if(not hasattr(self, "passpoint_networks"), |
| 523 | "No passpoint networks, skip this test") |
Girish Moturu | a069a4a | 2019-10-23 13:21:42 -0700 | [diff] [blame] | 524 | passpoint_config = self.passpoint_networks[ATT] |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame] | 525 | passpoint_config[WifiEnums.IS_APP_INTERACTION_REQUIRED] = True |
Nate(Qiang) Jiang | acaf889 | 2020-01-29 14:04:12 -0800 | [diff] [blame] | 526 | if "carrierId" in passpoint_config: |
| 527 | self.set_carrier_approved(passpoint_config["carrierId"], True) |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame] | 528 | self.add_suggestions_and_ensure_connection([passpoint_config], |
| 529 | passpoint_config[WifiEnums.SSID_KEY], True) |
| 530 | self.remove_suggestions_disconnect_and_ensure_no_connection_back( |
| 531 | [passpoint_config], passpoint_config[WifiEnums.SSID_KEY]) |
Nate(Qiang) Jiang | acaf889 | 2020-01-29 14:04:12 -0800 | [diff] [blame] | 532 | if "carrierId" in passpoint_config: |
| 533 | self.clear_carrier_approved(passpoint_config["carrierId"]) |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame] | 534 | |
Girish Moturu | a5d2848 | 2019-10-23 10:15:37 -0700 | [diff] [blame] | 535 | @test_tracker_info(uuid="159b8b8c-fb00-4d4e-a29f-606881dcbf44") |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame] | 536 | def test_connect_to_passpoint_network_reboot_config_store(self): |
| 537 | """ |
| 538 | Adds a passpoint network suggestion and ensure that the device connects to it |
| 539 | after reboot. |
| 540 | |
| 541 | Steps: |
| 542 | 1. Send a network suggestion to the device. |
| 543 | 2. Wait for the device to connect to it. |
| 544 | 3. Ensure that we did not receive the post connection broadcast |
| 545 | (isAppInteractionRequired = False). |
| 546 | 4. Reboot the device. |
| 547 | 5. Wait for the device to connect to back to it. |
| 548 | 6. Remove the suggestions and ensure the device does not connect back. |
Nate(Qiang) Jiang | 8a62e37 | 2019-12-19 11:04:05 -0800 | [diff] [blame] | 549 | 7. Reboot the device again, ensure user approval is kept |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame] | 550 | """ |
| 551 | asserts.skip_if(not hasattr(self, "passpoint_networks"), |
| 552 | "No passpoint networks, skip this test") |
Girish Moturu | a069a4a | 2019-10-23 13:21:42 -0700 | [diff] [blame] | 553 | passpoint_config = self.passpoint_networks[ATT] |
Nate(Qiang) Jiang | acaf889 | 2020-01-29 14:04:12 -0800 | [diff] [blame] | 554 | if "carrierId" in passpoint_config: |
| 555 | self.set_carrier_approved(passpoint_config["carrierId"], True) |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame] | 556 | self._test_connect_to_wifi_network_reboot_config_store([passpoint_config], |
| 557 | passpoint_config) |
Nate(Qiang) Jiang | acaf889 | 2020-01-29 14:04:12 -0800 | [diff] [blame] | 558 | if "carrierId" in passpoint_config: |
| 559 | self.clear_carrier_approved(passpoint_config["carrierId"]) |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame] | 560 | |
Girish Moturu | a5d2848 | 2019-10-23 10:15:37 -0700 | [diff] [blame] | 561 | @test_tracker_info(uuid="34f3d28a-bedf-43fe-a12d-2cfadf6bc6eb") |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame] | 562 | def test_fail_to_connect_to_passpoint_network_when_not_approved(self): |
| 563 | """ |
| 564 | Adds a passpoint network suggestion and ensure that the device does not |
| 565 | connect to it until we approve the app. |
| 566 | |
| 567 | Steps: |
| 568 | 1. Send a network suggestion to the device with the app not approved. |
| 569 | 2. Ensure the network is present in scan results, but we don't connect |
| 570 | to it. |
| 571 | 3. Now approve the app. |
| 572 | 4. Wait for the device to connect to it. |
| 573 | """ |
| 574 | asserts.skip_if(not hasattr(self, "passpoint_networks"), |
| 575 | "No passpoint networks, skip this test") |
Girish Moturu | a069a4a | 2019-10-23 13:21:42 -0700 | [diff] [blame] | 576 | passpoint_config = self.passpoint_networks[ATT] |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame] | 577 | self.dut.log.info("Adding network suggestions") |
| 578 | asserts.assert_true( |
| 579 | self.dut.droid.wifiAddNetworkSuggestions([passpoint_config]), |
| 580 | "Failed to add suggestions") |
| 581 | |
| 582 | # Disable suggestions by the app. |
| 583 | self.set_approved(False) |
| 584 | |
| 585 | # Ensure the app is not approved. |
| 586 | asserts.assert_false( |
| 587 | self.is_approved(), |
| 588 | "Suggestions should be disabled") |
| 589 | |
| 590 | # Start a new scan to trigger auto-join. |
| 591 | wutils.start_wifi_connection_scan_and_ensure_network_found( |
| 592 | self.dut, passpoint_config[WifiEnums.SSID_KEY]) |
| 593 | |
| 594 | # Ensure we don't connect to the network. |
| 595 | asserts.assert_false( |
| 596 | wutils.wait_for_connect( |
| 597 | self.dut, passpoint_config[WifiEnums.SSID_KEY], assert_on_fail=False), |
| 598 | "Should not connect to network suggestions from unapproved app") |
| 599 | |
| 600 | self.dut.log.info("Enabling suggestions from test"); |
| 601 | # Now Enable suggestions by the app & ensure we connect to the network. |
| 602 | self.set_approved(True) |
| 603 | |
| 604 | # Ensure the app is approved. |
| 605 | asserts.assert_true( |
| 606 | self.is_approved(), |
| 607 | "Suggestions should be enabled") |
| 608 | |
| 609 | # Start a new scan to trigger auto-join. |
| 610 | wutils.start_wifi_connection_scan_and_ensure_network_found( |
| 611 | self.dut, passpoint_config[WifiEnums.SSID_KEY]) |
Nate(Qiang) Jiang | 051b814 | 2019-11-01 17:23:33 -0700 | [diff] [blame] | 612 | time.sleep(PASSPOINT_TIMEOUT) |
Nate(Qiang) Jiang | 5558215 | 2019-10-07 12:13:47 -0700 | [diff] [blame] | 613 | wutils.wait_for_connect(self.dut, passpoint_config[WifiEnums.SSID_KEY]) |
Nate(Qiang) Jiang | e7a400e | 2020-01-16 17:27:23 -0800 | [diff] [blame] | 614 | |
Girish Moturu | 7e30c78 | 2020-02-05 12:37:06 -0800 | [diff] [blame^] | 615 | @test_tracker_info(uuid="cf624cda-4d25-42f1-80eb-6c717fb08338") |
Nate(Qiang) Jiang | acaf889 | 2020-01-29 14:04:12 -0800 | [diff] [blame] | 616 | def test_fail_to_connect_to_passpoint_network_when_imsi_protection_exemption_not_approved(self): |
| 617 | """ |
| 618 | Adds a passpoint network suggestion using SIM credential without IMSI privacy protection. |
| 619 | Before user approves the exemption, ensure that the device does noconnect to it until we |
| 620 | approve the carrier exemption. |
| 621 | |
| 622 | Steps: |
| 623 | 1. Send a network suggestion to the device with IMSI protection exemption not approved. |
| 624 | 2. Ensure the network is present in scan results, but we don't connect |
| 625 | to it. |
| 626 | 3. Now approve the carrier. |
| 627 | 4. Wait for the device to connect to it. |
| 628 | """ |
| 629 | asserts.skip_if(not hasattr(self, "passpoint_networks"), |
| 630 | "No passpoint networks, skip this test") |
| 631 | passpoint_config = self.passpoint_networks[ATT] |
| 632 | asserts.skip_if("carrierId" not in passpoint_config, |
| 633 | "Not a SIM based passpoint network, skip this test") |
| 634 | |
| 635 | self.dut.log.info("Adding network suggestions") |
| 636 | asserts.assert_true( |
| 637 | self.dut.droid.wifiAddNetworkSuggestions([passpoint_config]), |
| 638 | "Failed to add suggestions") |
| 639 | |
| 640 | # Ensure the carrier imsi protection exemption is not approved. |
| 641 | asserts.assert_false( |
| 642 | self.is_carrier_approved(passpoint_config["carrierId"]), |
| 643 | "Carrier should not be approved") |
| 644 | |
| 645 | # Start a new scan to trigger auto-join. |
| 646 | wutils.start_wifi_connection_scan_and_ensure_network_found( |
| 647 | self.dut, passpoint_config[WifiEnums.SSID_KEY]) |
| 648 | |
| 649 | # Ensure we don't connect to the network. |
| 650 | asserts.assert_false( |
| 651 | wutils.wait_for_connect( |
| 652 | self.dut, passpoint_config[WifiEnums.SSID_KEY], assert_on_fail=False), |
| 653 | "Should not connect to network suggestions from unapproved app") |
| 654 | |
| 655 | self.dut.log.info("Enabling suggestions from test") |
| 656 | # Now approve IMSI protection exemption by carrier & ensure we connect to the network. |
| 657 | self.set_carrier_approved(passpoint_config["carrierId"], True) |
| 658 | |
| 659 | # Ensure the carrier is approved. |
| 660 | asserts.assert_true( |
| 661 | self.is_carrier_approved(passpoint_config["carrierId"]), |
| 662 | "Carrier should be approved") |
| 663 | |
| 664 | # Start a new scan to trigger auto-join. |
| 665 | wutils.start_wifi_connection_scan_and_ensure_network_found( |
| 666 | self.dut, passpoint_config[WifiEnums.SSID_KEY]) |
| 667 | time.sleep(PASSPOINT_TIMEOUT) |
| 668 | wutils.wait_for_connect(self.dut, passpoint_config[WifiEnums.SSID_KEY]) |
| 669 | self.clear_carrier_approved(passpoint_config["carrierId"]) |
| 670 | |
Girish Moturu | 31f58f2 | 2020-01-30 18:54:40 -0800 | [diff] [blame] | 671 | @test_tracker_info(uuid="e35f99c8-78a4-4b96-9258-f9834b6ddd33") |
Nate(Qiang) Jiang | e7a400e | 2020-01-16 17:27:23 -0800 | [diff] [blame] | 672 | def test_initial_auto_join_on_network_suggestion(self): |
| 673 | """ |
| 674 | Add a network suggestion with enableAutojoin bit set to false, ensure the device doesn't |
| 675 | auto connect to this network |
| 676 | |
| 677 | Steps: |
| 678 | 1. Create a network suggestion. |
| 679 | 2. Set EnableAutojoin to false. |
| 680 | 3. Add this suggestion |
| 681 | 4. Ensure device doesn't connect to his network |
| 682 | """ |
Girish Moturu | 2155dc1 | 2020-01-21 15:16:17 -0800 | [diff] [blame] | 683 | network_suggestion = self.wpa_psk_5g |
Nate(Qiang) Jiang | e7a400e | 2020-01-16 17:27:23 -0800 | [diff] [blame] | 684 | # Set suggestion auto join initial to false. |
| 685 | network_suggestion["enableAutojoin"] = False |
| 686 | self.dut.log.info("Adding network suggestions") |
| 687 | asserts.assert_true( |
| 688 | self.dut.droid.wifiAddNetworkSuggestions([network_suggestion]), |
| 689 | "Failed to add suggestions") |
| 690 | # Enable suggestions by the app. |
| 691 | self.dut.log.debug("Enabling suggestions from test") |
| 692 | self.set_approved(True) |
| 693 | wutils.start_wifi_connection_scan_and_return_status(self.dut) |
| 694 | asserts.assert_false( |
| 695 | wutils.wait_for_connect(self.dut, network_suggestion[WifiEnums.SSID_KEY], |
| 696 | assert_on_fail=False), "Device should not connect.") |
| 697 | |
Girish Moturu | 31f58f2 | 2020-01-30 18:54:40 -0800 | [diff] [blame] | 698 | @test_tracker_info(uuid="ff4e451f-a380-4ff5-a5c2-dd9b1633d5e5") |
Nate(Qiang) Jiang | e7a400e | 2020-01-16 17:27:23 -0800 | [diff] [blame] | 699 | def test_user_override_auto_join_on_network_suggestion(self): |
| 700 | """ |
| 701 | Add a network suggestion, user change the auto join to false, ensure the device doesn't |
| 702 | auto connect to this network |
| 703 | |
| 704 | Steps: |
| 705 | 1. Create a network suggestion. |
| 706 | 2. Add this suggestion, and ensure we connect to this network |
| 707 | 3. Simulate user change the auto join to false. |
| 708 | 4. Toggle the Wifi off and on |
| 709 | 4. Ensure device doesn't connect to his network |
| 710 | """ |
Girish Moturu | 2155dc1 | 2020-01-21 15:16:17 -0800 | [diff] [blame] | 711 | network_suggestion = self.wpa_psk_5g |
Nate(Qiang) Jiang | e7a400e | 2020-01-16 17:27:23 -0800 | [diff] [blame] | 712 | self.add_suggestions_and_ensure_connection([network_suggestion], |
| 713 | network_suggestion[WifiEnums.SSID_KEY], False) |
| 714 | wifi_info = self.dut.droid.wifiGetConnectionInfo() |
| 715 | self.dut.log.info(wifi_info) |
| 716 | network_id = wifi_info[WifiEnums.NETID_KEY] |
| 717 | # Simulate user disable auto join through Settings. |
| 718 | self.dut.log.info("Disable auto join on suggestion") |
| 719 | self.dut.droid.wifiEnableAutojoin(network_id, False) |
| 720 | wutils.wifi_toggle_state(self.dut, False) |
| 721 | wutils.wifi_toggle_state(self.dut, True) |
| 722 | asserts.assert_false( |
| 723 | wutils.wait_for_connect(self.dut, network_suggestion[WifiEnums.SSID_KEY], |
| 724 | assert_on_fail=False), "Device should not connect.") |