[PATCH 11/14] tests: SAVE_CONFIG with an external PSK
Angelo Compagnucci
angelo.compagnucci at gmail.com
Mon Nov 23 06:24:45 PST 2026
Check that SAVE_CONFIG keeps WPA-PSK and SAE networks configured with
psk=ext:<name>, and that the saved configuration connects.
Signed-off-by: Angelo Compagnucci <angelo.compagnucci at gmail.com>
---
tests/hwsim/test_ext_password.py | 40 ++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/tests/hwsim/test_ext_password.py b/tests/hwsim/test_ext_password.py
index 4357c44e5..7e8e07aad 100644
--- a/tests/hwsim/test_ext_password.py
+++ b/tests/hwsim/test_ext_password.py
@@ -161,3 +161,43 @@ def test_ext_password_sae(dev, apdev):
dev[0].set("ext_password_backend", "test:sae1=12345678")
dev[0].connect("ext-pw-sae", raw_psk="ext:sae1", key_mgmt="SAE",
scan_freq="2412")
+
+def test_ext_password_save_config(dev, apdev, params):
+ """External password storage and SAVE_CONFIG"""
+ check_sae_capab(dev[0])
+ hapd = hostapd.add_ap(apdev[0],
+ hostapd.wpa2_params(ssid="ext-pw-psk",
+ passphrase="12345678"))
+ config = os.path.join(params['logdir'], 'ext_password_save_config.conf')
+ with open(config, "w") as f:
+ f.write("update_config=1\n")
+ f.write("ext_password_backend=test:psk1=12345678\n")
+
+ wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
+ try:
+ wpas.interface_add("wlan5", config=config)
+ wpas.connect("ext-pw-psk", raw_psk="ext:psk1", scan_freq="2412",
+ only_add_network=True)
+ wpas.connect("ext-pw-sae", raw_psk="ext:psk1", key_mgmt="SAE",
+ scan_freq="2412", only_add_network=True)
+ if "OK" not in wpas.request("SAVE_CONFIG"):
+ raise Exception("Failed to save configuration file")
+ with open(config, "r") as f:
+ data = f.read()
+ logger.info("Configuration file contents: " + data)
+ if data.count("psk=ext:psk1") != 2:
+ raise Exception("Networks with an external PSK were not saved")
+
+ wpas.interface_remove("wlan5")
+ wpas.interface_add("wlan5", config=config)
+ ids = [n['id'] for n in wpas.list_networks()
+ if n['ssid'] == "ext-pw-psk"]
+ if len(ids) != 1:
+ raise Exception("Saved network not found")
+ wpas.select_network(ids[0])
+ wpas.wait_connected()
+ finally:
+ try:
+ wpas.interface_remove("wlan5")
+ except:
+ pass
--
2.53.0
More information about the Hostap
mailing list