>From 0ddc036ab21b155a4e8a4552456220985723fae1 Mon Sep 17 00:00:00 2001 From: Mikael Kanstrup Date: Thu, 30 Jun 2016 10:37:43 +0200 Subject: [PATCH 4/5] tests: Add testcase for roaming failure with reassoc and bssid_set Add testcase that verifies that a failed roaming attempt performed with reassociate command and bssid_set=1 blacklists the correct AP. --- tests/hwsim/test_ap_roam.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/hwsim/test_ap_roam.py b/tests/hwsim/test_ap_roam.py index 11d9755..6389ead 100644 --- a/tests/hwsim/test_ap_roam.py +++ b/tests/hwsim/test_ap_roam.py @@ -11,6 +11,7 @@ logger = logging.getLogger() import hwsim_utils import hostapd +from wpasupplicant import WpaSupplicant @remote_compatible def test_ap_roam_open(dev, apdev): @@ -61,6 +62,45 @@ def test_ap_roam_wpa2_psk(dev, apdev): dev[0].roam(apdev[0]['bssid']) hwsim_utils.test_connectivity(dev[0], hapd0) +def get_blacklist(dev): + return dev.request("BLACKLIST").splitlines() + +def test_ap_roam_with_reassoc_wpa2_psk_failed(dev, apdev, params): + """Roam using reassoc between two WPA2-PSK APs""" + params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678") + hapd0 = hostapd.add_ap(apdev[0], params) + bssid0 = hapd0.own_addr() + + wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') + wpas.interface_add("wlan5", drv_params="force_connect_cmd=1,force_bss_selection=1") + + id = wpas.connect("test-wpa2-psk", psk="12345678", scan_freq="2412") + hwsim_utils.test_connectivity(wpas, hapd0) + + hapd1 = hostapd.add_ap(apdev[1], params) + bssid1 = hapd1.own_addr() + wpas.scan_for_bss(bssid1, freq=2412) + + if "OK" not in wpas.request("SET_NETWORK " + str(id) + " bssid " + bssid1): + raise Exception("SET_NETWORK failed") + if "OK" not in wpas.request("IGNORE_AUTH_RESP 1"): + raise Exception("IGNORE_AUTH_RESP failed") + if "OK" not in wpas.request("REASSOCIATE"): + raise Exception("REASSOCIATE failed") + + logger.info("Wait ~10s for auth timeout...") + ev = wpas.wait_event(["CTRL-EVENT-SCAN-STARTED"], 12) + if not ev: + raise Exception("CTRL-EVENT-SCAN-STARTED not seen"); + + b = get_blacklist(wpas) + if bssid0 in b: + raise Exception("Unexpected blacklist contents: " + str(b)) + + if "OK" not in wpas.request("IGNORE_AUTH_RESP 0"): + raise Exception("IGNORE_AUTH_RESP failed") + wpas.wait_connected(timeout=5) + def test_ap_roam_wpa2_psk_failed(dev, apdev, params): """Roam failure with WPA2-PSK AP due to wrong passphrase""" params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678") -- 2.4.2