From 650383134db76f0fa57a26f662c47ed748d1339a Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 22 Mar 2014 18:57:44 +0200 Subject: [PATCH] tests: hostapd GET_CONFIG key_mgmt values Signed-off-by: Jouni Malinen --- tests/hwsim/hostapd.py | 9 +++++++++ tests/hwsim/test_ap_eap.py | 5 ++++- tests/hwsim/test_ap_ft.py | 16 +++++++++++++--- tests/hwsim/test_ap_pmf.py | 20 +++++++++++++++++++- tests/hwsim/test_ap_psk.py | 5 ++++- tests/hwsim/test_sae.py | 5 ++++- 6 files changed, 53 insertions(+), 7 deletions(-) diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py index ce40adcd2..ff32c47a9 100644 --- a/tests/hwsim/hostapd.py +++ b/tests/hwsim/hostapd.py @@ -168,6 +168,15 @@ class Hostapd: return vals[field] return None + def get_config(self): + res = self.request("GET_CONFIG") + lines = res.splitlines() + vals = dict() + for l in lines: + [name,value] = l.split('=', 1) + vals[name] = value + return vals + def mgmt_rx(self, timeout=5): ev = self.wait_event(["MGMT-RX"], timeout=timeout) if ev is None: diff --git a/tests/hwsim/test_ap_eap.py b/tests/hwsim/test_ap_eap.py index 87c4e108a..19afa048b 100644 --- a/tests/hwsim/test_ap_eap.py +++ b/tests/hwsim/test_ap_eap.py @@ -156,7 +156,10 @@ def test_ap_wpa2_eap_aka_prime(dev, apdev): def test_ap_wpa2_eap_ttls_pap(dev, apdev): """WPA2-Enterprise connection using EAP-TTLS/PAP""" params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") - hostapd.add_ap(apdev[0]['ifname'], params) + hapd = hostapd.add_ap(apdev[0]['ifname'], params) + key_mgmt = hapd.get_config()['key_mgmt'] + if key_mgmt.split(' ')[0] != "WPA-EAP": + raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt) eap_connect(dev[0], apdev[0], "TTLS", "pap user", anonymous_identity="ttls", password="password", ca_cert="auth_serv/ca.pem", phase2="auth=PAP", diff --git a/tests/hwsim/test_ap_ft.py b/tests/hwsim/test_ap_ft.py index e91a0988b..98ebc7446 100644 --- a/tests/hwsim/test_ap_ft.py +++ b/tests/hwsim/test_ap_ft.py @@ -116,7 +116,11 @@ def test_ap_ft_mixed(dev, apdev): passphrase="12345678" params = ft_params1(rsn=False, ssid=ssid, passphrase=passphrase) - hostapd.add_ap(apdev[0]['ifname'], params) + hapd = hostapd.add_ap(apdev[0]['ifname'], params) + key_mgmt = hapd.get_config()['key_mgmt'] + vals = key_mgmt.split(' ') + if vals[0] != "WPA-PSK" or vals[1] != "FT-PSK": + raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt) params = ft_params2(rsn=False, ssid=ssid, passphrase=passphrase) hostapd.add_ap(apdev[1]['ifname'], params) @@ -172,7 +176,10 @@ def test_ap_ft_sae(dev, apdev): hostapd.add_ap(apdev[0]['ifname'], params) params = ft_params2(ssid=ssid, passphrase=passphrase) params['wpa_key_mgmt'] = "FT-SAE" - hostapd.add_ap(apdev[1]['ifname'], params) + hapd = hostapd.add_ap(apdev[1]['ifname'], params) + key_mgmt = hapd.get_config()['key_mgmt'] + if key_mgmt.split(' ')[0] != "FT-SAE": + raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt) run_roams(dev[0], apdev, ssid, passphrase, sae=True) @@ -200,7 +207,10 @@ def test_ap_ft_eap(dev, apdev): params['wpa_key_mgmt'] = "FT-EAP" params["ieee8021x"] = "1" params = dict(radius.items() + params.items()) - hostapd.add_ap(apdev[0]['ifname'], params) + hapd = hostapd.add_ap(apdev[0]['ifname'], params) + key_mgmt = hapd.get_config()['key_mgmt'] + if key_mgmt.split(' ')[0] != "FT-EAP": + raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt) params = ft_params2(ssid=ssid, passphrase=passphrase) params['wpa_key_mgmt'] = "FT-EAP" params["ieee8021x"] = "1" diff --git a/tests/hwsim/test_ap_pmf.py b/tests/hwsim/test_ap_pmf.py index 446172919..79e1b75b5 100644 --- a/tests/hwsim/test_ap_pmf.py +++ b/tests/hwsim/test_ap_pmf.py @@ -13,6 +13,7 @@ import hwsim_utils import hostapd from wlantest import Wlantest from wpasupplicant import WpaSupplicant +from test_ap_eap import eap_connect def test_ap_pmf_required(dev, apdev): """WPA2-PSK AP with PMF required""" @@ -23,7 +24,10 @@ def test_ap_pmf_required(dev, apdev): params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678") params["wpa_key_mgmt"] = "WPA-PSK-SHA256"; params["ieee80211w"] = "2"; - hostapd.add_ap(apdev[0]['ifname'], params) + hapd = hostapd.add_ap(apdev[0]['ifname'], params) + key_mgmt = hapd.get_config()['key_mgmt'] + if key_mgmt.split(' ')[0] != "WPA-PSK-SHA256": + raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt) dev[0].connect(ssid, psk="12345678", ieee80211w="1", key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2", scan_freq="2412") @@ -184,3 +188,17 @@ def test_ap_pmf_sta_sa_query(dev, apdev): raise Exception("STA did not send SA Query") if wt.get_sta_counter("valid_saqueryresp_rx", bssid, addr) < 1: raise Exception("AP did not reply to SA Query") + +def test_ap_pmf_required_eap(dev, apdev): + """WPA2-EAP AP with PMF required""" + ssid = "test-pmf-required-eap" + params = hostapd.wpa2_eap_params(ssid=ssid) + params["wpa_key_mgmt"] = "WPA-EAP-SHA256"; + params["ieee80211w"] = "2"; + hapd = hostapd.add_ap(apdev[0]['ifname'], params) + key_mgmt = hapd.get_config()['key_mgmt'] + if key_mgmt.split(' ')[0] != "WPA-EAP-SHA256": + raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt) + dev[0].connect("test-pmf-required-eap", key_mgmt="WPA-EAP-SHA256", + ieee80211w="2", eap="PSK", identity="psk.user@example.com", + password_hex="0123456789abcdef0123456789abcdef") diff --git a/tests/hwsim/test_ap_psk.py b/tests/hwsim/test_ap_psk.py index 508007663..892460cff 100644 --- a/tests/hwsim/test_ap_psk.py +++ b/tests/hwsim/test_ap_psk.py @@ -17,7 +17,10 @@ def test_ap_wpa2_psk(dev, apdev): psk = '602e323e077bc63bd80307ef4745b754b0ae0a925c2638ecd13a794b9527b9e6' params = hostapd.wpa2_params(ssid=ssid) params['wpa_psk'] = psk - hostapd.add_ap(apdev[0]['ifname'], params) + hapd = hostapd.add_ap(apdev[0]['ifname'], params) + key_mgmt = hapd.get_config()['key_mgmt'] + if key_mgmt.split(' ')[0] != "WPA-PSK": + raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt) dev[0].connect(ssid, raw_psk=psk, scan_freq="2412") dev[1].connect(ssid, psk=passphrase, scan_freq="2412") diff --git a/tests/hwsim/test_sae.py b/tests/hwsim/test_sae.py index 196f6bb27..24e666536 100644 --- a/tests/hwsim/test_sae.py +++ b/tests/hwsim/test_sae.py @@ -17,7 +17,10 @@ def test_sae(dev, apdev): params = hostapd.wpa2_params(ssid="test-sae", passphrase="12345678") params['wpa_key_mgmt'] = 'SAE' - hostapd.add_ap(apdev[0]['ifname'], params) + hapd = hostapd.add_ap(apdev[0]['ifname'], params) + key_mgmt = hapd.get_config()['key_mgmt'] + if key_mgmt.split(' ')[0] != "SAE": + raise Exception("Unexpected GET_CONFIG(key_mgmt): " + key_mgmt) dev[0].request("SET sae_groups ") id = dev[0].connect("test-sae", psk="12345678", key_mgmt="SAE",