From 2e22f3e82e3a2840f53985b01c0e2bba8434ee54 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 15 Mar 2020 17:07:52 +0200 Subject: [PATCH] tests: Check more details in pmksa_cache_ap_expiration It looks like this test case can fail if the STA goes to power save mode and the Deauthentication frame from the AP after session timeout is not actually sent at all. Check more details to make it clear that this is indeed the reason behind the failure. Signed-off-by: Jouni Malinen --- tests/hwsim/test_pmksa_cache.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/hwsim/test_pmksa_cache.py b/tests/hwsim/test_pmksa_cache.py index 11daaaa67..c334b48dd 100644 --- a/tests/hwsim/test_pmksa_cache.py +++ b/tests/hwsim/test_pmksa_cache.py @@ -662,6 +662,7 @@ def test_pmksa_cache_ap_expiration(dev, apdev): params = hostapd.wpa2_eap_params(ssid="test-pmksa-cache") hapd = hostapd.add_ap(apdev[0], params) bssid = apdev[0]['bssid'] + dev[0].connect("test-pmksa-cache", proto="RSN", key_mgmt="WPA-EAP", eap="GPSK", identity="gpsk-user-session-timeout", password="abcdefghijklmnop0123456789abcdef", @@ -669,20 +670,44 @@ def test_pmksa_cache_ap_expiration(dev, apdev): ev = hapd.wait_event(["AP-STA-CONNECTED"], timeout=5) if ev is None: raise Exception("No connection event received from hostapd") + hapd.dump_monitor() + dev[0].request("DISCONNECT") + ev = hapd.wait_event(["AP-STA-DISCONNECTED"], timeout=5) + if ev is None: + raise Exception("No disconnection event received from hostapd") + dev[0].wait_disconnected() + + # Wait for session timeout to remove PMKSA cache entry time.sleep(5) dev[0].dump_monitor() + hapd.dump_monitor() + dev[0].request("RECONNECT") ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED", "CTRL-EVENT-CONNECTED"], timeout=20) if ev is None: - raise Exception("Roaming with the AP timed out") + raise Exception("Reconnection with the AP timed out") if "CTRL-EVENT-CONNECTED" in ev: raise Exception("EAP exchange missing") dev[0].wait_connected(timeout=20, error="Reconnect timed out") dev[0].dump_monitor() + ev = hapd.wait_event(["AP-STA-CONNECTED"], timeout=5) + if ev is None: + raise Exception("No connection event received from hostapd [2]") + hapd.dump_monitor() + + # Wait for session timeout + ev = hapd.wait_event(["AP-STA-DISCONNECTED"], timeout=10) + if ev is None: + raise Exception("No disconnection event received from hostapd [2]") dev[0].wait_disconnected(timeout=20) dev[0].wait_connected(timeout=20, error="Reassociation timed out") + ev = hapd.wait_event(["AP-STA-CONNECTED"], timeout=5) + if ev is None: + raise Exception("No connection event received from hostapd [3]") + hapd.dump_monitor() + dev[0].dump_monitor() def test_pmksa_cache_multiple_sta(dev, apdev): """PMKSA cache with multiple stations"""