[PATCH v3 6/8] tests: uhr: no connection if UHR required but not supported

Johannes Berg johannes at sipsolutions.net
Fri Apr 24 00:11:58 PDT 2026


From: Johannes Berg <johannes.berg at intel.com>

Add a test that checks there's no connection if UHR is required
by the AP but not supported by (disabled on) the client.

Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 tests/hwsim/test_uhr.py      | 23 +++++++++++++++++++++++
 tests/hwsim/wpasupplicant.py |  3 ++-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/tests/hwsim/test_uhr.py b/tests/hwsim/test_uhr.py
index a5dfea0aee35..4917bcc6ff2d 100644
--- a/tests/hwsim/test_uhr.py
+++ b/tests/hwsim/test_uhr.py
@@ -82,6 +82,29 @@ def test_uhr_open(dev, apdev):
     if "wifi_generation=8" not in status:
         raise Exception("STA STATUS did not indicate wifi_generation=7")
 
+def test_uhr_required_not_supported(dev, apdev):
+    """no connection if UHR is required but not supported by client"""
+    params = {
+        "ssid": "uhr",
+        "ieee80211ax": "1",
+        "ieee80211be": "1",
+        "ieee80211bn": "1",
+        "require_uhr": "1",
+    }
+    try:
+        hapd = hostapd.add_ap(apdev[0], params)
+    except Exception as e:
+        if isinstance(e, Exception) and \
+           str(e) == "Failed to set hostapd parameter ieee80211bn":
+            raise HwsimSkip("UHR not supported")
+        raise
+    if hapd.get_status_field("ieee80211bn") != "1":
+        raise Exception("AP STATUS did not indicate ieee80211bn=1")
+    dev[0].connect("uhr", key_mgmt="NONE", scan_freq="2412", disable_uhr="1",
+                   wait_connect=False)
+    ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
+    assert ev is None, "connected despite disable_uhr/require_uhr"
+
 def uhr_mld_ap_wpa2_params(ssid, passphrase=None, key_mgmt="WPA-PSK-SHA256",
                            mfp="2", pwe=None, beacon_prot="1", bridge=False):
     params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase,
diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py
index ebce5519d719..520eefe1866e 100644
--- a/tests/hwsim/wpasupplicant.py
+++ b/tests/hwsim/wpasupplicant.py
@@ -1146,7 +1146,8 @@ class WpaSupplicant:
                       "sae_password_id_change",
                       "enable_4addr_mode",
                       "pmksa_privacy",
-                      "eap_over_auth_frame"]
+                      "eap_over_auth_frame",
+                      "disable_uhr"]
         for field in not_quoted:
             if field in kwargs and kwargs[field]:
                 self.set_network(id, field, kwargs[field])
-- 
2.53.0




More information about the Hostap mailing list