aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2016-03-04 16:51:24 (GMT)
committerJouni Malinen <j@w1.fi>2016-05-02 08:08:25 (GMT)
commit5594df44c7cda554ab9d8bc8d8914fd5639a1c95 (patch)
tree8377c14f5cf59f3df95638c09118fc37f2ae937c
parent73e4abb24a936014727924d8b0b2965edfc117dd (diff)
downloadhostap-5594df44c7cda554ab9d8bc8d8914fd5639a1c95.zip
hostap-5594df44c7cda554ab9d8bc8d8914fd5639a1c95.tar.gz
hostap-5594df44c7cda554ab9d8bc8d8914fd5639a1c95.tar.bz2
tests: wpa_supplicant config file writing with arbitrary PSK value
Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
-rw-r--r--tests/hwsim/test_wpas_config.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/hwsim/test_wpas_config.py b/tests/hwsim/test_wpas_config.py
index 7bd17c1..7d4dc15 100644
--- a/tests/hwsim/test_wpas_config.py
+++ b/tests/hwsim/test_wpas_config.py
@@ -254,3 +254,48 @@ def test_wpas_config_file_wps2(dev, apdev):
os.rmdir(config)
except:
pass
+
+def test_wpas_config_file_set_psk(dev):
+ """wpa_supplicant config file parsing/writing with arbitrary PSK value"""
+ config = "/tmp/test_wpas_config_file.conf"
+ if os.path.exists(config):
+ os.remove(config)
+
+ wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
+
+ try:
+ with open(config, "w") as f:
+ f.write("update_config=1\n")
+
+ wpas.interface_add("wlan5", config=config)
+
+ id = wpas.add_network()
+ wpas.set_network_quoted(id, "ssid", "foo")
+ if "OK" in wpas.request('SET_NETWORK %d psk "12345678"\n}\nmodel_name=foobar\nnetwork={\n#\"' % id):
+ raise Exception("Invalid psk value accepted")
+
+ 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 "model_name" in data:
+ raise Exception("Unexpected parameter added to configuration")
+
+ wpas.interface_remove("wlan5")
+ wpas.interface_add("wlan5", config=config)
+
+ finally:
+ try:
+ os.remove(config)
+ except:
+ pass
+ try:
+ os.remove(config + ".tmp")
+ except:
+ pass
+ try:
+ os.rmdir(config)
+ except:
+ pass