blob: 04f02184c4155f304084e298c056a5e78c02a299 [file] [log] [blame]
Roshan Piusd1204442018-11-12 12:20:39 -08001#!/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
17import itertools
18import pprint
19import queue
20import time
21
22import acts.base_test
23import acts.signals as signals
24import acts.test_utils.wifi.wifi_test_utils as wutils
25import acts.utils
26
27from acts import asserts
Roshan Pius3e3bd342019-01-09 13:55:17 -080028from acts.controllers.android_device import SL4A_APK_NAME
Roshan Piusd1204442018-11-12 12:20:39 -080029from acts.test_decorators import test_tracker_info
30from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest
31from acts.test_utils.wifi import wifi_constants
32
33WifiEnums = wutils.WifiEnums
Girish Moturub1e7a5c2019-07-29 13:48:11 -070034# EAP Macros
35EAP = WifiEnums.Eap
36EapPhase2 = WifiEnums.EapPhase2
37# Enterprise Config Macros
38Ent = WifiEnums.Enterprise
Girish Moturua069a4a2019-10-23 13:21:42 -070039ATT = 2
Nate Jiang8b2b4b82020-03-13 13:49:07 -070040# Suggestion network Macros
41Untrusted = "untrusted"
42AutoJoin = "enableAutojoin"
43# Network request Macros
44ClearCapabilities = "ClearCapabilities"
45TransportType = "TransportType"
46
Roshan Piusd1204442018-11-12 12:20:39 -080047
48# Default timeout used for reboot, toggle WiFi and Airplane mode,
49# for the system to settle down after the operation.
50DEFAULT_TIMEOUT = 10
Nate(Qiang) Jiang051b8142019-11-01 17:23:33 -070051PASSPOINT_TIMEOUT = 30
Roshan Piusd1204442018-11-12 12:20:39 -080052
Nate Jiang1ef58c32019-07-15 19:13:26 -070053
Roshan Piusd1204442018-11-12 12:20:39 -080054class WifiNetworkSuggestionTest(WifiBaseTest):
55 """Tests for WifiNetworkSuggestion API surface.
56
57 Test Bed Requirement:
58 * one Android device
59 * Several Wi-Fi networks visible to the device, including an open Wi-Fi
60 network.
61 """
62
Roshan Piusd1204442018-11-12 12:20:39 -080063 def setup_class(self):
Xianyuan Jia168103b2019-09-06 12:22:52 -070064 super().setup_class()
65
Roshan Piusd1204442018-11-12 12:20:39 -080066 self.dut = self.android_devices[0]
67 wutils.wifi_test_device_init(self.dut)
Roshan Piusd1204442018-11-12 12:20:39 -080068 opt_param = [
Girish Moturu3c99eb62020-06-19 13:05:26 -070069 "radius_conf_2g", "radius_conf_5g", "ca_cert", "eap_identity",
70 "eap_password", "passpoint_networks", "altsubject_match" ]
71 self.unpack_userparams(opt_param_names=opt_param,)
Roshan Piusd1204442018-11-12 12:20:39 -080072
73 if "AccessPoint" in self.user_params:
Girish Moturub1e7a5c2019-07-29 13:48:11 -070074 self.legacy_configure_ap_and_start(
75 wpa_network=True, ent_network=True,
76 radius_conf_2g=self.radius_conf_2g,
77 radius_conf_5g=self.radius_conf_5g,)
Roshan Piusd1204442018-11-12 12:20:39 -080078
Girish Moturua069a4a2019-10-23 13:21:42 -070079 if hasattr(self, "reference_networks") and \
80 isinstance(self.reference_networks, list):
81 self.wpa_psk_2g = self.reference_networks[0]["2g"]
82 self.wpa_psk_5g = self.reference_networks[0]["5g"]
83 if hasattr(self, "open_network") and isinstance(self.open_network,list):
Nate Jiang68f3ffa2019-08-07 15:23:49 -070084 self.open_2g = self.open_network[0]["2g"]
85 self.open_5g = self.open_network[0]["5g"]
Girish Moturua069a4a2019-10-23 13:21:42 -070086 if hasattr(self, "ent_networks") and isinstance(self.ent_networks,list):
Nate Jiang68f3ffa2019-08-07 15:23:49 -070087 self.ent_network_2g = self.ent_networks[0]["2g"]
88 self.ent_network_5g = self.ent_networks[0]["5g"]
89 self.config_aka = {
90 Ent.EAP: int(EAP.AKA),
91 WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY],
Girish Moturu7e30c782020-02-05 12:37:06 -080092 "carrierId": str(self.dut.droid.telephonyGetSimCarrierId()),
Nate Jiang68f3ffa2019-08-07 15:23:49 -070093 }
94 self.config_ttls = {
95 Ent.EAP: int(EAP.TTLS),
96 Ent.CA_CERT: self.ca_cert,
97 Ent.IDENTITY: self.eap_identity,
98 Ent.PASSWORD: self.eap_password,
99 Ent.PHASE2: int(EapPhase2.MSCHAPV2),
100 WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY],
Girish Moturu3c99eb62020-06-19 13:05:26 -0700101 Ent.ALTSUBJECT_MATCH: self.altsubject_match,
Nate Jiang68f3ffa2019-08-07 15:23:49 -0700102 }
Girish Moturua069a4a2019-10-23 13:21:42 -0700103 if hasattr(self, "hidden_networks") and \
104 isinstance(self.hidden_networks, list):
105 self.hidden_network = self.hidden_networks[0]
Roshan Piusd1204442018-11-12 12:20:39 -0800106 self.dut.droid.wifiRemoveNetworkSuggestions([])
Girish Moturu1fa47172020-04-13 11:36:32 -0700107 self.dut.adb.shell(
108 "pm disable com.google.android.apps.carrier.carrierwifi")
Roshan Piusd1204442018-11-12 12:20:39 -0800109
110 def setup_test(self):
111 self.dut.droid.wakeLockAcquireBright()
112 self.dut.droid.wakeUpNow()
Nate Jiang5fdbbe12020-05-06 11:35:51 -0700113 self.dut.unlock_screen()
Nate(Qiang) Jiangd3424642020-03-02 19:52:59 -0800114 self.clear_user_disabled_networks()
Roshan Piusd1204442018-11-12 12:20:39 -0800115 wutils.wifi_toggle_state(self.dut, True)
Roshan Pius159222c2019-02-07 10:33:32 -0800116 self.dut.ed.clear_all_events()
Nate(Qiang) Jiang92251a62020-02-28 10:13:30 -0800117 self.clear_carrier_approved(str(self.dut.droid.telephonyGetSimCarrierId()))
Roshan Piusd1204442018-11-12 12:20:39 -0800118
119 def teardown_test(self):
120 self.dut.droid.wakeLockRelease()
121 self.dut.droid.goToSleepNow()
122 self.dut.droid.wifiRemoveNetworkSuggestions([])
Roshan Piusffc29912019-01-18 13:39:49 -0800123 self.dut.droid.wifiDisconnect()
Roshan Piusd1204442018-11-12 12:20:39 -0800124 wutils.reset_wifi(self.dut)
Nate Jiang1ef58c32019-07-15 19:13:26 -0700125 wutils.wifi_toggle_state(self.dut, False)
Roshan Piusd1204442018-11-12 12:20:39 -0800126 self.dut.ed.clear_all_events()
Nate(Qiang) Jiang92251a62020-02-28 10:13:30 -0800127 self.clear_carrier_approved(str(self.dut.droid.telephonyGetSimCarrierId()))
Roshan Piusd1204442018-11-12 12:20:39 -0800128
129 def on_fail(self, test_name, begin_time):
130 self.dut.take_bug_report(test_name, begin_time)
131 self.dut.cat_adb_log(test_name, begin_time)
132
133 def teardown_class(self):
Girish Moturu1fa47172020-04-13 11:36:32 -0700134 self.dut.adb.shell(
135 "pm enable com.google.android.apps.carrier.carrierwifi")
Roshan Piusd1204442018-11-12 12:20:39 -0800136 if "AccessPoint" in self.user_params:
137 del self.user_params["reference_networks"]
138 del self.user_params["open_network"]
139
140 """Helper Functions"""
Roshan Pius3e3bd342019-01-09 13:55:17 -0800141 def set_approved(self, approved):
142 self.dut.log.debug("Setting suggestions from sl4a app "
143 + "approved" if approved else "not approved")
144 self.dut.adb.shell("cmd wifi network-suggestions-set-user-approved"
145 + " " + SL4A_APK_NAME
146 + " " + ("yes" if approved else "no"))
147
148 def is_approved(self):
149 is_approved_str = self.dut.adb.shell(
150 "cmd wifi network-suggestions-has-user-approved"
151 + " " + SL4A_APK_NAME)
152 return True if (is_approved_str == "yes") else False
153
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800154 def set_carrier_approved(self, carrier_id, approved):
155 self.dut.log.debug(("Setting IMSI protection exemption for carrier: " + carrier_id
156 + "approved" if approved else "not approved"))
157 self.dut.adb.shell("cmd wifi imsi-protection-exemption-set-user-approved-for-carrier"
158 + " " + carrier_id
159 + " " + ("yes" if approved else "no"))
160
161 def is_carrier_approved(self, carrier_id):
162 is_approved_str = self.dut.adb.shell(
163 "cmd wifi imsi-protection-exemption-has-user-approved-for-carrier"
164 + " " + carrier_id)
165 return True if (is_approved_str == "yes") else False
166
167 def clear_carrier_approved(self, carrier_id):
168 self.dut.adb.shell(
169 "cmd wifi imsi-protection-exemption-clear-user-approved-for-carrier"
170 + " " + carrier_id)
171
Nate(Qiang) Jiangd3424642020-03-02 19:52:59 -0800172 def clear_user_disabled_networks(self):
173 self.dut.log.debug("Clearing user disabled networks")
Roshan Pius89b22bd2019-01-24 14:12:49 -0800174 self.dut.adb.shell(
Nate(Qiang) Jiangd3424642020-03-02 19:52:59 -0800175 "cmd wifi clear-user-disabled-networks")
Roshan Pius89b22bd2019-01-24 14:12:49 -0800176
Roshan Piusd1204442018-11-12 12:20:39 -0800177 def add_suggestions_and_ensure_connection(self, network_suggestions,
178 expected_ssid,
179 expect_post_connection_broadcast):
Roshan Pius3702f242019-02-28 09:14:40 -0800180 if expect_post_connection_broadcast is not None:
181 self.dut.droid.wifiStartTrackingNetworkSuggestionStateChange()
182
Nate(Qiang) Jiange7a400e2020-01-16 17:27:23 -0800183 self.dut.log.info("Adding network suggestions")
Roshan Piusd1204442018-11-12 12:20:39 -0800184 asserts.assert_true(
185 self.dut.droid.wifiAddNetworkSuggestions(network_suggestions),
186 "Failed to add suggestions")
Roshan Pius3e3bd342019-01-09 13:55:17 -0800187 # Enable suggestions by the app.
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700188 self.dut.log.debug("Enabling suggestions from test")
Roshan Pius3e3bd342019-01-09 13:55:17 -0800189 self.set_approved(True)
lutina49d3e512019-07-05 14:42:33 +0800190 wutils.start_wifi_connection_scan_and_return_status(self.dut)
Nate(Qiang) Jiang051b8142019-11-01 17:23:33 -0700191 # if suggestion is passpoint wait longer for connection.
192 if "profile" in network_suggestions:
193 time.sleep(PASSPOINT_TIMEOUT)
Roshan Piusd1204442018-11-12 12:20:39 -0800194 wutils.wait_for_connect(self.dut, expected_ssid)
195
196 if expect_post_connection_broadcast is None:
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700197 return
Roshan Piusd1204442018-11-12 12:20:39 -0800198
199 # Check if we expected to get the broadcast.
200 try:
Roshan Piusd1204442018-11-12 12:20:39 -0800201 event = self.dut.ed.pop_event(
202 wifi_constants.WIFI_NETWORK_SUGGESTION_POST_CONNECTION, 60)
Roshan Piusd1204442018-11-12 12:20:39 -0800203 except queue.Empty:
204 if expect_post_connection_broadcast:
205 raise signals.TestFailure(
206 "Did not receive post connection broadcast")
207 else:
208 if not expect_post_connection_broadcast:
209 raise signals.TestFailure(
210 "Received post connection broadcast")
Roshan Pius3702f242019-02-28 09:14:40 -0800211 finally:
212 self.dut.droid.wifiStopTrackingNetworkSuggestionStateChange()
Roshan Piusff6ca4c2019-03-26 13:53:31 -0700213 self.dut.ed.clear_all_events()
Roshan Piusd1204442018-11-12 12:20:39 -0800214
Nate Jiang68f3ffa2019-08-07 15:23:49 -0700215 def remove_suggestions_disconnect_and_ensure_no_connection_back(self,
216 network_suggestions,
217 expected_ssid):
218 # Remove suggestion trigger disconnect and wait for the disconnect.
219 self.dut.log.info("Removing network suggestions")
220 asserts.assert_true(
221 self.dut.droid.wifiRemoveNetworkSuggestions(network_suggestions),
222 "Failed to remove suggestions")
223 wutils.wait_for_disconnect(self.dut)
224 self.dut.ed.clear_all_events()
225
226 # Now ensure that we didn't connect back.
227 asserts.assert_false(
228 wutils.wait_for_connect(self.dut, expected_ssid, assert_on_fail=False),
229 "Device should not connect back")
230
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700231 def _test_connect_to_wifi_network_reboot_config_store(self,
232 network_suggestions,
233 wifi_network):
234 """ Test network suggestion with reboot config store
235
236 Args:
237 1. network_suggestions: network suggestions in list to add to the device.
238 2. wifi_network: expected wifi network to connect to
239 """
240
241 self.add_suggestions_and_ensure_connection(
242 network_suggestions, wifi_network[WifiEnums.SSID_KEY], None)
243
244 # Reboot and wait for connection back to the same suggestion.
245 self.dut.reboot()
246 time.sleep(DEFAULT_TIMEOUT)
247
248 wutils.wait_for_connect(self.dut, wifi_network[WifiEnums.SSID_KEY])
249
Nate Jiang68f3ffa2019-08-07 15:23:49 -0700250 self.remove_suggestions_disconnect_and_ensure_no_connection_back(
251 network_suggestions, wifi_network[WifiEnums.SSID_KEY])
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700252
Nate(Qiang) Jiang8a62e372019-12-19 11:04:05 -0800253 # Reboot with empty suggestion, verify user approval is kept.
254 self.dut.reboot()
255 time.sleep(DEFAULT_TIMEOUT)
256 asserts.assert_true(self.is_approved(), "User approval should be kept")
257
Roshan Piusf028bd32018-12-06 15:18:21 -0800258 @test_tracker_info(uuid="bda8ed20-4382-4380-831a-64cf77eca108")
Roshan Piusd1204442018-11-12 12:20:39 -0800259 def test_connect_to_wpa_psk_2g(self):
260 """ Adds a network suggestion and ensure that the device connected.
261
262 Steps:
263 1. Send a network suggestion to the device.
264 2. Wait for the device to connect to it.
265 3. Ensure that we did not receive the post connection broadcast
266 (isAppInteractionRequired = False).
Roshan Piusffc29912019-01-18 13:39:49 -0800267 4. Remove the suggestions and ensure the device does not connect back.
Roshan Piusd1204442018-11-12 12:20:39 -0800268 """
269 self.add_suggestions_and_ensure_connection(
270 [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY],
271 False)
Nate Jiang1ef58c32019-07-15 19:13:26 -0700272
Nate Jiang68f3ffa2019-08-07 15:23:49 -0700273 self.remove_suggestions_disconnect_and_ensure_no_connection_back(
274 [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY])
Roshan Piusd1204442018-11-12 12:20:39 -0800275
Girish Moturu10c6b2c2020-04-08 09:28:48 -0700276 @test_tracker_info(uuid="b2df6ebe-9c5b-4e84-906a-e76f96fcef56")
Roshan Pius67e7c512020-04-07 14:40:18 -0700277 def test_connect_to_wpa_psk_2g_with_screen_off(self):
278 """ Adds a network suggestion and ensure that the device connected
279 when the screen is off.
280
281 Steps:
282 1. Send an invalid suggestion to the device (Needed for PNO scan to start).
283 2. Toggle screen off.
284 3. Send a valid network suggestion to the device.
285 4. Wait for the device to connect to it.
286 5. Ensure that we did not receive the post connection broadcast
287 (isAppInteractionRequired = False).
288 6. Remove the suggestions and ensure the device does not connect back.
289 """
290 invalid_suggestion = self.wpa_psk_5g
291 network_ssid = invalid_suggestion.pop(WifiEnums.SSID_KEY)
292 invalid_suggestion[WifiEnums.SSID_KEY] = network_ssid + "blah"
293
294 self.dut.log.info("Adding invalid suggestions")
295 asserts.assert_true(
296 self.dut.droid.wifiAddNetworkSuggestions([invalid_suggestion]),
297 "Failed to add suggestions")
298
299 # Approve suggestions by the app.
300 self.set_approved(True)
301
302 # Turn screen off to ensure PNO kicks-in.
303 self.dut.droid.wakeLockRelease()
304 self.dut.droid.goToSleepNow()
305 time.sleep(10)
306
307 # Add valid suggestions & ensure we restart PNO and connect to it.
308 self.add_suggestions_and_ensure_connection(
309 [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY],
310 False)
311
312 self.remove_suggestions_disconnect_and_ensure_no_connection_back(
313 [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY])
314
Girish Moturu10c6b2c2020-04-08 09:28:48 -0700315 @test_tracker_info(uuid="f18bf994-ef3b-45d6-aba0-dd6338b07979")
Roshan Pius55fb7c42020-04-03 14:47:18 -0700316 def test_connect_to_wpa_psk_2g_modify_meteredness(self):
317 """ Adds a network suggestion and ensure that the device connected.
318 Change the meteredness of the network after the connection.
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. Mark the network suggestion metered.
326 5. Ensure that the device disconnected and reconnected back to the
327 suggestion.
328 6. Mark the network suggestion unmetered.
329 7. Ensure that the device did not disconnect.
330 8. Remove the suggestions and ensure the device does not connect back.
331 """
332 self.add_suggestions_and_ensure_connection(
333 [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY],
334 False)
335
336 mod_suggestion = self.wpa_psk_2g
337
338 # Mark the network metered.
339 self.dut.log.debug("Marking suggestion as metered")
340 mod_suggestion[WifiEnums.IS_SUGGESTION_METERED] = True
341 asserts.assert_true(
342 self.dut.droid.wifiAddNetworkSuggestions([mod_suggestion]),
343 "Failed to add suggestions")
344 # Wait for disconnect.
345 wutils.wait_for_disconnect(self.dut)
346 self.dut.log.info("Disconnected from network %s", mod_suggestion)
347 self.dut.ed.clear_all_events()
348 # Wait for reconnect.
349 wutils.wait_for_connect(self.dut, mod_suggestion[WifiEnums.SSID_KEY])
350
351 # Mark the network unmetered.
352 self.dut.log.debug("Marking suggestion as unmetered")
353 mod_suggestion[WifiEnums.IS_SUGGESTION_METERED] = False
354 asserts.assert_true(
355 self.dut.droid.wifiAddNetworkSuggestions([mod_suggestion]),
356 "Failed to add suggestions")
357 # Ensure there is no disconnect.
358 wutils.ensure_no_disconnect(self.dut)
359 self.dut.ed.clear_all_events()
360
361 self.remove_suggestions_disconnect_and_ensure_no_connection_back(
362 [mod_suggestion], mod_suggestion[WifiEnums.SSID_KEY])
363
364
Roshan Piusc6fceca2019-03-22 13:23:58 -0700365 @test_tracker_info(uuid="f54bc250-d9e9-4f00-8b5b-b866e8550b43")
366 def test_connect_to_highest_priority(self):
367 """
368 Adds network suggestions and ensures that device connects to
369 the suggestion with the highest priority.
370
371 Steps:
372 1. Send 2 network suggestions to the device (with different priorities).
373 2. Wait for the device to connect to the network with the highest
374 priority.
Nate Jiang172c6902019-09-09 17:54:33 -0700375 3. In-place modify network suggestions with priorities reversed
376 4. Restart wifi, wait for the device to connect to the network with the highest
377 priority.
378 5. Re-add the suggestions with the priorities reversed again.
379 6. Again wait for the device to connect to the network with the highest
Roshan Piusc6fceca2019-03-22 13:23:58 -0700380 priority.
381 """
382 network_suggestion_2g = self.wpa_psk_2g
383 network_suggestion_5g = self.wpa_psk_5g
384
385 # Add suggestions & wait for the connection event.
386 network_suggestion_2g[WifiEnums.PRIORITY] = 5
387 network_suggestion_5g[WifiEnums.PRIORITY] = 2
388 self.add_suggestions_and_ensure_connection(
389 [network_suggestion_2g, network_suggestion_5g],
390 self.wpa_psk_2g[WifiEnums.SSID_KEY],
391 None)
392
Nate Jiang172c6902019-09-09 17:54:33 -0700393 # In-place modify Reverse the priority, should be no disconnect
394 network_suggestion_2g[WifiEnums.PRIORITY] = 2
395 network_suggestion_5g[WifiEnums.PRIORITY] = 5
Roshan Pius67e7c512020-04-07 14:40:18 -0700396 self.dut.log.info("Modifying network suggestions")
Nate Jiang172c6902019-09-09 17:54:33 -0700397 asserts.assert_true(
398 self.dut.droid.wifiAddNetworkSuggestions([network_suggestion_2g,
399 network_suggestion_5g]),
400 "Failed to add suggestions")
401 wutils.ensure_no_disconnect(self.dut)
402
403 # Disable and re-enable wifi, should connect to higher priority
404 wutils.wifi_toggle_state(self.dut, False)
405 time.sleep(DEFAULT_TIMEOUT)
406 wutils.wifi_toggle_state(self.dut, True)
407 wutils.start_wifi_connection_scan_and_return_status(self.dut)
408 wutils.wait_for_connect(self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY])
409
Nate Jiang68f3ffa2019-08-07 15:23:49 -0700410 self.remove_suggestions_disconnect_and_ensure_no_connection_back(
Nate Jiang0878aef2019-09-16 13:33:26 -0700411 [], self.wpa_psk_5g[WifiEnums.SSID_KEY])
Roshan Piusc6fceca2019-03-22 13:23:58 -0700412
413 # Reverse the priority.
414 # Add suggestions & wait for the connection event.
Nate Jiang172c6902019-09-09 17:54:33 -0700415 network_suggestion_2g[WifiEnums.PRIORITY] = 5
416 network_suggestion_5g[WifiEnums.PRIORITY] = 2
Roshan Piusc6fceca2019-03-22 13:23:58 -0700417 self.add_suggestions_and_ensure_connection(
418 [network_suggestion_2g, network_suggestion_5g],
Nate Jiang0878aef2019-09-16 13:33:26 -0700419 self.wpa_psk_2g[WifiEnums.SSID_KEY],
Roshan Piusc6fceca2019-03-22 13:23:58 -0700420 None)
421
Roshan Piusf028bd32018-12-06 15:18:21 -0800422 @test_tracker_info(uuid="b1d27eea-23c8-4c4f-b944-ef118e4cc35f")
Roshan Piusd1204442018-11-12 12:20:39 -0800423 def test_connect_to_wpa_psk_2g_with_post_connection_broadcast(self):
424 """ Adds a network suggestion and ensure that the device connected.
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).
Roshan Piusffc29912019-01-18 13:39:49 -0800432 4. Remove the suggestions and ensure the device does not connect back.
Roshan Piusd1204442018-11-12 12:20:39 -0800433 """
434 network_suggestion = self.wpa_psk_2g
435 network_suggestion[WifiEnums.IS_APP_INTERACTION_REQUIRED] = True
436 self.add_suggestions_and_ensure_connection(
437 [network_suggestion], self.wpa_psk_2g[WifiEnums.SSID_KEY],
438 True)
Nate Jiang68f3ffa2019-08-07 15:23:49 -0700439 self.remove_suggestions_disconnect_and_ensure_no_connection_back(
440 [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY])
Roshan Piusd1204442018-11-12 12:20:39 -0800441
Roshan Piusf028bd32018-12-06 15:18:21 -0800442 @test_tracker_info(uuid="a036a24d-29c0-456d-ae6a-afdde34da710")
Roshan Piusd1204442018-11-12 12:20:39 -0800443 def test_connect_to_wpa_psk_5g_reboot_config_store(self):
444 """
445 Adds a network suggestion and ensure that the device connects to it
446 after reboot.
447
448 Steps:
449 1. Send a network suggestion to the device.
450 2. Wait for the device to connect to it.
451 3. Ensure that we did not receive the post connection broadcast
452 (isAppInteractionRequired = False).
453 4. Reboot the device.
454 5. Wait for the device to connect to back to it.
Roshan Piusffc29912019-01-18 13:39:49 -0800455 6. Remove the suggestions and ensure the device does not connect back.
Nate(Qiang) Jiang8a62e372019-12-19 11:04:05 -0800456 7. Reboot the device again, ensure user approval is kept
Roshan Piusd1204442018-11-12 12:20:39 -0800457 """
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700458 self._test_connect_to_wifi_network_reboot_config_store(
459 [self.wpa_psk_5g], self.wpa_psk_5g)
Roshan Piusd1204442018-11-12 12:20:39 -0800460
Girish Moturuc2033ae2019-07-31 09:04:36 -0700461 @test_tracker_info(uuid="61649a2b-0f00-4272-9b9b-40ad5944da31")
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700462 def test_connect_to_wpa_ent_config_aka_reboot_config_store(self):
463 """
464 Adds a network suggestion and ensure that the device connects to it
465 after reboot.
Roshan Piusd1204442018-11-12 12:20:39 -0800466
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700467 Steps:
468 1. Send a Enterprise AKA network suggestion to the device.
469 2. Wait for the device to connect to it.
470 3. Ensure that we did not receive the post connection broadcast.
471 4. Reboot the device.
472 5. Wait for the device to connect to the wifi network.
473 6. Remove suggestions and ensure device doesn't connect back to it.
Nate(Qiang) Jiang8a62e372019-12-19 11:04:05 -0800474 7. Reboot the device again, ensure user approval is kept
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700475 """
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800476 if "carrierId" in self.config_aka:
477 self.set_carrier_approved(self.config_aka["carrierId"], True)
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700478 self._test_connect_to_wifi_network_reboot_config_store(
479 [self.config_aka], self.ent_network_2g)
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800480 if "carrierId" in self.config_aka:
481 self.clear_carrier_approved(self.config_aka["carrierId"])
Roshan Piusd1204442018-11-12 12:20:39 -0800482
Girish Moturuc2033ae2019-07-31 09:04:36 -0700483 @test_tracker_info(uuid="98b2d40a-acb4-4a2f-aba1-b069e2a1d09d")
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700484 def test_connect_to_wpa_ent_config_ttls_pap_reboot_config_store(self):
485 """
486 Adds a network suggestion and ensure that the device connects to it
487 after reboot.
Roshan Piusffc29912019-01-18 13:39:49 -0800488
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700489 Steps:
490 1. Send a Enterprise TTLS PAP network suggestion to the device.
491 2. Wait for the device to connect to it.
492 3. Ensure that we did not receive the post connection broadcast.
493 4. Reboot the device.
494 5. Wait for the device to connect to the wifi network.
495 6. Remove suggestions and ensure device doesn't connect back to it.
Nate(Qiang) Jiang8a62e372019-12-19 11:04:05 -0800496 7. Reboot the device again, ensure user approval is kept
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700497 """
498 config = dict(self.config_ttls)
499 config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.PAP.value
500
501 self._test_connect_to_wifi_network_reboot_config_store(
502 [config], self.ent_network_2g)
Roshan Piusffc29912019-01-18 13:39:49 -0800503
Roshan Pius3e3bd342019-01-09 13:55:17 -0800504 @test_tracker_info(uuid="554b5861-22d0-4922-a5f4-712b4cf564eb")
505 def test_fail_to_connect_to_wpa_psk_5g_when_not_approved(self):
506 """
507 Adds a network suggestion and ensure that the device does not
508 connect to it until we approve the app.
509
510 Steps:
511 1. Send a network suggestion to the device with the app not approved.
512 2. Ensure the network is present in scan results, but we don't connect
513 to it.
514 3. Now approve the app.
515 4. Wait for the device to connect to it.
516 """
Roshan Pius67e7c512020-04-07 14:40:18 -0700517 self.dut.log.info("Adding network suggestions")
Roshan Pius3e3bd342019-01-09 13:55:17 -0800518 asserts.assert_true(
519 self.dut.droid.wifiAddNetworkSuggestions([self.wpa_psk_5g]),
520 "Failed to add suggestions")
521
522 # Disable suggestions by the app.
523 self.set_approved(False)
524
525 # Ensure the app is not approved.
526 asserts.assert_false(
527 self.is_approved(),
528 "Suggestions should be disabled")
529
530 # Start a new scan to trigger auto-join.
531 wutils.start_wifi_connection_scan_and_ensure_network_found(
532 self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY])
533
534 # Ensure we don't connect to the network.
535 asserts.assert_false(
536 wutils.wait_for_connect(
537 self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY], assert_on_fail=False),
538 "Should not connect to network suggestions from unapproved app")
539
Roshan Pius67e7c512020-04-07 14:40:18 -0700540 self.dut.log.info("Enabling suggestions from test")
Roshan Pius3e3bd342019-01-09 13:55:17 -0800541 # Now Enable suggestions by the app & ensure we connect to the network.
542 self.set_approved(True)
543
544 # Ensure the app is approved.
545 asserts.assert_true(
546 self.is_approved(),
547 "Suggestions should be enabled")
548
549 # Start a new scan to trigger auto-join.
550 wutils.start_wifi_connection_scan_and_ensure_network_found(
551 self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY])
552
553 wutils.wait_for_connect(self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY])
Roshan Pius89b22bd2019-01-24 14:12:49 -0800554
Roshan Pius3d57f132019-01-28 10:25:18 -0800555 @test_tracker_info(uuid="98400dea-776e-4a0a-9024-18845b27331c")
Roshan Pius89b22bd2019-01-24 14:12:49 -0800556 def test_fail_to_connect_to_wpa_psk_2g_after_user_forgot_network(self):
557 """
558 Adds a network suggestion and ensures that the device does not
559 connect to it after the user forgot the network previously.
560
561 Steps:
562 1. Send a network suggestion to the device with
563 isAppInteractionRequired set.
564 2. Wait for the device to connect to it.
565 3. Ensure that we did receive the post connection broadcast
566 (isAppInteractionRequired = True).
567 4. Simulate user forgetting the network and the device does not
568 connecting back even though the suggestion is active from the app.
569 """
570 network_suggestion = self.wpa_psk_2g
571 network_suggestion[WifiEnums.IS_APP_INTERACTION_REQUIRED] = True
572 self.add_suggestions_and_ensure_connection(
573 [network_suggestion], self.wpa_psk_2g[WifiEnums.SSID_KEY],
574 True)
575
Nate(Qiang) Jiangd3424642020-03-02 19:52:59 -0800576 # Simulate user disconnect the network.
577 self.dut.droid.wifiUserDisconnectNetwork(
Roshan Pius89b22bd2019-01-24 14:12:49 -0800578 self.wpa_psk_2g[WifiEnums.SSID_KEY])
579 wutils.wait_for_disconnect(self.dut)
580 self.dut.log.info("Disconnected from network %s", self.wpa_psk_2g)
581 self.dut.ed.clear_all_events()
582
583 # Now ensure that we don't connect back even though the suggestion
584 # is still active.
585 asserts.assert_false(
586 wutils.wait_for_connect(self.dut,
587 self.wpa_psk_2g[WifiEnums.SSID_KEY],
588 assert_on_fail=False),
589 "Device should not connect back")
Nate Jiang20af5e82019-08-08 12:45:24 -0700590
591 @test_tracker_info(uuid="93c86b05-fa56-4d79-ad27-009a16f691b1")
592 def test_connect_to_hidden_network(self):
593 """
594 Adds a network suggestion with hidden SSID config, ensure device can scan
595 and connect to this network.
596
597 Steps:
598 1. Send a hidden network suggestion to the device.
599 2. Wait for the device to connect to it.
600 3. Ensure that we did not receive the post connection broadcast
601 (isAppInteractionRequired = False).
602 4. Remove the suggestions and ensure the device does not connect back.
603 """
604 asserts.skip_if(not hasattr(self, "hidden_networks"), "No hidden networks, skip this test")
605
606 network_suggestion = self.hidden_network
607 self.add_suggestions_and_ensure_connection(
608 [network_suggestion], network_suggestion[WifiEnums.SSID_KEY], False)
609 self.remove_suggestions_disconnect_and_ensure_no_connection_back(
610 [network_suggestion], network_suggestion[WifiEnums.SSID_KEY])
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700611
Girish Moturua5d28482019-10-23 10:15:37 -0700612 @test_tracker_info(uuid="806dff14-7543-482b-bd0a-598de59374b3")
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700613 def test_connect_to_passpoint_network_with_post_connection_broadcast(self):
614 """ Adds a passpoint network suggestion and ensure that the device connected.
615
616 Steps:
617 1. Send a network suggestion to the device.
618 2. Wait for the device to connect to it.
619 3. Ensure that we did receive the post connection broadcast
620 (isAppInteractionRequired = true).
621 4. Remove the suggestions and ensure the device does not connect back.
622 """
623 asserts.skip_if(not hasattr(self, "passpoint_networks"),
624 "No passpoint networks, skip this test")
Girish Moturua069a4a2019-10-23 13:21:42 -0700625 passpoint_config = self.passpoint_networks[ATT]
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700626 passpoint_config[WifiEnums.IS_APP_INTERACTION_REQUIRED] = True
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800627 if "carrierId" in passpoint_config:
628 self.set_carrier_approved(passpoint_config["carrierId"], True)
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700629 self.add_suggestions_and_ensure_connection([passpoint_config],
630 passpoint_config[WifiEnums.SSID_KEY], True)
631 self.remove_suggestions_disconnect_and_ensure_no_connection_back(
632 [passpoint_config], passpoint_config[WifiEnums.SSID_KEY])
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800633 if "carrierId" in passpoint_config:
634 self.clear_carrier_approved(passpoint_config["carrierId"])
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700635
Girish Moturua5d28482019-10-23 10:15:37 -0700636 @test_tracker_info(uuid="159b8b8c-fb00-4d4e-a29f-606881dcbf44")
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700637 def test_connect_to_passpoint_network_reboot_config_store(self):
638 """
639 Adds a passpoint network suggestion and ensure that the device connects to it
640 after reboot.
641
642 Steps:
643 1. Send a network suggestion to the device.
644 2. Wait for the device to connect to it.
645 3. Ensure that we did not receive the post connection broadcast
646 (isAppInteractionRequired = False).
647 4. Reboot the device.
648 5. Wait for the device to connect to back to it.
649 6. Remove the suggestions and ensure the device does not connect back.
Nate(Qiang) Jiang8a62e372019-12-19 11:04:05 -0800650 7. Reboot the device again, ensure user approval is kept
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700651 """
652 asserts.skip_if(not hasattr(self, "passpoint_networks"),
653 "No passpoint networks, skip this test")
Girish Moturua069a4a2019-10-23 13:21:42 -0700654 passpoint_config = self.passpoint_networks[ATT]
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800655 if "carrierId" in passpoint_config:
656 self.set_carrier_approved(passpoint_config["carrierId"], True)
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700657 self._test_connect_to_wifi_network_reboot_config_store([passpoint_config],
658 passpoint_config)
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800659 if "carrierId" in passpoint_config:
660 self.clear_carrier_approved(passpoint_config["carrierId"])
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700661
Girish Moturua5d28482019-10-23 10:15:37 -0700662 @test_tracker_info(uuid="34f3d28a-bedf-43fe-a12d-2cfadf6bc6eb")
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700663 def test_fail_to_connect_to_passpoint_network_when_not_approved(self):
664 """
665 Adds a passpoint network suggestion and ensure that the device does not
666 connect to it until we approve the app.
667
668 Steps:
669 1. Send a network suggestion to the device with the app not approved.
670 2. Ensure the network is present in scan results, but we don't connect
671 to it.
672 3. Now approve the app.
673 4. Wait for the device to connect to it.
674 """
675 asserts.skip_if(not hasattr(self, "passpoint_networks"),
676 "No passpoint networks, skip this test")
Girish Moturua069a4a2019-10-23 13:21:42 -0700677 passpoint_config = self.passpoint_networks[ATT]
Nate(Qiang) Jiang647afb92020-02-06 13:44:14 -0800678 if "carrierId" in passpoint_config:
679 self.set_carrier_approved(passpoint_config["carrierId"], True)
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700680 self.dut.log.info("Adding network suggestions")
681 asserts.assert_true(
682 self.dut.droid.wifiAddNetworkSuggestions([passpoint_config]),
683 "Failed to add suggestions")
684
685 # Disable suggestions by the app.
686 self.set_approved(False)
687
688 # Ensure the app is not approved.
689 asserts.assert_false(
690 self.is_approved(),
691 "Suggestions should be disabled")
692
693 # Start a new scan to trigger auto-join.
694 wutils.start_wifi_connection_scan_and_ensure_network_found(
695 self.dut, passpoint_config[WifiEnums.SSID_KEY])
696
697 # Ensure we don't connect to the network.
698 asserts.assert_false(
699 wutils.wait_for_connect(
700 self.dut, passpoint_config[WifiEnums.SSID_KEY], assert_on_fail=False),
701 "Should not connect to network suggestions from unapproved app")
702
Roshan Pius67e7c512020-04-07 14:40:18 -0700703 self.dut.log.info("Enabling suggestions from test")
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700704 # Now Enable suggestions by the app & ensure we connect to the network.
705 self.set_approved(True)
706
707 # Ensure the app is approved.
708 asserts.assert_true(
709 self.is_approved(),
710 "Suggestions should be enabled")
711
712 # Start a new scan to trigger auto-join.
713 wutils.start_wifi_connection_scan_and_ensure_network_found(
714 self.dut, passpoint_config[WifiEnums.SSID_KEY])
Nate(Qiang) Jiang051b8142019-11-01 17:23:33 -0700715 time.sleep(PASSPOINT_TIMEOUT)
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700716 wutils.wait_for_connect(self.dut, passpoint_config[WifiEnums.SSID_KEY])
Nate(Qiang) Jiang647afb92020-02-06 13:44:14 -0800717 if "carrierId" in passpoint_config:
718 self.clear_carrier_approved(passpoint_config["carrierId"])
Nate(Qiang) Jiange7a400e2020-01-16 17:27:23 -0800719
Girish Moturu7e30c782020-02-05 12:37:06 -0800720 @test_tracker_info(uuid="cf624cda-4d25-42f1-80eb-6c717fb08338")
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800721 def test_fail_to_connect_to_passpoint_network_when_imsi_protection_exemption_not_approved(self):
722 """
723 Adds a passpoint network suggestion using SIM credential without IMSI privacy protection.
724 Before user approves the exemption, ensure that the device does noconnect to it until we
725 approve the carrier exemption.
726
727 Steps:
728 1. Send a network suggestion to the device with IMSI protection exemption not approved.
729 2. Ensure the network is present in scan results, but we don't connect
730 to it.
731 3. Now approve the carrier.
732 4. Wait for the device to connect to it.
733 """
734 asserts.skip_if(not hasattr(self, "passpoint_networks"),
735 "No passpoint networks, skip this test")
736 passpoint_config = self.passpoint_networks[ATT]
737 asserts.skip_if("carrierId" not in passpoint_config,
738 "Not a SIM based passpoint network, skip this test")
739
Nate(Qiang) Jiang92251a62020-02-28 10:13:30 -0800740 # Ensure the carrier is not approved.
741 asserts.assert_false(
742 self.is_carrier_approved(passpoint_config["carrierId"]),
743 "Carrier shouldn't be approved")
744
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800745 self.dut.log.info("Adding network suggestions")
746 asserts.assert_true(
747 self.dut.droid.wifiAddNetworkSuggestions([passpoint_config]),
748 "Failed to add suggestions")
749
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800750 # Start a new scan to trigger auto-join.
751 wutils.start_wifi_connection_scan_and_ensure_network_found(
752 self.dut, passpoint_config[WifiEnums.SSID_KEY])
753
754 # Ensure we don't connect to the network.
755 asserts.assert_false(
756 wutils.wait_for_connect(
757 self.dut, passpoint_config[WifiEnums.SSID_KEY], assert_on_fail=False),
758 "Should not connect to network suggestions from unapproved app")
759
760 self.dut.log.info("Enabling suggestions from test")
761 # Now approve IMSI protection exemption by carrier & ensure we connect to the network.
762 self.set_carrier_approved(passpoint_config["carrierId"], True)
763
764 # Ensure the carrier is approved.
765 asserts.assert_true(
766 self.is_carrier_approved(passpoint_config["carrierId"]),
767 "Carrier should be approved")
768
769 # Start a new scan to trigger auto-join.
770 wutils.start_wifi_connection_scan_and_ensure_network_found(
771 self.dut, passpoint_config[WifiEnums.SSID_KEY])
772 time.sleep(PASSPOINT_TIMEOUT)
773 wutils.wait_for_connect(self.dut, passpoint_config[WifiEnums.SSID_KEY])
774 self.clear_carrier_approved(passpoint_config["carrierId"])
775
Girish Moturu31f58f22020-01-30 18:54:40 -0800776 @test_tracker_info(uuid="e35f99c8-78a4-4b96-9258-f9834b6ddd33")
Nate(Qiang) Jiange7a400e2020-01-16 17:27:23 -0800777 def test_initial_auto_join_on_network_suggestion(self):
778 """
779 Add a network suggestion with enableAutojoin bit set to false, ensure the device doesn't
780 auto connect to this network
781
782 Steps:
783 1. Create a network suggestion.
784 2. Set EnableAutojoin to false.
785 3. Add this suggestion
786 4. Ensure device doesn't connect to his network
787 """
Girish Moturu2155dc12020-01-21 15:16:17 -0800788 network_suggestion = self.wpa_psk_5g
Nate(Qiang) Jiange7a400e2020-01-16 17:27:23 -0800789 # Set suggestion auto join initial to false.
Nate Jiang8b2b4b82020-03-13 13:49:07 -0700790 network_suggestion[AutoJoin] = False
Nate(Qiang) Jiange7a400e2020-01-16 17:27:23 -0800791 self.dut.log.info("Adding network suggestions")
792 asserts.assert_true(
793 self.dut.droid.wifiAddNetworkSuggestions([network_suggestion]),
794 "Failed to add suggestions")
795 # Enable suggestions by the app.
796 self.dut.log.debug("Enabling suggestions from test")
797 self.set_approved(True)
798 wutils.start_wifi_connection_scan_and_return_status(self.dut)
799 asserts.assert_false(
800 wutils.wait_for_connect(self.dut, network_suggestion[WifiEnums.SSID_KEY],
801 assert_on_fail=False), "Device should not connect.")
802
Girish Moturu31f58f22020-01-30 18:54:40 -0800803 @test_tracker_info(uuid="ff4e451f-a380-4ff5-a5c2-dd9b1633d5e5")
Nate(Qiang) Jiange7a400e2020-01-16 17:27:23 -0800804 def test_user_override_auto_join_on_network_suggestion(self):
805 """
806 Add a network suggestion, user change the auto join to false, ensure the device doesn't
807 auto connect to this network
808
809 Steps:
810 1. Create a network suggestion.
811 2. Add this suggestion, and ensure we connect to this network
812 3. Simulate user change the auto join to false.
813 4. Toggle the Wifi off and on
814 4. Ensure device doesn't connect to his network
815 """
Girish Moturu2155dc12020-01-21 15:16:17 -0800816 network_suggestion = self.wpa_psk_5g
Nate(Qiang) Jiange7a400e2020-01-16 17:27:23 -0800817 self.add_suggestions_and_ensure_connection([network_suggestion],
818 network_suggestion[WifiEnums.SSID_KEY], False)
819 wifi_info = self.dut.droid.wifiGetConnectionInfo()
820 self.dut.log.info(wifi_info)
821 network_id = wifi_info[WifiEnums.NETID_KEY]
822 # Simulate user disable auto join through Settings.
823 self.dut.log.info("Disable auto join on suggestion")
824 self.dut.droid.wifiEnableAutojoin(network_id, False)
825 wutils.wifi_toggle_state(self.dut, False)
826 wutils.wifi_toggle_state(self.dut, True)
827 asserts.assert_false(
828 wutils.wait_for_connect(self.dut, network_suggestion[WifiEnums.SSID_KEY],
829 assert_on_fail=False), "Device should not connect.")
Nate Jiang8b2b4b82020-03-13 13:49:07 -0700830
Girish Moturu10c6b2c2020-04-08 09:28:48 -0700831 @test_tracker_info(uuid="32201b1c-76a0-46dc-9983-2cd24312a783")
Nate Jiang8b2b4b82020-03-13 13:49:07 -0700832 def test_untrusted_suggestion_without_untrusted_request(self):
833 """
834 Add an untrusted network suggestion, when no untrusted request, will not connect to it.
835 Steps:
836 1. Create a untrusted network suggestion.
837 2. Add this suggestion, and ensure device do not connect to this network
838 3. Request untrusted network and ensure device connect to this network
839 """
840 network_suggestion = self.open_5g
841 network_suggestion[Untrusted] = True
842 self.dut.log.info("Adding network suggestions")
843 asserts.assert_true(
844 self.dut.droid.wifiAddNetworkSuggestions([network_suggestion]),
845 "Failed to add suggestions")
846 # Start a new scan to trigger auto-join.
847 wutils.start_wifi_connection_scan_and_ensure_network_found(
848 self.dut, network_suggestion[WifiEnums.SSID_KEY])
849
850 # Ensure we don't connect to the network.
851 asserts.assert_false(
852 wutils.wait_for_connect(
853 self.dut, network_suggestion[WifiEnums.SSID_KEY], assert_on_fail=False),
854 "Should not connect to untrusted network suggestions with no request")
855 network_request = {ClearCapabilities: True, TransportType: 1}
856 req_key = self.dut.droid.connectivityRequestNetwork(network_request)
857
858 # Start a new scan to trigger auto-join.
859 wutils.start_wifi_connection_scan_and_ensure_network_found(
860 self.dut, network_suggestion[WifiEnums.SSID_KEY])
861
862 wutils.wait_for_connect(
863 self.dut, network_suggestion[WifiEnums.SSID_KEY], assert_on_fail=False)
864
865 self.dut.droid.connectivityUnregisterNetworkCallback(req_key)
866