From: Raphaël Mélotte Date: Fri, 18 Dec 2020 10:50:28 +0000 (+0100) Subject: tests: Add WPS test with dynamic update X-Git-Tag: hostap_2_10~628 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a3ea68a361aface192ab1542cd27ca3a2c823d4;p=thirdparty%2Fhostap.git 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 --- diff --git a/tests/hwsim/test_ap_dynamic.py b/tests/hwsim/test_ap_dynamic.py index 96d35b9a2..d23cf0cf0 100644 --- a/tests/hwsim/test_ap_dynamic.py +++ b/tests/hwsim/test_ap_dynamic.py @@ -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)