]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: EXT PW file backend
authorJouni Malinen <jouni@codeaurora.org>
Mon, 15 Feb 2021 21:26:32 +0000 (23:26 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 15 Feb 2021 22:47:43 +0000 (00:47 +0200)
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
tests/hwsim/example-wpa_supplicant.config
tests/hwsim/test_ext_password.py

index 8f8a76afbfb922230b38644d8d262db0e67187f4..a5792896bee6d415662b3b79959034d18c9bce7a 100644 (file)
@@ -112,6 +112,7 @@ CONFIG_AUTOSCAN_EXPONENTIAL=y
 CONFIG_AUTOSCAN_PERIODIC=y
 
 CONFIG_EXT_PASSWORD_TEST=y
+CONFIG_EXT_PASSWORD_FILE=y
 
 CONFIG_EAP_UNAUTH_TLS=y
 
index dfaf3ea6ef14a7ad8ef4762be0309b7138bf4fef..789b673d9625271309df3d9bec08ce634c31318e 100644 (file)
@@ -7,6 +7,8 @@
 from remotehost import remote_compatible
 import logging
 logger = logging.getLogger()
+import os
+import tempfile
 
 import hostapd
 from utils import skip_with_fips
@@ -79,3 +81,32 @@ def test_ext_password_interworking(dev, apdev):
     dev[0].set_cred(id, "password", "ext:pw1")
     interworking_select(dev[0], bssid, freq="2412")
     interworking_connect(dev[0], bssid, "TTLS")
+
+def test_ext_password_file_psk(dev, apdev):
+    """External password (file) storage for PSK"""
+    params = hostapd.wpa2_params(ssid="ext-pw-psk", passphrase="12345678")
+    hostapd.add_ap(apdev[0], params)
+    fd, fn = tempfile.mkstemp()
+    with open(fn, "w") as f:
+        f.write("psk1=12345678\n")
+    os.close(fd)
+    dev[0].request("SET ext_password_backend file:%s" % fn)
+    dev[0].connect("ext-pw-psk", raw_psk="ext:psk1", scan_freq="2412")
+    for i in range(2):
+        dev[0].request("REMOVE_NETWORK all")
+        if i == 0:
+            dev[0].wait_disconnected()
+            dev[0].connect("ext-pw-psk", raw_psk="ext:psk2", scan_freq="2412",
+                           wait_connect=False)
+        else:
+            dev[0].connect("ext-pw-psk", raw_psk="ext:psk1", scan_freq="2412",
+                           wait_connect=False)
+        ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED",
+                                "EXT PW: No PSK found from external storage"],
+                               timeout=10)
+        if i == 0:
+            os.unlink(fn)
+        if ev is None:
+            raise Exception("No connection result reported")
+        if "CTRL-EVENT-CONNECTED" in ev:
+            raise Exception("Unexpected connection")