tests: PMKSA cache size limit in wpa_supplicant

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2015-01-31 13:26:46 +02:00
parent 19879b4572
commit d2432b8b7e
2 changed files with 47 additions and 2 deletions

View File

@ -606,3 +606,48 @@ def _test_pmksa_cache_preauth_oom(dev, apdev):
dev[0].wait_disconnected() dev[0].wait_disconnected()
dev[0].wait_connected() dev[0].wait_connected()
dev[0].dump_monitor() dev[0].dump_monitor()
def test_pmksa_cache_size_limit(dev, apdev):
"""PMKSA cache size limit in wpa_supplicant"""
try:
_test_pmksa_cache_size_limit(dev, apdev)
finally:
try:
hapd = hostapd.HostapdGlobal()
hapd.flush()
hapd.remove(apdev[0]['ifname'])
except:
pass
params = hostapd.wpa2_eap_params(ssid="test-pmksa-cache")
bssid = apdev[0]['bssid']
params['bssid'] = bssid
hostapd.add_ap(apdev[0]['ifname'], params)
def _test_pmksa_cache_size_limit(dev, apdev):
params = hostapd.wpa2_eap_params(ssid="test-pmksa-cache")
id = dev[0].connect("test-pmksa-cache", proto="RSN", key_mgmt="WPA-EAP",
eap="GPSK", identity="gpsk user",
password="abcdefghijklmnop0123456789abcdef",
scan_freq="2412", only_add_network=True)
for i in range(33):
bssid = apdev[0]['bssid'][0:15] + "%02x" % i
logger.info("Iteration with BSSID " + bssid)
params['bssid'] = bssid
hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].request("BSS_FLUSH 0")
dev[0].scan_for_bss(bssid, freq=2412, only_new=True)
dev[0].select_network(id)
dev[0].wait_connected()
dev[0].request("DISCONNECT")
dev[0].wait_disconnected()
dev[0].dump_monitor()
entries = len(dev[0].request("PMKSA").splitlines()) - 1
if i == 32:
if entries != 32:
raise Exception("Unexpected number of PMKSA entries after expected removal of the oldest entry")
elif i + 1 != entries:
raise Exception("Unexpected number of PMKSA entries")
hapd = hostapd.HostapdGlobal()
hapd.flush()
hapd.remove(apdev[0]['ifname'])

View File

@ -864,11 +864,11 @@ class WpaSupplicant:
if ev is None: if ev is None:
raise Exception("Scan timed out") raise Exception("Scan timed out")
def scan_for_bss(self, bssid, freq=None, force_scan=False): def scan_for_bss(self, bssid, freq=None, force_scan=False, only_new=False):
if not force_scan and self.get_bss(bssid) is not None: if not force_scan and self.get_bss(bssid) is not None:
return return
for i in range(0, 10): for i in range(0, 10):
self.scan(freq=freq, type="ONLY") self.scan(freq=freq, type="ONLY", only_new=only_new)
if self.get_bss(bssid) is not None: if self.get_bss(bssid) is not None:
return return
raise Exception("Could not find BSS " + bssid + " in scan") raise Exception("Could not find BSS " + bssid + " in scan")