blob: ba37b4e2ccbc7c9d53bf3a84f19f1d16a36f3943 [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 = [
Nate Jiang165c2652020-07-07 10:56:07 -070069 "open_network", "reference_networks", "hidden_networks", "radius_conf_2g",
70 "radius_conf_5g", "ca_cert", "eap_identity", "eap_password", "passpoint_networks",
71 "altsubject_match"]
Girish Moturu3c99eb62020-06-19 13:05:26 -070072 self.unpack_userparams(opt_param_names=opt_param,)
Roshan Piusd1204442018-11-12 12:20:39 -080073
74 if "AccessPoint" in self.user_params:
Girish Moturub1e7a5c2019-07-29 13:48:11 -070075 self.legacy_configure_ap_and_start(
76 wpa_network=True, ent_network=True,
77 radius_conf_2g=self.radius_conf_2g,
78 radius_conf_5g=self.radius_conf_5g,)
Roshan Piusd1204442018-11-12 12:20:39 -080079
Girish Moturua069a4a2019-10-23 13:21:42 -070080 if hasattr(self, "reference_networks") and \
81 isinstance(self.reference_networks, list):
82 self.wpa_psk_2g = self.reference_networks[0]["2g"]
83 self.wpa_psk_5g = self.reference_networks[0]["5g"]
84 if hasattr(self, "open_network") and isinstance(self.open_network,list):
Nate Jiang68f3ffa2019-08-07 15:23:49 -070085 self.open_2g = self.open_network[0]["2g"]
86 self.open_5g = self.open_network[0]["5g"]
Girish Moturua069a4a2019-10-23 13:21:42 -070087 if hasattr(self, "ent_networks") and isinstance(self.ent_networks,list):
Nate Jiang68f3ffa2019-08-07 15:23:49 -070088 self.ent_network_2g = self.ent_networks[0]["2g"]
89 self.ent_network_5g = self.ent_networks[0]["5g"]
90 self.config_aka = {
91 Ent.EAP: int(EAP.AKA),
92 WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY],
Girish Moturu7e30c782020-02-05 12:37:06 -080093 "carrierId": str(self.dut.droid.telephonyGetSimCarrierId()),
Nate Jiang68f3ffa2019-08-07 15:23:49 -070094 }
95 self.config_ttls = {
96 Ent.EAP: int(EAP.TTLS),
97 Ent.CA_CERT: self.ca_cert,
98 Ent.IDENTITY: self.eap_identity,
99 Ent.PASSWORD: self.eap_password,
100 Ent.PHASE2: int(EapPhase2.MSCHAPV2),
101 WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY],
Girish Moturu3c99eb62020-06-19 13:05:26 -0700102 Ent.ALTSUBJECT_MATCH: self.altsubject_match,
Nate Jiang68f3ffa2019-08-07 15:23:49 -0700103 }
Girish Moturua069a4a2019-10-23 13:21:42 -0700104 if hasattr(self, "hidden_networks") and \
105 isinstance(self.hidden_networks, list):
106 self.hidden_network = self.hidden_networks[0]
Roshan Piusd1204442018-11-12 12:20:39 -0800107 self.dut.droid.wifiRemoveNetworkSuggestions([])
Girish Moturu1fa47172020-04-13 11:36:32 -0700108 self.dut.adb.shell(
109 "pm disable com.google.android.apps.carrier.carrierwifi")
Roshan Piusd1204442018-11-12 12:20:39 -0800110
111 def setup_test(self):
112 self.dut.droid.wakeLockAcquireBright()
113 self.dut.droid.wakeUpNow()
Nate Jiang5fdbbe12020-05-06 11:35:51 -0700114 self.dut.unlock_screen()
Nate(Qiang) Jiangd3424642020-03-02 19:52:59 -0800115 self.clear_user_disabled_networks()
Roshan Piusd1204442018-11-12 12:20:39 -0800116 wutils.wifi_toggle_state(self.dut, True)
Roshan Pius159222c2019-02-07 10:33:32 -0800117 self.dut.ed.clear_all_events()
Nate(Qiang) Jiang92251a62020-02-28 10:13:30 -0800118 self.clear_carrier_approved(str(self.dut.droid.telephonyGetSimCarrierId()))
Roshan Piusd1204442018-11-12 12:20:39 -0800119
120 def teardown_test(self):
121 self.dut.droid.wakeLockRelease()
122 self.dut.droid.goToSleepNow()
123 self.dut.droid.wifiRemoveNetworkSuggestions([])
Roshan Piusffc29912019-01-18 13:39:49 -0800124 self.dut.droid.wifiDisconnect()
Roshan Piusd1204442018-11-12 12:20:39 -0800125 wutils.reset_wifi(self.dut)
Nate Jiang1ef58c32019-07-15 19:13:26 -0700126 wutils.wifi_toggle_state(self.dut, False)
Roshan Piusd1204442018-11-12 12:20:39 -0800127 self.dut.ed.clear_all_events()
Nate(Qiang) Jiang92251a62020-02-28 10:13:30 -0800128 self.clear_carrier_approved(str(self.dut.droid.telephonyGetSimCarrierId()))
Roshan Piusd1204442018-11-12 12:20:39 -0800129
130 def on_fail(self, test_name, begin_time):
131 self.dut.take_bug_report(test_name, begin_time)
132 self.dut.cat_adb_log(test_name, begin_time)
133
134 def teardown_class(self):
Girish Moturu1fa47172020-04-13 11:36:32 -0700135 self.dut.adb.shell(
136 "pm enable com.google.android.apps.carrier.carrierwifi")
Roshan Piusd1204442018-11-12 12:20:39 -0800137 if "AccessPoint" in self.user_params:
138 del self.user_params["reference_networks"]
139 del self.user_params["open_network"]
140
141 """Helper Functions"""
Roshan Pius3e3bd342019-01-09 13:55:17 -0800142 def set_approved(self, approved):
143 self.dut.log.debug("Setting suggestions from sl4a app "
144 + "approved" if approved else "not approved")
145 self.dut.adb.shell("cmd wifi network-suggestions-set-user-approved"
146 + " " + SL4A_APK_NAME
147 + " " + ("yes" if approved else "no"))
148
149 def is_approved(self):
150 is_approved_str = self.dut.adb.shell(
151 "cmd wifi network-suggestions-has-user-approved"
152 + " " + SL4A_APK_NAME)
153 return True if (is_approved_str == "yes") else False
154
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800155 def set_carrier_approved(self, carrier_id, approved):
156 self.dut.log.debug(("Setting IMSI protection exemption for carrier: " + carrier_id
157 + "approved" if approved else "not approved"))
158 self.dut.adb.shell("cmd wifi imsi-protection-exemption-set-user-approved-for-carrier"
159 + " " + carrier_id
160 + " " + ("yes" if approved else "no"))
161
162 def is_carrier_approved(self, carrier_id):
163 is_approved_str = self.dut.adb.shell(
164 "cmd wifi imsi-protection-exemption-has-user-approved-for-carrier"
165 + " " + carrier_id)
166 return True if (is_approved_str == "yes") else False
167
168 def clear_carrier_approved(self, carrier_id):
169 self.dut.adb.shell(
170 "cmd wifi imsi-protection-exemption-clear-user-approved-for-carrier"
171 + " " + carrier_id)
172
Nate(Qiang) Jiangd3424642020-03-02 19:52:59 -0800173 def clear_user_disabled_networks(self):
174 self.dut.log.debug("Clearing user disabled networks")
Roshan Pius89b22bd2019-01-24 14:12:49 -0800175 self.dut.adb.shell(
Nate(Qiang) Jiangd3424642020-03-02 19:52:59 -0800176 "cmd wifi clear-user-disabled-networks")
Roshan Pius89b22bd2019-01-24 14:12:49 -0800177
Roshan Piusd1204442018-11-12 12:20:39 -0800178 def add_suggestions_and_ensure_connection(self, network_suggestions,
179 expected_ssid,
180 expect_post_connection_broadcast):
Roshan Pius3702f242019-02-28 09:14:40 -0800181 if expect_post_connection_broadcast is not None:
182 self.dut.droid.wifiStartTrackingNetworkSuggestionStateChange()
183
Nate(Qiang) Jiange7a400e2020-01-16 17:27:23 -0800184 self.dut.log.info("Adding network suggestions")
Roshan Piusd1204442018-11-12 12:20:39 -0800185 asserts.assert_true(
186 self.dut.droid.wifiAddNetworkSuggestions(network_suggestions),
187 "Failed to add suggestions")
Roshan Pius3e3bd342019-01-09 13:55:17 -0800188 # Enable suggestions by the app.
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700189 self.dut.log.debug("Enabling suggestions from test")
Roshan Pius3e3bd342019-01-09 13:55:17 -0800190 self.set_approved(True)
lutina49d3e512019-07-05 14:42:33 +0800191 wutils.start_wifi_connection_scan_and_return_status(self.dut)
Nate(Qiang) Jiang051b8142019-11-01 17:23:33 -0700192 # if suggestion is passpoint wait longer for connection.
193 if "profile" in network_suggestions:
194 time.sleep(PASSPOINT_TIMEOUT)
Roshan Piusd1204442018-11-12 12:20:39 -0800195 wutils.wait_for_connect(self.dut, expected_ssid)
196
197 if expect_post_connection_broadcast is None:
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700198 return
Roshan Piusd1204442018-11-12 12:20:39 -0800199
200 # Check if we expected to get the broadcast.
201 try:
Roshan Piusd1204442018-11-12 12:20:39 -0800202 event = self.dut.ed.pop_event(
203 wifi_constants.WIFI_NETWORK_SUGGESTION_POST_CONNECTION, 60)
Roshan Piusd1204442018-11-12 12:20:39 -0800204 except queue.Empty:
205 if expect_post_connection_broadcast:
206 raise signals.TestFailure(
207 "Did not receive post connection broadcast")
208 else:
209 if not expect_post_connection_broadcast:
210 raise signals.TestFailure(
211 "Received post connection broadcast")
Roshan Pius3702f242019-02-28 09:14:40 -0800212 finally:
213 self.dut.droid.wifiStopTrackingNetworkSuggestionStateChange()
Roshan Piusff6ca4c2019-03-26 13:53:31 -0700214 self.dut.ed.clear_all_events()
Roshan Piusd1204442018-11-12 12:20:39 -0800215
Nate Jiang68f3ffa2019-08-07 15:23:49 -0700216 def remove_suggestions_disconnect_and_ensure_no_connection_back(self,
217 network_suggestions,
218 expected_ssid):
219 # Remove suggestion trigger disconnect and wait for the disconnect.
220 self.dut.log.info("Removing network suggestions")
221 asserts.assert_true(
222 self.dut.droid.wifiRemoveNetworkSuggestions(network_suggestions),
223 "Failed to remove suggestions")
224 wutils.wait_for_disconnect(self.dut)
225 self.dut.ed.clear_all_events()
226
227 # Now ensure that we didn't connect back.
228 asserts.assert_false(
229 wutils.wait_for_connect(self.dut, expected_ssid, assert_on_fail=False),
230 "Device should not connect back")
231
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700232 def _test_connect_to_wifi_network_reboot_config_store(self,
233 network_suggestions,
234 wifi_network):
235 """ Test network suggestion with reboot config store
236
237 Args:
238 1. network_suggestions: network suggestions in list to add to the device.
239 2. wifi_network: expected wifi network to connect to
240 """
241
242 self.add_suggestions_and_ensure_connection(
243 network_suggestions, wifi_network[WifiEnums.SSID_KEY], None)
244
245 # Reboot and wait for connection back to the same suggestion.
246 self.dut.reboot()
247 time.sleep(DEFAULT_TIMEOUT)
248
249 wutils.wait_for_connect(self.dut, wifi_network[WifiEnums.SSID_KEY])
250
Nate Jiang68f3ffa2019-08-07 15:23:49 -0700251 self.remove_suggestions_disconnect_and_ensure_no_connection_back(
252 network_suggestions, wifi_network[WifiEnums.SSID_KEY])
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700253
Nate(Qiang) Jiang8a62e372019-12-19 11:04:05 -0800254 # Reboot with empty suggestion, verify user approval is kept.
255 self.dut.reboot()
256 time.sleep(DEFAULT_TIMEOUT)
257 asserts.assert_true(self.is_approved(), "User approval should be kept")
258
Roshan Piusf028bd32018-12-06 15:18:21 -0800259 @test_tracker_info(uuid="bda8ed20-4382-4380-831a-64cf77eca108")
Roshan Piusd1204442018-11-12 12:20:39 -0800260 def test_connect_to_wpa_psk_2g(self):
261 """ Adds a network suggestion and ensure that the device connected.
262
263 Steps:
264 1. Send a network suggestion to the device.
265 2. Wait for the device to connect to it.
266 3. Ensure that we did not receive the post connection broadcast
267 (isAppInteractionRequired = False).
Roshan Piusffc29912019-01-18 13:39:49 -0800268 4. Remove the suggestions and ensure the device does not connect back.
Roshan Piusd1204442018-11-12 12:20:39 -0800269 """
270 self.add_suggestions_and_ensure_connection(
271 [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY],
272 False)
Nate Jiang1ef58c32019-07-15 19:13:26 -0700273
Nate Jiang68f3ffa2019-08-07 15:23:49 -0700274 self.remove_suggestions_disconnect_and_ensure_no_connection_back(
275 [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY])
Roshan Piusd1204442018-11-12 12:20:39 -0800276
Girish Moturu10c6b2c2020-04-08 09:28:48 -0700277 @test_tracker_info(uuid="b2df6ebe-9c5b-4e84-906a-e76f96fcef56")
Roshan Pius67e7c512020-04-07 14:40:18 -0700278 def test_connect_to_wpa_psk_2g_with_screen_off(self):
279 """ Adds a network suggestion and ensure that the device connected
280 when the screen is off.
281
282 Steps:
283 1. Send an invalid suggestion to the device (Needed for PNO scan to start).
284 2. Toggle screen off.
285 3. Send a valid network suggestion to the device.
286 4. Wait for the device to connect to it.
287 5. Ensure that we did not receive the post connection broadcast
288 (isAppInteractionRequired = False).
289 6. Remove the suggestions and ensure the device does not connect back.
290 """
291 invalid_suggestion = self.wpa_psk_5g
292 network_ssid = invalid_suggestion.pop(WifiEnums.SSID_KEY)
293 invalid_suggestion[WifiEnums.SSID_KEY] = network_ssid + "blah"
294
295 self.dut.log.info("Adding invalid suggestions")
296 asserts.assert_true(
297 self.dut.droid.wifiAddNetworkSuggestions([invalid_suggestion]),
298 "Failed to add suggestions")
299
300 # Approve suggestions by the app.
301 self.set_approved(True)
302
303 # Turn screen off to ensure PNO kicks-in.
304 self.dut.droid.wakeLockRelease()
305 self.dut.droid.goToSleepNow()
306 time.sleep(10)
307
308 # Add valid suggestions & ensure we restart PNO and connect to it.
309 self.add_suggestions_and_ensure_connection(
310 [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY],
311 False)
312
313 self.remove_suggestions_disconnect_and_ensure_no_connection_back(
314 [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY])
315
Girish Moturu10c6b2c2020-04-08 09:28:48 -0700316 @test_tracker_info(uuid="f18bf994-ef3b-45d6-aba0-dd6338b07979")
Roshan Pius55fb7c42020-04-03 14:47:18 -0700317 def test_connect_to_wpa_psk_2g_modify_meteredness(self):
318 """ Adds a network suggestion and ensure that the device connected.
319 Change the meteredness of the network after the connection.
320
321 Steps:
322 1. Send a network suggestion to the device.
323 2. Wait for the device to connect to it.
324 3. Ensure that we did not receive the post connection broadcast
325 (isAppInteractionRequired = False).
326 4. Mark the network suggestion metered.
327 5. Ensure that the device disconnected and reconnected back to the
328 suggestion.
329 6. Mark the network suggestion unmetered.
330 7. Ensure that the device did not disconnect.
331 8. Remove the suggestions and ensure the device does not connect back.
332 """
333 self.add_suggestions_and_ensure_connection(
334 [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY],
335 False)
336
337 mod_suggestion = self.wpa_psk_2g
338
339 # Mark the network metered.
340 self.dut.log.debug("Marking suggestion as metered")
341 mod_suggestion[WifiEnums.IS_SUGGESTION_METERED] = True
342 asserts.assert_true(
343 self.dut.droid.wifiAddNetworkSuggestions([mod_suggestion]),
344 "Failed to add suggestions")
345 # Wait for disconnect.
346 wutils.wait_for_disconnect(self.dut)
347 self.dut.log.info("Disconnected from network %s", mod_suggestion)
348 self.dut.ed.clear_all_events()
349 # Wait for reconnect.
350 wutils.wait_for_connect(self.dut, mod_suggestion[WifiEnums.SSID_KEY])
351
352 # Mark the network unmetered.
353 self.dut.log.debug("Marking suggestion as unmetered")
354 mod_suggestion[WifiEnums.IS_SUGGESTION_METERED] = False
355 asserts.assert_true(
356 self.dut.droid.wifiAddNetworkSuggestions([mod_suggestion]),
357 "Failed to add suggestions")
358 # Ensure there is no disconnect.
359 wutils.ensure_no_disconnect(self.dut)
360 self.dut.ed.clear_all_events()
361
362 self.remove_suggestions_disconnect_and_ensure_no_connection_back(
363 [mod_suggestion], mod_suggestion[WifiEnums.SSID_KEY])
364
365
Roshan Piusc6fceca2019-03-22 13:23:58 -0700366 @test_tracker_info(uuid="f54bc250-d9e9-4f00-8b5b-b866e8550b43")
367 def test_connect_to_highest_priority(self):
368 """
369 Adds network suggestions and ensures that device connects to
370 the suggestion with the highest priority.
371
372 Steps:
373 1. Send 2 network suggestions to the device (with different priorities).
374 2. Wait for the device to connect to the network with the highest
375 priority.
Nate Jiang172c6902019-09-09 17:54:33 -0700376 3. In-place modify network suggestions with priorities reversed
377 4. Restart wifi, wait for the device to connect to the network with the highest
378 priority.
379 5. Re-add the suggestions with the priorities reversed again.
380 6. Again wait for the device to connect to the network with the highest
Roshan Piusc6fceca2019-03-22 13:23:58 -0700381 priority.
382 """
383 network_suggestion_2g = self.wpa_psk_2g
384 network_suggestion_5g = self.wpa_psk_5g
385
386 # Add suggestions & wait for the connection event.
387 network_suggestion_2g[WifiEnums.PRIORITY] = 5
388 network_suggestion_5g[WifiEnums.PRIORITY] = 2
389 self.add_suggestions_and_ensure_connection(
390 [network_suggestion_2g, network_suggestion_5g],
391 self.wpa_psk_2g[WifiEnums.SSID_KEY],
392 None)
393
Nate Jiang172c6902019-09-09 17:54:33 -0700394 # In-place modify Reverse the priority, should be no disconnect
395 network_suggestion_2g[WifiEnums.PRIORITY] = 2
396 network_suggestion_5g[WifiEnums.PRIORITY] = 5
Roshan Pius67e7c512020-04-07 14:40:18 -0700397 self.dut.log.info("Modifying network suggestions")
Nate Jiang172c6902019-09-09 17:54:33 -0700398 asserts.assert_true(
399 self.dut.droid.wifiAddNetworkSuggestions([network_suggestion_2g,
400 network_suggestion_5g]),
401 "Failed to add suggestions")
402 wutils.ensure_no_disconnect(self.dut)
403
404 # Disable and re-enable wifi, should connect to higher priority
405 wutils.wifi_toggle_state(self.dut, False)
406 time.sleep(DEFAULT_TIMEOUT)
407 wutils.wifi_toggle_state(self.dut, True)
408 wutils.start_wifi_connection_scan_and_return_status(self.dut)
409 wutils.wait_for_connect(self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY])
410
Nate Jiang68f3ffa2019-08-07 15:23:49 -0700411 self.remove_suggestions_disconnect_and_ensure_no_connection_back(
Nate Jiang0878aef2019-09-16 13:33:26 -0700412 [], self.wpa_psk_5g[WifiEnums.SSID_KEY])
Roshan Piusc6fceca2019-03-22 13:23:58 -0700413
414 # Reverse the priority.
415 # Add suggestions & wait for the connection event.
Nate Jiang172c6902019-09-09 17:54:33 -0700416 network_suggestion_2g[WifiEnums.PRIORITY] = 5
417 network_suggestion_5g[WifiEnums.PRIORITY] = 2
Roshan Piusc6fceca2019-03-22 13:23:58 -0700418 self.add_suggestions_and_ensure_connection(
419 [network_suggestion_2g, network_suggestion_5g],
Nate Jiang0878aef2019-09-16 13:33:26 -0700420 self.wpa_psk_2g[WifiEnums.SSID_KEY],
Roshan Piusc6fceca2019-03-22 13:23:58 -0700421 None)
422
Roshan Piusf028bd32018-12-06 15:18:21 -0800423 @test_tracker_info(uuid="b1d27eea-23c8-4c4f-b944-ef118e4cc35f")
Roshan Piusd1204442018-11-12 12:20:39 -0800424 def test_connect_to_wpa_psk_2g_with_post_connection_broadcast(self):
425 """ Adds a network suggestion and ensure that the device connected.
426
427 Steps:
428 1. Send a network suggestion to the device with
429 isAppInteractionRequired set.
430 2. Wait for the device to connect to it.
431 3. Ensure that we did receive the post connection broadcast
432 (isAppInteractionRequired = True).
Roshan Piusffc29912019-01-18 13:39:49 -0800433 4. Remove the suggestions and ensure the device does not connect back.
Roshan Piusd1204442018-11-12 12:20:39 -0800434 """
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)
Nate Jiang68f3ffa2019-08-07 15:23:49 -0700440 self.remove_suggestions_disconnect_and_ensure_no_connection_back(
441 [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY])
Roshan Piusd1204442018-11-12 12:20:39 -0800442
Roshan Piusf028bd32018-12-06 15:18:21 -0800443 @test_tracker_info(uuid="a036a24d-29c0-456d-ae6a-afdde34da710")
Roshan Piusd1204442018-11-12 12:20:39 -0800444 def test_connect_to_wpa_psk_5g_reboot_config_store(self):
445 """
446 Adds a network suggestion and ensure that the device connects to it
447 after reboot.
448
449 Steps:
450 1. Send a network suggestion to the device.
451 2. Wait for the device to connect to it.
452 3. Ensure that we did not receive the post connection broadcast
453 (isAppInteractionRequired = False).
454 4. Reboot the device.
455 5. Wait for the device to connect to back to it.
Roshan Piusffc29912019-01-18 13:39:49 -0800456 6. Remove the suggestions and ensure the device does not connect back.
Nate(Qiang) Jiang8a62e372019-12-19 11:04:05 -0800457 7. Reboot the device again, ensure user approval is kept
Roshan Piusd1204442018-11-12 12:20:39 -0800458 """
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700459 self._test_connect_to_wifi_network_reboot_config_store(
460 [self.wpa_psk_5g], self.wpa_psk_5g)
Roshan Piusd1204442018-11-12 12:20:39 -0800461
Girish Moturuc2033ae2019-07-31 09:04:36 -0700462 @test_tracker_info(uuid="61649a2b-0f00-4272-9b9b-40ad5944da31")
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700463 def test_connect_to_wpa_ent_config_aka_reboot_config_store(self):
464 """
465 Adds a network suggestion and ensure that the device connects to it
466 after reboot.
Roshan Piusd1204442018-11-12 12:20:39 -0800467
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700468 Steps:
469 1. Send a Enterprise AKA network suggestion to the device.
470 2. Wait for the device to connect to it.
471 3. Ensure that we did not receive the post connection broadcast.
472 4. Reboot the device.
473 5. Wait for the device to connect to the wifi network.
474 6. Remove suggestions and ensure device doesn't connect back to it.
Nate(Qiang) Jiang8a62e372019-12-19 11:04:05 -0800475 7. Reboot the device again, ensure user approval is kept
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700476 """
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800477 if "carrierId" in self.config_aka:
478 self.set_carrier_approved(self.config_aka["carrierId"], True)
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700479 self._test_connect_to_wifi_network_reboot_config_store(
480 [self.config_aka], self.ent_network_2g)
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800481 if "carrierId" in self.config_aka:
482 self.clear_carrier_approved(self.config_aka["carrierId"])
Roshan Piusd1204442018-11-12 12:20:39 -0800483
Girish Moturuc2033ae2019-07-31 09:04:36 -0700484 @test_tracker_info(uuid="98b2d40a-acb4-4a2f-aba1-b069e2a1d09d")
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700485 def test_connect_to_wpa_ent_config_ttls_pap_reboot_config_store(self):
486 """
487 Adds a network suggestion and ensure that the device connects to it
488 after reboot.
Roshan Piusffc29912019-01-18 13:39:49 -0800489
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700490 Steps:
491 1. Send a Enterprise TTLS PAP network suggestion to the device.
492 2. Wait for the device to connect to it.
493 3. Ensure that we did not receive the post connection broadcast.
494 4. Reboot the device.
495 5. Wait for the device to connect to the wifi network.
496 6. Remove suggestions and ensure device doesn't connect back to it.
Nate(Qiang) Jiang8a62e372019-12-19 11:04:05 -0800497 7. Reboot the device again, ensure user approval is kept
Girish Moturub1e7a5c2019-07-29 13:48:11 -0700498 """
499 config = dict(self.config_ttls)
500 config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.PAP.value
501
502 self._test_connect_to_wifi_network_reboot_config_store(
503 [config], self.ent_network_2g)
Roshan Piusffc29912019-01-18 13:39:49 -0800504
Roshan Pius3e3bd342019-01-09 13:55:17 -0800505 @test_tracker_info(uuid="554b5861-22d0-4922-a5f4-712b4cf564eb")
506 def test_fail_to_connect_to_wpa_psk_5g_when_not_approved(self):
507 """
508 Adds a network suggestion and ensure that the device does not
509 connect to it until we approve the app.
510
511 Steps:
512 1. Send a network suggestion to the device with the app not approved.
513 2. Ensure the network is present in scan results, but we don't connect
514 to it.
515 3. Now approve the app.
516 4. Wait for the device to connect to it.
517 """
Roshan Pius67e7c512020-04-07 14:40:18 -0700518 self.dut.log.info("Adding network suggestions")
Roshan Pius3e3bd342019-01-09 13:55:17 -0800519 asserts.assert_true(
520 self.dut.droid.wifiAddNetworkSuggestions([self.wpa_psk_5g]),
521 "Failed to add suggestions")
522
523 # Disable suggestions by the app.
524 self.set_approved(False)
525
526 # Ensure the app is not approved.
527 asserts.assert_false(
528 self.is_approved(),
529 "Suggestions should be disabled")
530
531 # Start a new scan to trigger auto-join.
532 wutils.start_wifi_connection_scan_and_ensure_network_found(
533 self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY])
534
535 # Ensure we don't connect to the network.
536 asserts.assert_false(
537 wutils.wait_for_connect(
538 self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY], assert_on_fail=False),
539 "Should not connect to network suggestions from unapproved app")
540
Roshan Pius67e7c512020-04-07 14:40:18 -0700541 self.dut.log.info("Enabling suggestions from test")
Roshan Pius3e3bd342019-01-09 13:55:17 -0800542 # Now Enable suggestions by the app & ensure we connect to the network.
543 self.set_approved(True)
544
545 # Ensure the app is approved.
546 asserts.assert_true(
547 self.is_approved(),
548 "Suggestions should be enabled")
549
550 # Start a new scan to trigger auto-join.
551 wutils.start_wifi_connection_scan_and_ensure_network_found(
552 self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY])
553
554 wutils.wait_for_connect(self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY])
Roshan Pius89b22bd2019-01-24 14:12:49 -0800555
Roshan Pius3d57f132019-01-28 10:25:18 -0800556 @test_tracker_info(uuid="98400dea-776e-4a0a-9024-18845b27331c")
Roshan Pius89b22bd2019-01-24 14:12:49 -0800557 def test_fail_to_connect_to_wpa_psk_2g_after_user_forgot_network(self):
558 """
559 Adds a network suggestion and ensures that the device does not
560 connect to it after the user forgot the network previously.
561
562 Steps:
563 1. Send a network suggestion to the device with
564 isAppInteractionRequired set.
565 2. Wait for the device to connect to it.
566 3. Ensure that we did receive the post connection broadcast
567 (isAppInteractionRequired = True).
568 4. Simulate user forgetting the network and the device does not
569 connecting back even though the suggestion is active from the app.
570 """
571 network_suggestion = self.wpa_psk_2g
572 network_suggestion[WifiEnums.IS_APP_INTERACTION_REQUIRED] = True
573 self.add_suggestions_and_ensure_connection(
574 [network_suggestion], self.wpa_psk_2g[WifiEnums.SSID_KEY],
575 True)
576
Nate(Qiang) Jiangd3424642020-03-02 19:52:59 -0800577 # Simulate user disconnect the network.
578 self.dut.droid.wifiUserDisconnectNetwork(
Roshan Pius89b22bd2019-01-24 14:12:49 -0800579 self.wpa_psk_2g[WifiEnums.SSID_KEY])
580 wutils.wait_for_disconnect(self.dut)
581 self.dut.log.info("Disconnected from network %s", self.wpa_psk_2g)
582 self.dut.ed.clear_all_events()
583
584 # Now ensure that we don't connect back even though the suggestion
585 # is still active.
586 asserts.assert_false(
587 wutils.wait_for_connect(self.dut,
588 self.wpa_psk_2g[WifiEnums.SSID_KEY],
589 assert_on_fail=False),
590 "Device should not connect back")
Nate Jiang20af5e82019-08-08 12:45:24 -0700591
592 @test_tracker_info(uuid="93c86b05-fa56-4d79-ad27-009a16f691b1")
593 def test_connect_to_hidden_network(self):
594 """
595 Adds a network suggestion with hidden SSID config, ensure device can scan
596 and connect to this network.
597
598 Steps:
599 1. Send a hidden network suggestion to the device.
600 2. Wait for the device to connect to it.
601 3. Ensure that we did not receive the post connection broadcast
602 (isAppInteractionRequired = False).
603 4. Remove the suggestions and ensure the device does not connect back.
604 """
605 asserts.skip_if(not hasattr(self, "hidden_networks"), "No hidden networks, skip this test")
606
607 network_suggestion = self.hidden_network
608 self.add_suggestions_and_ensure_connection(
609 [network_suggestion], network_suggestion[WifiEnums.SSID_KEY], False)
610 self.remove_suggestions_disconnect_and_ensure_no_connection_back(
611 [network_suggestion], network_suggestion[WifiEnums.SSID_KEY])
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700612
Girish Moturua5d28482019-10-23 10:15:37 -0700613 @test_tracker_info(uuid="806dff14-7543-482b-bd0a-598de59374b3")
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700614 def test_connect_to_passpoint_network_with_post_connection_broadcast(self):
615 """ Adds a passpoint network suggestion and ensure that the device connected.
616
617 Steps:
618 1. Send a network suggestion to the device.
619 2. Wait for the device to connect to it.
620 3. Ensure that we did receive the post connection broadcast
621 (isAppInteractionRequired = true).
622 4. Remove the suggestions and ensure the device does not connect back.
623 """
624 asserts.skip_if(not hasattr(self, "passpoint_networks"),
625 "No passpoint networks, skip this test")
Girish Moturua069a4a2019-10-23 13:21:42 -0700626 passpoint_config = self.passpoint_networks[ATT]
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700627 passpoint_config[WifiEnums.IS_APP_INTERACTION_REQUIRED] = True
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800628 if "carrierId" in passpoint_config:
629 self.set_carrier_approved(passpoint_config["carrierId"], True)
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700630 self.add_suggestions_and_ensure_connection([passpoint_config],
631 passpoint_config[WifiEnums.SSID_KEY], True)
632 self.remove_suggestions_disconnect_and_ensure_no_connection_back(
633 [passpoint_config], passpoint_config[WifiEnums.SSID_KEY])
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800634 if "carrierId" in passpoint_config:
635 self.clear_carrier_approved(passpoint_config["carrierId"])
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700636
Girish Moturua5d28482019-10-23 10:15:37 -0700637 @test_tracker_info(uuid="159b8b8c-fb00-4d4e-a29f-606881dcbf44")
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700638 def test_connect_to_passpoint_network_reboot_config_store(self):
639 """
640 Adds a passpoint network suggestion and ensure that the device connects to it
641 after reboot.
642
643 Steps:
644 1. Send a network suggestion to the device.
645 2. Wait for the device to connect to it.
646 3. Ensure that we did not receive the post connection broadcast
647 (isAppInteractionRequired = False).
648 4. Reboot the device.
649 5. Wait for the device to connect to back to it.
650 6. Remove the suggestions and ensure the device does not connect back.
Nate(Qiang) Jiang8a62e372019-12-19 11:04:05 -0800651 7. Reboot the device again, ensure user approval is kept
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700652 """
653 asserts.skip_if(not hasattr(self, "passpoint_networks"),
654 "No passpoint networks, skip this test")
Girish Moturua069a4a2019-10-23 13:21:42 -0700655 passpoint_config = self.passpoint_networks[ATT]
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800656 if "carrierId" in passpoint_config:
657 self.set_carrier_approved(passpoint_config["carrierId"], True)
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700658 self._test_connect_to_wifi_network_reboot_config_store([passpoint_config],
659 passpoint_config)
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800660 if "carrierId" in passpoint_config:
661 self.clear_carrier_approved(passpoint_config["carrierId"])
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700662
Girish Moturua5d28482019-10-23 10:15:37 -0700663 @test_tracker_info(uuid="34f3d28a-bedf-43fe-a12d-2cfadf6bc6eb")
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700664 def test_fail_to_connect_to_passpoint_network_when_not_approved(self):
665 """
666 Adds a passpoint network suggestion and ensure that the device does not
667 connect to it until we approve the app.
668
669 Steps:
670 1. Send a network suggestion to the device with the app not approved.
671 2. Ensure the network is present in scan results, but we don't connect
672 to it.
673 3. Now approve the app.
674 4. Wait for the device to connect to it.
675 """
676 asserts.skip_if(not hasattr(self, "passpoint_networks"),
677 "No passpoint networks, skip this test")
Girish Moturua069a4a2019-10-23 13:21:42 -0700678 passpoint_config = self.passpoint_networks[ATT]
Nate(Qiang) Jiang647afb92020-02-06 13:44:14 -0800679 if "carrierId" in passpoint_config:
680 self.set_carrier_approved(passpoint_config["carrierId"], True)
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700681 self.dut.log.info("Adding network suggestions")
682 asserts.assert_true(
683 self.dut.droid.wifiAddNetworkSuggestions([passpoint_config]),
684 "Failed to add suggestions")
685
686 # Disable suggestions by the app.
687 self.set_approved(False)
688
689 # Ensure the app is not approved.
690 asserts.assert_false(
691 self.is_approved(),
692 "Suggestions should be disabled")
693
694 # Start a new scan to trigger auto-join.
695 wutils.start_wifi_connection_scan_and_ensure_network_found(
696 self.dut, passpoint_config[WifiEnums.SSID_KEY])
697
698 # Ensure we don't connect to the network.
699 asserts.assert_false(
700 wutils.wait_for_connect(
701 self.dut, passpoint_config[WifiEnums.SSID_KEY], assert_on_fail=False),
702 "Should not connect to network suggestions from unapproved app")
703
Roshan Pius67e7c512020-04-07 14:40:18 -0700704 self.dut.log.info("Enabling suggestions from test")
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700705 # Now Enable suggestions by the app & ensure we connect to the network.
706 self.set_approved(True)
707
708 # Ensure the app is approved.
709 asserts.assert_true(
710 self.is_approved(),
711 "Suggestions should be enabled")
712
713 # Start a new scan to trigger auto-join.
714 wutils.start_wifi_connection_scan_and_ensure_network_found(
715 self.dut, passpoint_config[WifiEnums.SSID_KEY])
Nate(Qiang) Jiang051b8142019-11-01 17:23:33 -0700716 time.sleep(PASSPOINT_TIMEOUT)
Nate(Qiang) Jiang55582152019-10-07 12:13:47 -0700717 wutils.wait_for_connect(self.dut, passpoint_config[WifiEnums.SSID_KEY])
Nate(Qiang) Jiang647afb92020-02-06 13:44:14 -0800718 if "carrierId" in passpoint_config:
719 self.clear_carrier_approved(passpoint_config["carrierId"])
Nate(Qiang) Jiange7a400e2020-01-16 17:27:23 -0800720
Girish Moturu7e30c782020-02-05 12:37:06 -0800721 @test_tracker_info(uuid="cf624cda-4d25-42f1-80eb-6c717fb08338")
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800722 def test_fail_to_connect_to_passpoint_network_when_imsi_protection_exemption_not_approved(self):
723 """
724 Adds a passpoint network suggestion using SIM credential without IMSI privacy protection.
725 Before user approves the exemption, ensure that the device does noconnect to it until we
726 approve the carrier exemption.
727
728 Steps:
729 1. Send a network suggestion to the device with IMSI protection exemption not approved.
730 2. Ensure the network is present in scan results, but we don't connect
731 to it.
732 3. Now approve the carrier.
733 4. Wait for the device to connect to it.
734 """
735 asserts.skip_if(not hasattr(self, "passpoint_networks"),
736 "No passpoint networks, skip this test")
737 passpoint_config = self.passpoint_networks[ATT]
738 asserts.skip_if("carrierId" not in passpoint_config,
739 "Not a SIM based passpoint network, skip this test")
740
Nate(Qiang) Jiang92251a62020-02-28 10:13:30 -0800741 # Ensure the carrier is not approved.
742 asserts.assert_false(
743 self.is_carrier_approved(passpoint_config["carrierId"]),
744 "Carrier shouldn't be approved")
745
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800746 self.dut.log.info("Adding network suggestions")
747 asserts.assert_true(
748 self.dut.droid.wifiAddNetworkSuggestions([passpoint_config]),
749 "Failed to add suggestions")
750
Nate(Qiang) Jiangacaf8892020-01-29 14:04:12 -0800751 # Start a new scan to trigger auto-join.
752 wutils.start_wifi_connection_scan_and_ensure_network_found(
753 self.dut, passpoint_config[WifiEnums.SSID_KEY])
754
755 # Ensure we don't connect to the network.
756 asserts.assert_false(
757 wutils.wait_for_connect(
758 self.dut, passpoint_config[WifiEnums.SSID_KEY], assert_on_fail=False),
759 "Should not connect to network suggestions from unapproved app")
760
761 self.dut.log.info("Enabling suggestions from test")
762 # Now approve IMSI protection exemption by carrier & ensure we connect to the network.
763 self.set_carrier_approved(passpoint_config["carrierId"], True)
764
765 # Ensure the carrier is approved.
766 asserts.assert_true(
767 self.is_carrier_approved(passpoint_config["carrierId"]),
768 "Carrier should be approved")
769
770 # Start a new scan to trigger auto-join.
771 wutils.start_wifi_connection_scan_and_ensure_network_found(
772 self.dut, passpoint_config[WifiEnums.SSID_KEY])
773 time.sleep(PASSPOINT_TIMEOUT)
774 wutils.wait_for_connect(self.dut, passpoint_config[WifiEnums.SSID_KEY])
775 self.clear_carrier_approved(passpoint_config["carrierId"])
776
Girish Moturu31f58f22020-01-30 18:54:40 -0800777 @test_tracker_info(uuid="e35f99c8-78a4-4b96-9258-f9834b6ddd33")
Nate(Qiang) Jiange7a400e2020-01-16 17:27:23 -0800778 def test_initial_auto_join_on_network_suggestion(self):
779 """
780 Add a network suggestion with enableAutojoin bit set to false, ensure the device doesn't
781 auto connect to this network
782
783 Steps:
784 1. Create a network suggestion.
785 2. Set EnableAutojoin to false.
786 3. Add this suggestion
787 4. Ensure device doesn't connect to his network
788 """
Girish Moturu2155dc12020-01-21 15:16:17 -0800789 network_suggestion = self.wpa_psk_5g
Nate(Qiang) Jiange7a400e2020-01-16 17:27:23 -0800790 # Set suggestion auto join initial to false.
Nate Jiang8b2b4b82020-03-13 13:49:07 -0700791 network_suggestion[AutoJoin] = False
Nate(Qiang) Jiange7a400e2020-01-16 17:27:23 -0800792 self.dut.log.info("Adding network suggestions")
793 asserts.assert_true(
794 self.dut.droid.wifiAddNetworkSuggestions([network_suggestion]),
795 "Failed to add suggestions")
796 # Enable suggestions by the app.
797 self.dut.log.debug("Enabling suggestions from test")
798 self.set_approved(True)
799 wutils.start_wifi_connection_scan_and_return_status(self.dut)
800 asserts.assert_false(
801 wutils.wait_for_connect(self.dut, network_suggestion[WifiEnums.SSID_KEY],
802 assert_on_fail=False), "Device should not connect.")
803
Girish Moturu31f58f22020-01-30 18:54:40 -0800804 @test_tracker_info(uuid="ff4e451f-a380-4ff5-a5c2-dd9b1633d5e5")
Nate(Qiang) Jiange7a400e2020-01-16 17:27:23 -0800805 def test_user_override_auto_join_on_network_suggestion(self):
806 """
807 Add a network suggestion, user change the auto join to false, ensure the device doesn't
808 auto connect to this network
809
810 Steps:
811 1. Create a network suggestion.
812 2. Add this suggestion, and ensure we connect to this network
813 3. Simulate user change the auto join to false.
814 4. Toggle the Wifi off and on
815 4. Ensure device doesn't connect to his network
816 """
Girish Moturu2155dc12020-01-21 15:16:17 -0800817 network_suggestion = self.wpa_psk_5g
Nate(Qiang) Jiange7a400e2020-01-16 17:27:23 -0800818 self.add_suggestions_and_ensure_connection([network_suggestion],
819 network_suggestion[WifiEnums.SSID_KEY], False)
820 wifi_info = self.dut.droid.wifiGetConnectionInfo()
821 self.dut.log.info(wifi_info)
822 network_id = wifi_info[WifiEnums.NETID_KEY]
823 # Simulate user disable auto join through Settings.
824 self.dut.log.info("Disable auto join on suggestion")
825 self.dut.droid.wifiEnableAutojoin(network_id, False)
826 wutils.wifi_toggle_state(self.dut, False)
827 wutils.wifi_toggle_state(self.dut, True)
828 asserts.assert_false(
829 wutils.wait_for_connect(self.dut, network_suggestion[WifiEnums.SSID_KEY],
830 assert_on_fail=False), "Device should not connect.")
Nate Jiang8b2b4b82020-03-13 13:49:07 -0700831
Girish Moturu10c6b2c2020-04-08 09:28:48 -0700832 @test_tracker_info(uuid="32201b1c-76a0-46dc-9983-2cd24312a783")
Nate Jiang8b2b4b82020-03-13 13:49:07 -0700833 def test_untrusted_suggestion_without_untrusted_request(self):
834 """
835 Add an untrusted network suggestion, when no untrusted request, will not connect to it.
836 Steps:
837 1. Create a untrusted network suggestion.
838 2. Add this suggestion, and ensure device do not connect to this network
839 3. Request untrusted network and ensure device connect to this network
840 """
841 network_suggestion = self.open_5g
842 network_suggestion[Untrusted] = True
843 self.dut.log.info("Adding network suggestions")
844 asserts.assert_true(
845 self.dut.droid.wifiAddNetworkSuggestions([network_suggestion]),
846 "Failed to add suggestions")
847 # Start a new scan to trigger auto-join.
848 wutils.start_wifi_connection_scan_and_ensure_network_found(
849 self.dut, network_suggestion[WifiEnums.SSID_KEY])
850
851 # Ensure we don't connect to the network.
852 asserts.assert_false(
853 wutils.wait_for_connect(
854 self.dut, network_suggestion[WifiEnums.SSID_KEY], assert_on_fail=False),
855 "Should not connect to untrusted network suggestions with no request")
856 network_request = {ClearCapabilities: True, TransportType: 1}
857 req_key = self.dut.droid.connectivityRequestNetwork(network_request)
858
859 # Start a new scan to trigger auto-join.
860 wutils.start_wifi_connection_scan_and_ensure_network_found(
861 self.dut, network_suggestion[WifiEnums.SSID_KEY])
862
863 wutils.wait_for_connect(
864 self.dut, network_suggestion[WifiEnums.SSID_KEY], assert_on_fail=False)
865
866 self.dut.droid.connectivityUnregisterNetworkCallback(req_key)
867