tests: AP_SCAN 0/2 and externally triggered connection
Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
b3ec107c8b
commit
d5b14d0027
1 changed files with 64 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
import logging
|
||||
logger = logging.getLogger()
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
import hwsim_utils
|
||||
|
@ -22,3 +23,66 @@ def test_sta_dynamic(dev, apdev):
|
|||
wpas.interface_add("wlan5")
|
||||
|
||||
wpas.connect("sta-dynamic", psk="12345678", scan_freq="2412")
|
||||
|
||||
def test_sta_ap_scan_0(dev, apdev):
|
||||
"""Dynamically added wpa_supplicant interface with AP_SCAN 0 connection"""
|
||||
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test" })
|
||||
bssid = apdev[0]['bssid']
|
||||
|
||||
logger.info("Create a dynamic wpa_supplicant interface and connect")
|
||||
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
|
||||
wpas.interface_add("wlan5")
|
||||
|
||||
if "OK" not in wpas.request("AP_SCAN 0"):
|
||||
raise Exception("Failed to set AP_SCAN 2")
|
||||
|
||||
id = wpas.connect("", key_mgmt="NONE", bssid=bssid,
|
||||
only_add_network=True)
|
||||
wpas.request("ENABLE_NETWORK " + str(id) + " no-connect")
|
||||
wpas.request("SCAN")
|
||||
time.sleep(0.5)
|
||||
subprocess.call(['sudo', 'iw', wpas.ifname, 'connect', 'test', '2412'])
|
||||
ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
|
||||
if ev is None:
|
||||
raise Exception("Connection not reported")
|
||||
wpas.request("SCAN")
|
||||
ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=5)
|
||||
if ev is None:
|
||||
raise Exception("Connection not reported")
|
||||
|
||||
def test_sta_ap_scan_2(dev, apdev):
|
||||
"""Dynamically added wpa_supplicant interface with AP_SCAN 2 connection"""
|
||||
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test" })
|
||||
bssid = apdev[0]['bssid']
|
||||
|
||||
logger.info("Create a dynamic wpa_supplicant interface and connect")
|
||||
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
|
||||
wpas.interface_add("wlan5")
|
||||
|
||||
if "FAIL" not in wpas.request("AP_SCAN -1"):
|
||||
raise Exception("Invalid AP_SCAN -1 accepted")
|
||||
if "FAIL" not in wpas.request("AP_SCAN 3"):
|
||||
raise Exception("Invalid AP_SCAN 3 accepted")
|
||||
if "OK" not in wpas.request("AP_SCAN 2"):
|
||||
raise Exception("Failed to set AP_SCAN 2")
|
||||
|
||||
id = wpas.connect("", key_mgmt="NONE", bssid=bssid,
|
||||
only_add_network=True)
|
||||
wpas.request("ENABLE_NETWORK " + str(id) + " no-connect")
|
||||
subprocess.call(['sudo', 'iw', wpas.ifname, 'scan', 'trigger',
|
||||
'freq', '2412'])
|
||||
time.sleep(1)
|
||||
subprocess.call(['sudo', 'iw', wpas.ifname, 'connect', 'test', '2412'])
|
||||
ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
|
||||
if ev is None:
|
||||
raise Exception("Connection not reported")
|
||||
|
||||
wpas.request("SET disallow_aps bssid " + bssid)
|
||||
ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
|
||||
if ev is None:
|
||||
raise Exception("Disconnection not reported")
|
||||
|
||||
subprocess.call(['sudo', 'iw', wpas.ifname, 'connect', 'test', '2412'])
|
||||
ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
|
||||
if ev is not None:
|
||||
raise Exception("Unexpected connection reported")
|
||||
|
|
Loading…
Reference in a new issue