]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: hostapd behavior on dynamic addition of invalid config
authorJouni Malinen <j@w1.fi>
Sat, 2 Nov 2013 17:57:35 +0000 (19:57 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 3 Nov 2013 09:31:48 +0000 (11:31 +0200)
Verify that hostapd handles ENABLE command on invalid configuration
correctly and allows the configuration to be fixed or the interface to
be removed.

Signed-hostap: Jouni Malinen <j@w1.fi>

tests/hwsim/test_ap_dynamic.py

index ef4a576465dd5034a528d066acbd6088d6bcdc77..fb150e5b54f1631704fc02c9132d7e2da90a5916 100644 (file)
@@ -137,3 +137,41 @@ def test_ap_bss_add_remove(dev, apdev):
     logger.info("Test error handling if a duplicate ifname is tried")
     hostapd.add_bss('phy3', ifname3, 'bss-3.conf', ignore_error=True)
     multi_check(dev, [ True, True, True ])
+
+def invalid_ap(hapd_global, ifname):
+    logger.info("Trying to start AP " + ifname + " with invalid configuration")
+    hapd_global.remove(ifname)
+    hapd_global.add(ifname)
+    hapd = hostapd.Hostapd(ifname)
+    if not hapd.ping():
+        raise Exception("Could not ping hostapd")
+    hapd.set_defaults()
+    hapd.set("ssid", "invalid-config")
+    hapd.set("channel", "12345")
+    try:
+        hapd.enable()
+        started = True
+    except Exception, e:
+        started = False
+    if started:
+        raise Exception("ENABLE command succeeded unexpectedly")
+    return hapd
+
+def test_ap_invalid_config(dev, apdev):
+    """Try to start AP with invalid configuration and fix configuration"""
+    hapd_global = hostapd.HostapdGlobal()
+    ifname = apdev[0]['ifname']
+    hapd = invalid_ap(hapd_global, ifname)
+
+    logger.info("Fix configuration and start AP again")
+    hapd.set("channel", "1")
+    hapd.enable()
+    dev[0].connect("invalid-config", key_mgmt="NONE", scan_freq="2412")
+
+def test_ap_invalid_config2(dev, apdev):
+    """Try to start AP with invalid configuration and remove interface"""
+    hapd_global = hostapd.HostapdGlobal()
+    ifname = apdev[0]['ifname']
+    hapd = invalid_ap(hapd_global, ifname)
+    logger.info("Remove interface with failed configuration")
+    hapd_global.remove(ifname)