tests: Add WPS test with dynamic update

This test first configure hostapd with an initial SSID
('test-wpa2-psk-start'). Then a new SSID is configured
('test-wpa2-psk-new') using SET and RELOAD. Next, a station is
associated using WPS, and the test verifies that the new SSID was served
to the station.

Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
This commit is contained in:
Raphaël Mélotte 2020-12-18 11:50:28 +01:00 committed by Jouni Malinen
parent f95ccc102a
commit 3a3ea68a36

View file

@ -37,6 +37,44 @@ def test_ap_change_ssid(dev, apdev):
dev[0].set_network_quoted(id, "ssid", "test-wpa2-psk-new")
dev[0].connect_network(id)
def test_ap_change_ssid_wps(dev, apdev):
"""Dynamic SSID change with hostapd and WPA2-PSK using WPS"""
params = hostapd.wpa2_params(ssid="test-wpa2-psk-start",
passphrase="12345678")
# Use a PSK and not the passphrase, because the PSK will have to be computed
# again if we use a passphrase.
del params["wpa_passphrase"]
params["wpa_psk"] = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
params.update({"wps_state": "2", "eap_server": "1"})
bssid = apdev[0]['bssid']
hapd = hostapd.add_ap(apdev[0], params)
new_ssid = "test-wpa2-psk-new"
logger.info("Change SSID dynamically (WPS)")
res = hapd.request("SET ssid " + new_ssid)
if "OK" not in res:
raise Exception("SET command failed")
res = hapd.request("RELOAD")
if "OK" not in res:
raise Exception("RELOAD command failed")
# Connect to the new ssid using wps:
hapd.request("WPS_PBC")
if "PBC Status: Active" not in hapd.request("WPS_GET_STATUS"):
raise Exception("PBC status not shown correctly")
dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412", force_scan=True)
dev[0].request("WPS_PBC")
dev[0].wait_connected(timeout=20)
status = dev[0].get_status()
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != bssid:
raise Exception("Not fully connected")
if status['ssid'] != new_ssid:
raise Exception("Unexpected SSID %s != %s" % (status['ssid'], new_ssid))
dev[0].request("DISCONNECT")
dev[0].wait_disconnected()
def multi_check(apdev, dev, check, scan_opt=True):
id = []
num_bss = len(check)