aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2016-03-20 16:06:03 (GMT)
committerJouni Malinen <j@w1.fi>2016-03-20 16:06:03 (GMT)
commit865fa1e9ea87db7434d8b42686311cfe94e49352 (patch)
treef1d0dbc33e02c8c0bb0ea2ee185608190f7e3b08
parent9f2cf23e2e0d8f5c28a403c44fad1f65705f884e (diff)
downloadhostap-865fa1e9ea87db7434d8b42686311cfe94e49352.zip
hostap-865fa1e9ea87db7434d8b42686311cfe94e49352.tar.gz
hostap-865fa1e9ea87db7434d8b42686311cfe94e49352.tar.bz2
tests: PMKSA cache control interface operations
Signed-off-by: Jouni Malinen <j@w1.fi>
-rw-r--r--tests/hwsim/hostapd.py15
-rw-r--r--tests/hwsim/test_pmksa_cache.py43
2 files changed, 58 insertions, 0 deletions
diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py
index 0a4ad72..1282e71 100644
--- a/tests/hwsim/hostapd.py
+++ b/tests/hwsim/hostapd.py
@@ -319,6 +319,21 @@ class Hostapd:
vals[name_val[0]] = name_val[1]
return vals
+ def get_pmksa(self, addr):
+ res = self.request("PMKSA")
+ lines = res.splitlines()
+ for l in lines:
+ if addr not in l:
+ continue
+ vals = dict()
+ [index,aa,pmkid,expiration,opportunistic] = l.split(' ')
+ vals['index'] = index
+ vals['pmkid'] = pmkid
+ vals['expiration'] = expiration
+ vals['opportunistic'] = opportunistic
+ return vals
+ return None
+
def add_ap(ifname, params, wait_enabled=True, no_enable=False, timeout=30,
hostname=None, port=8878):
logger.info("Starting AP " + ifname)
diff --git a/tests/hwsim/test_pmksa_cache.py b/tests/hwsim/test_pmksa_cache.py
index c837c79..f044c4e 100644
--- a/tests/hwsim/test_pmksa_cache.py
+++ b/tests/hwsim/test_pmksa_cache.py
@@ -833,3 +833,46 @@ def test_pmksa_cache_preauth_wpas_oom(dev, apdev):
if state.startswith('0:'):
break
time.sleep(0.05)
+
+def test_pmksa_cache_ctrl(dev, apdev):
+ """PMKSA cache control interface operations"""
+ params = hostapd.wpa2_eap_params(ssid="test-pmksa-cache")
+ hapd = hostapd.add_ap(apdev[0]['ifname'], params)
+ bssid = apdev[0]['bssid']
+ addr = dev[0].own_addr()
+
+ dev[0].connect("test-pmksa-cache", proto="RSN", key_mgmt="WPA-EAP",
+ eap="GPSK", identity="gpsk user",
+ password="abcdefghijklmnop0123456789abcdef",
+ scan_freq="2412")
+
+ pmksa_sta = dev[0].get_pmksa(bssid)
+ if pmksa_sta is None:
+ raise Exception("No PMKSA cache entry created on STA")
+ pmksa_ap = hapd.get_pmksa(addr)
+ if pmksa_ap is None:
+ raise Exception("No PMKSA cache entry created on AP")
+ if pmksa_sta['pmkid'] != pmksa_ap['pmkid']:
+ raise Exception("PMKID mismatch in PMKSA cache entries")
+
+ if "OK" not in hapd.request("PMKSA_FLUSH"):
+ raise Exception("PMKSA_FLUSH failed")
+ pmksa_ap = hapd.get_pmksa(addr)
+ if pmksa_ap is not None:
+ raise Exception("PMKSA cache entry was not removed on AP")
+
+ dev[0].request("DISCONNECT")
+ dev[0].wait_disconnected()
+ dev[0].request("RECONNECT")
+ dev[0].wait_connected()
+
+ pmksa_sta2 = dev[0].get_pmksa(bssid)
+ if pmksa_sta2 is None:
+ raise Exception("No PMKSA cache entry created on STA after reconnect")
+ pmksa_ap2 = hapd.get_pmksa(addr)
+ if pmksa_ap2 is None:
+ raise Exception("No PMKSA cache entry created on AP after reconnect")
+ if pmksa_sta2['pmkid'] != pmksa_ap2['pmkid']:
+ raise Exception("PMKID mismatch in PMKSA cache entries after reconnect")
+ if pmksa_sta2['pmkid'] == pmksa_sta['pmkid']:
+ raise Exception("PMKID did not change after reconnect")