tests: Multi-icon fetch with REQ_HS20_ICON

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2016-02-27 11:14:02 +02:00
parent 13a17a77a4
commit 1018bc99b7

View file

@ -2326,6 +2326,125 @@ def test_ap_hs20_fetch_osu(dev, apdev):
if "FAIL" not in dev[i].request("DEL_HS20_ICON "):
raise Exception("DEL_HS20_ICON accepted when no icons left")
def get_icon(dev, bssid, iconname):
icon = ""
pos = 0
while True:
if pos > 100000:
raise Exception("Unexpectedly long icon")
res = dev.request("GET_HS20_ICON " + bssid + " " + iconname + " %d 3000" % pos)
if res.startswith("FAIL"):
break
icon += base64.b64decode(res)
pos += 3000
if len(icon) < 13:
raise Exception("Too short GET_HS20_ICON response")
return icon[0:13], icon[13:]
def test_ap_hs20_req_hs20_icon(dev, apdev):
"""Hotspot 2.0 OSU provider and multi-icon fetch with REQ_HS20_ICON"""
bssid = apdev[0]['bssid']
params = hs20_ap_params()
params['hs20_icon'] = [ "128:80:zxx:image/png:w1fi_logo:w1fi_logo.png",
"128:80:zxx:image/png:test_logo:auth_serv/sha512-server.pem" ]
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", "w1fi_logo2" ]
params['osu_service_desc'] = [ "eng:Example services", "fin:Esimerkkipalveluja" ]
params['osu_server_uri'] = "https://example.com/osu/"
hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].scan_for_bss(bssid, freq="2412")
# First, fetch two icons from the AP to wpa_supplicant
if "OK" not in dev[0].request("REQ_HS20_ICON " + bssid + " w1fi_logo"):
raise Exception("REQ_HS20_ICON failed")
ev = dev[0].wait_event(["RX-HS20-ICON"], timeout=5)
if ev is None:
raise Exception("Timeout on RX-HS20-ICON (1)")
if "OK" not in dev[0].request("REQ_HS20_ICON " + bssid + " test_logo"):
raise Exception("REQ_HS20_ICON failed")
ev = dev[0].wait_event(["RX-HS20-ICON"], timeout=5)
if ev is None:
raise Exception("Timeout on RX-HS20-ICON (2)")
# Then, fetch the icons from wpa_supplicant for validation
hdr, data1 = get_icon(dev[0], bssid, "w1fi_logo")
hdr, data2 = get_icon(dev[0], bssid, "test_logo")
with open('w1fi_logo.png', 'r') as f:
data = f.read()
if data1 != data:
raise Exception("Unexpected icon data (1)")
with open('auth_serv/sha512-server.pem', 'r') as f:
data = f.read()
if data2 != data:
raise Exception("Unexpected icon data (2)")
# Finally, delete the icons from wpa_supplicant
if "OK" not in dev[0].request("DEL_HS20_ICON " + bssid + " w1fi_logo"):
raise Exception("DEL_HS20_ICON failed")
if "OK" not in dev[0].request("DEL_HS20_ICON " + bssid + " test_logo"):
raise Exception("DEL_HS20_ICON failed")
def test_ap_hs20_req_hs20_icon_parallel(dev, apdev):
"""Hotspot 2.0 OSU provider and multi-icon parallel fetch with REQ_HS20_ICON"""
bssid = apdev[0]['bssid']
params = hs20_ap_params()
params['hs20_icon'] = [ "128:80:zxx:image/png:w1fi_logo:w1fi_logo.png",
"128:80:zxx:image/png:test_logo:auth_serv/sha512-server.pem" ]
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", "w1fi_logo2" ]
params['osu_service_desc'] = [ "eng:Example services", "fin:Esimerkkipalveluja" ]
params['osu_server_uri'] = "https://example.com/osu/"
hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].scan_for_bss(bssid, freq="2412")
# First, fetch two icons from the AP to wpa_supplicant
if "OK" not in dev[0].request("REQ_HS20_ICON " + bssid + " w1fi_logo"):
raise Exception("REQ_HS20_ICON failed")
if "OK" not in dev[0].request("REQ_HS20_ICON " + bssid + " test_logo"):
raise Exception("REQ_HS20_ICON failed")
ev = dev[0].wait_event(["RX-HS20-ICON"], timeout=5)
if ev is None:
raise Exception("Timeout on RX-HS20-ICON (1)")
ev = dev[0].wait_event(["RX-HS20-ICON"], timeout=5)
if ev is None:
raise Exception("Timeout on RX-HS20-ICON (2)")
# Then, fetch the icons from wpa_supplicant for validation
hdr, data1 = get_icon(dev[0], bssid, "w1fi_logo")
hdr, data2 = get_icon(dev[0], bssid, "test_logo")
with open('w1fi_logo.png', 'r') as f:
data = f.read()
if data1 != data:
raise Exception("Unexpected icon data (1)")
with open('auth_serv/sha512-server.pem', 'r') as f:
data = f.read()
if data2 != data:
raise Exception("Unexpected icon data (2)")
# Finally, delete the icons from wpa_supplicant
if "OK" not in dev[0].request("DEL_HS20_ICON " + bssid + " w1fi_logo"):
raise Exception("DEL_HS20_ICON failed")
if "OK" not in dev[0].request("DEL_HS20_ICON " + bssid + " test_logo"):
raise Exception("DEL_HS20_ICON failed")
def test_ap_hs20_fetch_osu_stop(dev, apdev):
"""Hotspot 2.0 OSU provider fetch stopped"""
bssid = apdev[0]['bssid']