From 04e17e50241588257416c9d98f58b228d28004dd Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 4 Jan 2019 20:27:40 +0200 Subject: [PATCH] tests: Verify that roaming attempts do not get rejected The previous roam() and roam_over_ds() checks would have ignored failing association rejection if a consecutive attempt to connect succeeds within the initial time limit. This can miss incorrect behavior, so check explicitly for association rejection. Signed-off-by: Jouni Malinen --- tests/hwsim/wpasupplicant.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index 3881facb5..f06d52a1b 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -1,5 +1,5 @@ # Python class for controlling wpa_supplicant -# Copyright (c) 2013-2014, Jouni Malinen +# Copyright (c) 2013-2019, Jouni Malinen # # This software may be distributed under the terms of the BSD license. # See README for more details. @@ -1116,7 +1116,12 @@ class WpaSupplicant: raise Exception("Unexpected connection") self.dump_monitor() return - self.wait_connected(timeout=10, error="Roaming with the AP timed out") + ev = self.wait_event(["CTRL-EVENT-CONNECTED", + "CTRL-EVENT-ASSOC-REJECT"], timeout=10) + if ev is None: + raise Exception("Roaming with the AP timed out") + if "CTRL-EVENT-ASSOC-REJECT" in ev: + raise Exception("Roaming association rejected") self.dump_monitor() def roam_over_ds(self, bssid, fail_test=False): @@ -1129,7 +1134,12 @@ class WpaSupplicant: raise Exception("Unexpected connection") self.dump_monitor() return - self.wait_connected(timeout=10, error="Roaming with the AP timed out") + ev = self.wait_event(["CTRL-EVENT-CONNECTED", + "CTRL-EVENT-ASSOC-REJECT"], timeout=10) + if ev is None: + raise Exception("Roaming with the AP timed out") + if "CTRL-EVENT-ASSOC-REJECT" in ev: + raise Exception("Roaming association rejected") self.dump_monitor() def wps_reg(self, bssid, pin, new_ssid=None, key_mgmt=None, cipher=None,