tests: Hotspot 2.0 OSU provider and OOM

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2016-07-15 13:26:11 +03:00
parent f281f508b7
commit 19f2a3f357

View File

@ -3355,6 +3355,49 @@ def test_ap_hs20_fetch_osu_invalid_dir(dev, apdev):
if ev is None:
raise Exception("Timeout on OSU fetch")
def test_ap_hs20_fetch_osu_oom(dev, apdev):
"""Hotspot 2.0 OSU provider and OOM"""
bssid = apdev[0]['bssid']
params = hs20_ap_params()
params['hs20_icon'] = "128:80:zxx:image/png:w1fi_logo:w1fi_logo.png"
params['osu_ssid'] = '"HS 2.0 OSU open"'
params['osu_method_list'] = "1"
params['osu_friendly_name'] = [ "eng:Test OSU", "fin:Testi-OSU" ]
params['osu_icon'] = "w1fi_logo"
params['osu_service_desc'] = [ "eng:Example services", "fin:Esimerkkipalveluja" ]
params['osu_server_uri'] = "https://example.com/osu/"
hostapd.add_ap(apdev[0], params)
dev[0].hs20_enable()
dir = "/tmp/osu-fetch"
if os.path.isdir(dir):
files = [ f for f in os.listdir(dir) if f.startswith("osu-") ]
for f in files:
os.remove(dir + "/" + f)
else:
try:
os.makedirs(dir)
except:
pass
dev[0].scan_for_bss(bssid, freq="2412")
try:
dev[0].request("SET osu_dir " + dir)
with alloc_fail(dev[0], 1, "=hs20_osu_add_prov"):
dev[0].request("FETCH_OSU no-scan")
ev = dev[0].wait_event(["OSU provider fetch completed"], timeout=30)
if ev is None:
raise Exception("Timeout on OSU fetch")
with alloc_fail(dev[0], 1, "hs20_anqp_send_req;hs20_next_osu_icon"):
dev[0].request("FETCH_OSU no-scan")
ev = dev[0].wait_event(["OSU provider fetch completed"], timeout=30)
if ev is None:
raise Exception("Timeout on OSU fetch")
finally:
files = [ f for f in os.listdir(dir) if f.startswith("osu-") ]
for f in files:
os.remove(dir + "/" + f)
os.rmdir(dir)
def build_prov(prov):
data = binascii.unhexlify(prov)
return binascii.unhexlify('013001') + struct.pack('<H', len(data)) + data