aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2016-03-04 15:24:29 (GMT)
committerJouni Malinen <j@w1.fi>2016-05-02 08:08:25 (GMT)
commitf529c0d9082b3ea4d165e4c74a9cb79f0498f204 (patch)
tree900ae8c4b2ab24c94f084d8935c07d90395c5c18
parentecbb0b3dc122b0d290987cf9c84010bbe53e1022 (diff)
downloadhostap-f529c0d9082b3ea4d165e4c74a9cb79f0498f204.zip
hostap-f529c0d9082b3ea4d165e4c74a9cb79f0498f204.tar.gz
hostap-f529c0d9082b3ea4d165e4c74a9cb79f0498f204.tar.bz2
tests: wpa_supplicant config file parsing/writing with WPS
This verifies that a WPA2PSK passphrase with control characters gets rejected in a WPS Credential and that control characters in SSID get written as a hexdump. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
-rw-r--r--tests/hwsim/test_wpas_config.py96
-rw-r--r--tests/hwsim/wps-ctrl-credbin0 -> 67 bytes
-rw-r--r--tests/hwsim/wps-ctrl-cred2bin0 -> 59 bytes
3 files changed, 96 insertions, 0 deletions
diff --git a/tests/hwsim/test_wpas_config.py b/tests/hwsim/test_wpas_config.py
index 55a4616..7bd17c1 100644
--- a/tests/hwsim/test_wpas_config.py
+++ b/tests/hwsim/test_wpas_config.py
@@ -9,6 +9,7 @@ logger = logging.getLogger()
import os
from wpasupplicant import WpaSupplicant
+import hostapd
def check_config(config):
with open(config, "r") as f:
@@ -158,3 +159,98 @@ def test_wpas_config_file(dev):
os.rmdir(config)
except:
pass
+
+def test_wpas_config_file_wps(dev, apdev):
+ """wpa_supplicant config file parsing/writing with WPS"""
+ config = "/tmp/test_wpas_config_file.conf"
+ if os.path.exists(config):
+ os.remove(config)
+
+ params = { "ssid": "test-wps", "eap_server": "1", "wps_state": "2",
+ "skip_cred_build": "1", "extra_cred": "wps-ctrl-cred" }
+ hapd = hostapd.add_ap(apdev[0]['ifname'], params)
+
+ 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)
+
+ hapd.request("WPS_PIN any 12345670")
+ wpas.scan_for_bss(apdev[0]['bssid'], freq="2412")
+ wpas.request("WPS_PIN " + apdev[0]['bssid'] + " 12345670")
+ ev = wpas.wait_event(["WPS-FAIL"], timeout=10)
+ if ev is None:
+ raise Exception("WPS-FAIL event timed out")
+
+ with open(config, "r") as f:
+ data = f.read()
+ logger.info("Configuration file contents: " + data)
+ if "network=" in data:
+ raise Exception("Unexpected network block in configuration data")
+
+ finally:
+ try:
+ os.remove(config)
+ except:
+ pass
+ try:
+ os.remove(config + ".tmp")
+ except:
+ pass
+ try:
+ os.rmdir(config)
+ except:
+ pass
+
+def test_wpas_config_file_wps2(dev, apdev):
+ """wpa_supplicant config file parsing/writing with WPS (2)"""
+ config = "/tmp/test_wpas_config_file.conf"
+ if os.path.exists(config):
+ os.remove(config)
+
+ params = { "ssid": "test-wps", "eap_server": "1", "wps_state": "2",
+ "skip_cred_build": "1", "extra_cred": "wps-ctrl-cred2" }
+ hapd = hostapd.add_ap(apdev[0]['ifname'], params)
+
+ 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)
+
+ hapd.request("WPS_PIN any 12345670")
+ wpas.scan_for_bss(apdev[0]['bssid'], freq="2412")
+ wpas.request("WPS_PIN " + apdev[0]['bssid'] + " 12345670")
+ ev = wpas.wait_event(["WPS-SUCCESS"], timeout=10)
+ if ev is None:
+ raise Exception("WPS-SUCCESS event timed out")
+
+ with open(config, "r") as f:
+ data = f.read()
+ logger.info("Configuration file contents: " + data)
+
+ with open(config, "r") as f:
+ data = f.read()
+ if "network=" not in data:
+ raise Exception("Missing network block in configuration data")
+ if "ssid=410a420d430044" not in data:
+ raise Exception("Unexpected ssid parameter value")
+
+ finally:
+ try:
+ os.remove(config)
+ except:
+ pass
+ try:
+ os.remove(config + ".tmp")
+ except:
+ pass
+ try:
+ os.rmdir(config)
+ except:
+ pass
diff --git a/tests/hwsim/wps-ctrl-cred b/tests/hwsim/wps-ctrl-cred
new file mode 100644
index 0000000..b02b783
--- /dev/null
+++ b/tests/hwsim/wps-ctrl-cred
Binary files differ
diff --git a/tests/hwsim/wps-ctrl-cred2 b/tests/hwsim/wps-ctrl-cred2
new file mode 100644
index 0000000..696a576
--- /dev/null
+++ b/tests/hwsim/wps-ctrl-cred2
Binary files differ