diff mbox series

[2/2] tests: Add all-blacklist test

Message ID 20200608234754.32593-2-briannorris@chromium.org
State Accepted
Headers show
Series [1/2] tests: sae: Skip malformed packets | expand

Commit Message

Brian Norris June 8, 2020, 11:47 p.m. UTC
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
 tests/hwsim/test_ap_roam.py | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
diff mbox series

Patch

diff --git a/tests/hwsim/test_ap_roam.py b/tests/hwsim/test_ap_roam.py
index 9047c7a80209..13e669bad01b 100644
--- a/tests/hwsim/test_ap_roam.py
+++ b/tests/hwsim/test_ap_roam.py
@@ -26,6 +26,31 @@  def test_ap_roam_open(dev, apdev):
     dev[0].roam(apdev[0]['bssid'])
     hwsim_utils.test_connectivity(dev[0], hapd0)
 
+def test_ap_blacklist_all(dev, apdev, params):
+    """Ensure we clear the blacklist if all visible APs reject."""
+    hapd0 = hostapd.add_ap(apdev[0], {"ssid": "test-open", "max_num_sta": "0"})
+    hapd1 = hostapd.add_ap(apdev[1], {"ssid": "test-open", "max_num_sta": "0"})
+    bss0 = hapd0.own_addr()
+    bss1 = hapd1.own_addr()
+
+    dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412",
+                   wait_connect=False, bssid=bss0)
+    if not dev[0].wait_event(["CTRL-EVENT-AUTH-REJECT"], timeout=10):
+        raise Exception("AP 0 didn't reject us")
+    dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412",
+                   wait_connect=False, bssid=bss1)
+    if not dev[0].wait_event(["CTRL-EVENT-AUTH-REJECT"], timeout=10):
+        raise Exception("AP 1 didn't reject us")
+    blacklist = get_blacklist(dev[0])
+    if len(blacklist) != 2:
+        raise Exception("Unexpected blacklist: %s" % blacklist)
+
+    hapd0.set("max_num_sta", "1")
+    # All visible APs were blacklisted; we should clear the blacklist and find
+    # the AP that now accepts us.
+    dev[0].scan_for_bss(bss0, freq=2412)
+    dev[0].connect("test-open", key_mgmt="NONE", scan_freq="2412", bssid=bss0)
+
 @remote_compatible
 def test_ap_roam_open_failed(dev, apdev):
     """Roam failure due to rejected authentication"""