From 169e808e458a27c92d57321076380c736eab767e Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 12 Apr 2014 22:52:41 +0300 Subject: [PATCH] tests: Opportunistic key caching with the connect API Signed-off-by: Jouni Malinen --- tests/hwsim/test_pmksa_cache.py | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tests/hwsim/test_pmksa_cache.py b/tests/hwsim/test_pmksa_cache.py index ebe233233..b1d6bfe7e 100644 --- a/tests/hwsim/test_pmksa_cache.py +++ b/tests/hwsim/test_pmksa_cache.py @@ -10,6 +10,7 @@ import subprocess import time import hostapd +from wpasupplicant import WpaSupplicant from test_ap_eap import eap_connect def test_pmksa_cache_on_roam_back(dev, apdev): @@ -162,6 +163,58 @@ def test_pmksa_cache_opportunistic(dev, apdev): if pmksa['pmkid'] != pmksa1b['pmkid']: raise Exception("Unexpected PMKID change for AP1") +def test_pmksa_cache_opportunistic_connect(dev, apdev): + """Opportunistic PMKSA caching with connect API""" + params = hostapd.wpa2_eap_params(ssid="test-pmksa-cache") + params['okc'] = "1" + hostapd.add_ap(apdev[0]['ifname'], params) + bssid = apdev[0]['bssid'] + wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') + wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") + wpas.connect("test-pmksa-cache", proto="RSN", key_mgmt="WPA-EAP", + eap="GPSK", identity="gpsk user", + password="abcdefghijklmnop0123456789abcdef", okc=True, + scan_freq="2412") + pmksa = wpas.get_pmksa(bssid) + if pmksa is None: + raise Exception("No PMKSA cache entry created") + if pmksa['opportunistic'] != '0': + raise Exception("Unexpected opportunistic PMKSA cache entry") + + hostapd.add_ap(apdev[1]['ifname'], params) + bssid2 = apdev[1]['bssid'] + + wpas.dump_monitor() + logger.info("Roam to AP2") + wpas.scan(freq="2412") + wpas.request("ROAM " + bssid2) + ev = wpas.wait_event(["CTRL-EVENT-EAP-STARTED", + "CTRL-EVENT-CONNECTED"], timeout=10) + if ev is None: + raise Exception("Roaming with the AP timed out") + if "CTRL-EVENT-EAP-STARTED" in ev: + raise Exception("Unexpected EAP exchange") + pmksa2 = wpas.get_pmksa(bssid2) + if pmksa2 is None: + raise Exception("No PMKSA cache entry created") + + wpas.dump_monitor() + logger.info("Roam back to AP1") + wpas.scan(freq="2412") + wpas.request("ROAM " + bssid) + ev = wpas.wait_event(["CTRL-EVENT-EAP-STARTED", + "CTRL-EVENT-CONNECTED"], timeout=10) + if ev is None: + raise Exception("Roaming with the AP timed out") + if "CTRL-EVENT-EAP-STARTED" in ev: + raise Exception("Unexpected EAP exchange") + + pmksa1b = wpas.get_pmksa(bssid) + if pmksa1b is None: + raise Exception("No PMKSA cache entry found") + if pmksa['pmkid'] != pmksa1b['pmkid']: + raise Exception("Unexpected PMKID change for AP1") + def test_pmksa_cache_expiration(dev, apdev): """PMKSA cache entry expiration""" params = hostapd.wpa2_eap_params(ssid="test-pmksa-cache")