From: Jouni Malinen Date: Sat, 22 Feb 2025 20:09:49 +0000 (+0200) Subject: tests: Remove testing of Passpoiint OSU/OSEN/icons/etc. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=334000ec3376682de3fe988811783c26da8e869d;p=thirdparty%2Fhostap.git tests: Remove testing of Passpoiint OSU/OSEN/icons/etc. This functionality was removed from Passpoint spec v3.4 and will be removed from implementation, so prepare testing for that. Signed-off-by: Jouni Malinen --- diff --git a/tests/hwsim/auth_serv/eap_user.conf b/tests/hwsim/auth_serv/eap_user.conf index 738a50f70..0bd8eaae5 100644 --- a/tests/hwsim/auth_serv/eap_user.conf +++ b/tests/hwsim/auth_serv/eap_user.conf @@ -17,7 +17,6 @@ "psk.user@example.com" PSK 0123456789abcdef0123456789abcdef "vendor-test" VENDOR-TEST "foo" "vendor-test-2" VENDOR-TEST "foo" [2] -"osen@example.com" WFA-UNAUTH-TLS "unauth-tls" UNAUTH-TLS "WFA-SimpleConfig-Enrollee-1-0" WSC diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py index 1ffc96e7d..9cfe5a2b6 100644 --- a/tests/hwsim/hostapd.py +++ b/tests/hwsim/hostapd.py @@ -696,7 +696,7 @@ def add_ap(apdev, params, wait_enabled=True, no_enable=False, timeout=30, fields = ["ssid", "wpa_passphrase", "nas_identifier", "wpa_key_mgmt", "wpa", "wpa_deny_ptk0_rekey", "wpa_pairwise", "rsn_pairwise", "auth_server_addr", - "acct_server_addr", "osu_server_uri"] + "acct_server_addr"] for field in fields: if field in params: hapd.set(field, params[field]) diff --git a/tests/hwsim/test_ap_config.py b/tests/hwsim/test_ap_config.py index ea69abfeb..2d3493199 100644 --- a/tests/hwsim/test_ap_config.py +++ b/tests/hwsim/test_ap_config.py @@ -490,15 +490,9 @@ def test_ap_config_set_oom(dev, apdev): (1, "parse_anqp_elem", "SET anqp_elem 265:0000"), (2, "parse_anqp_elem", "SET anqp_elem 266:000000"), (1, "parse_venue_url", "SET venue_url 1:http://example.com/"), - (1, "hs20_parse_operator_icon", "SET operator_icon icon"), - (2, "hs20_parse_operator_icon", "SET operator_icon icon"), (1, "hs20_parse_conn_capab", "SET hs20_conn_capab 1:0:2"), (1, "hs20_parse_wan_metrics", "SET hs20_wan_metrics 01:8000:1000:80:240:3000"), - (1, "hs20_parse_icon", - "SET hs20_icon 32:32:eng:image/png:icon32:/tmp/icon32.png"), - (1, "hs20_parse_osu_server_uri", - "SET osu_server_uri https://example.com/osu/"), (1, "hostapd_config_parse_acs_chan_bias", "SET acs_chan_bias 1:0.8 6:0.8 11:0.8"), (2, "hostapd_config_parse_acs_chan_bias", @@ -536,12 +530,10 @@ def test_ap_config_set_oom(dev, apdev): if "FAIL" not in hapd.request(cmd): raise Exception("Command accepted during OOM: " + cmd) - hapd.set("hs20_icon", "32:32:eng:image/png:icon32:/tmp/icon32.png") hapd.set("hs20_conn_capab", "1:0:2") hapd.set("nai_realm", "0,example.com;example.net") hapd.set("venue_name", "eng:Example venue") hapd.set("roaming_consortium", "021122") - hapd.set("osu_server_uri", "https://example.com/osu/") hapd.set("vendor_elements", "01020304") hapd.set("vendor_elements", "01020304") hapd.set("vendor_elements", "") @@ -550,19 +542,9 @@ def test_ap_config_set_oom(dev, apdev): hapd.set("lci", "") hapd.set("civic", "") - tests = [(1, "hs20_parse_icon", - "SET hs20_icon 32:32:eng:image/png:icon32:/tmp/icon32.png"), - (1, "parse_roaming_consortium", "SET roaming_consortium 021122"), + tests = [(1, "parse_roaming_consortium", "SET roaming_consortium 021122"), (2, "parse_nai_realm", "SET nai_realm 0,example.com;example.net"), (1, "parse_lang_string", "SET venue_name eng:Example venue"), - (1, "hs20_parse_osu_server_uri", - "SET osu_server_uri https://example.com/osu/"), - (1, "hs20_parse_osu_nai", "SET osu_nai anonymous@example.com"), - (1, "hs20_parse_osu_nai2", "SET osu_nai2 anonymous@example.com"), - (1, "hostapd_parse_intlist", "SET osu_method_list 1 0"), - (1, "hs20_parse_osu_icon", "SET osu_icon icon32"), - (2, "hs20_parse_osu_icon", "SET osu_icon icon32"), - (2, "hs20_parse_osu_icon", "SET osu_icon icon32"), (1, "hs20_parse_conn_capab", "SET hs20_conn_capab 1:0:2")] for count, func, cmd in tests: with alloc_fail(hapd, count, func): diff --git a/tests/hwsim/test_ap_eap.py b/tests/hwsim/test_ap_eap.py index 96b6d0f27..3f214a9a9 100644 --- a/tests/hwsim/test_ap_eap.py +++ b/tests/hwsim/test_ap_eap.py @@ -7514,24 +7514,6 @@ def test_eap_tls_errors(dev, apdev): dev[0].request("REMOVE_NETWORK all") dev[0].wait_disconnected() - with alloc_fail(dev[0], 1, "eap_wfa_unauth_tls_init"): - dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", - eap="WFA-UNAUTH-TLS", - identity="osen@example.com", ca_cert="auth_serv/ca.pem", - wait_connect=False, scan_freq="2412") - wait_fail_trigger(dev[0], "GET_ALLOC_FAIL") - dev[0].request("REMOVE_NETWORK all") - dev[0].wait_disconnected() - - with alloc_fail(dev[0], 1, "eap_peer_tls_ssl_init;eap_wfa_unauth_tls_init"): - dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP", - eap="WFA-UNAUTH-TLS", - identity="osen@example.com", ca_cert="auth_serv/ca.pem", - wait_connect=False, scan_freq="2412") - wait_fail_trigger(dev[0], "GET_ALLOC_FAIL") - dev[0].request("REMOVE_NETWORK all") - dev[0].wait_disconnected() - def test_ap_wpa2_eap_status(dev, apdev): """EAP state machine status information""" params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index 6cd2918b2..14621a0a9 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -2747,78 +2747,6 @@ def run_ap_hs20_deauth_req_pmf_htc(dev, apdev): if ev is not None: raise Exception("Deauth imminent notice without PMF accepted") -def test_ap_hs20_remediation_required(dev, apdev): - """Hotspot 2.0 connection and remediation required from RADIUS""" - check_eap_capa(dev[0], "MSCHAPV2") - try: - _test_ap_hs20_remediation_required(dev, apdev) - finally: - dev[0].request("SET pmf 0") - -def _test_ap_hs20_remediation_required(dev, apdev): - bssid = apdev[0]['bssid'] - params = hs20_ap_params() - params['nai_realm'] = ["0,example.com,21[2:4]"] - hostapd.add_ap(apdev[0], params) - - dev[0].request("SET pmf 1") - dev[0].hs20_enable() - dev[0].add_cred_values({'realm': "example.com", - 'username': "hs20-subrem-test", - 'password': "password"}) - interworking_select(dev[0], bssid, freq="2412") - interworking_connect(dev[0], bssid, "TTLS") - ev = dev[0].wait_event(["HS20-SUBSCRIPTION-REMEDIATION"], timeout=5) - if ev is None: - raise Exception("Timeout on subscription remediation notice") - if " 1 https://example.com/" not in ev: - raise Exception("Unexpected subscription remediation event contents") - -def test_ap_hs20_remediation_required_ctrl(dev, apdev): - """Hotspot 2.0 connection and subrem from ctrl_iface""" - check_eap_capa(dev[0], "MSCHAPV2") - try: - _test_ap_hs20_remediation_required_ctrl(dev, apdev) - finally: - dev[0].request("SET pmf 0") - -def _test_ap_hs20_remediation_required_ctrl(dev, apdev): - bssid = apdev[0]['bssid'] - addr = dev[0].own_addr() - params = hs20_ap_params() - params['nai_realm'] = ["0,example.com,21[2:4]"] - hapd = hostapd.add_ap(apdev[0], params) - - dev[0].request("SET pmf 1") - dev[0].hs20_enable() - dev[0].add_cred_values(default_cred()) - interworking_select(dev[0], bssid, freq="2412") - interworking_connect(dev[0], bssid, "TTLS") - - hapd.wait_sta() - hapd.request("HS20_WNM_NOTIF " + addr + " https://example.com/") - ev = dev[0].wait_event(["HS20-SUBSCRIPTION-REMEDIATION"], timeout=5) - if ev is None: - raise Exception("Timeout on subscription remediation notice") - if " 1 https://example.com/" not in ev: - raise Exception("Unexpected subscription remediation event contents") - - hapd.request("HS20_WNM_NOTIF " + addr) - ev = dev[0].wait_event(["HS20-SUBSCRIPTION-REMEDIATION"], timeout=5) - if ev is None: - raise Exception("Timeout on subscription remediation notice") - if not ev.endswith("HS20-SUBSCRIPTION-REMEDIATION "): - raise Exception("Unexpected subscription remediation event contents: " + ev) - - if "FAIL" not in hapd.request("HS20_WNM_NOTIF "): - raise Exception("Unexpected HS20_WNM_NOTIF success") - if "FAIL" not in hapd.request("HS20_WNM_NOTIF foo"): - raise Exception("Unexpected HS20_WNM_NOTIF success") - if "FAIL" not in hapd.request("HS20_WNM_NOTIF " + addr + " https://12345678923456789842345678456783456712345678923456789842345678456783456712345678923456789842345678456783456712345678923456789842345678456783456712345678923456789842345678456783456712345678923456789842345678456783456712345678923456789842345678456783456712345678927.very.long.example.com/"): - raise Exception("Unexpected HS20_WNM_NOTIF success") - if "OK" not in hapd.request("HS20_WNM_NOTIF " + addr + " "): - raise Exception("HS20_WNM_NOTIF failed with empty URL") - def test_ap_hs20_session_info(dev, apdev): """Hotspot 2.0 connection and session information from RADIUS""" check_eap_capa(dev[0], "MSCHAPV2") @@ -2852,81 +2780,6 @@ def _test_ap_hs20_session_info(dev, apdev): if ev is None: raise Exception("Scan not completed") -def test_ap_hs20_osen(dev, apdev): - """Hotspot 2.0 OSEN connection""" - params = {'ssid': "osen", - 'osen': "1", - 'auth_server_addr': "127.0.0.1", - 'auth_server_port': "1812", - 'auth_server_shared_secret': "radius"} - hostapd.add_ap(apdev[0], params) - - dev[1].connect("osen", key_mgmt="NONE", scan_freq="2412", - wait_connect=False) - if "WEP40" in dev[2].get_capability("group"): - dev[2].connect("osen", key_mgmt="NONE", wep_key0='"hello"', - scan_freq="2412", wait_connect=False) - dev[0].flush_scan_cache() - dev[0].connect("osen", proto="OSEN", key_mgmt="OSEN", pairwise="CCMP", - group="GTK_NOT_USED CCMP", - eap="WFA-UNAUTH-TLS", identity="osen@example.com", - ca_cert="auth_serv/ca.pem", - scan_freq="2412") - res = dev[0].get_bss(apdev[0]['bssid'])['flags'] - if "[OSEN-OSEN-CCMP]" not in res: - raise Exception("OSEN not reported in BSS") - if "[WEP]" in res: - raise Exception("WEP reported in BSS") - res = dev[0].request("SCAN_RESULTS") - if "[OSEN-OSEN-CCMP]" not in res: - raise Exception("OSEN not reported in SCAN_RESULTS") - - wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') - wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") - wpas.connect("osen", proto="OSEN", key_mgmt="OSEN", pairwise="CCMP", - group="GTK_NOT_USED CCMP", - eap="WFA-UNAUTH-TLS", identity="osen@example.com", - ca_cert="auth_serv/ca.pem", - scan_freq="2412") - wpas.request("DISCONNECT") - -def test_ap_hs20_osen_single_ssid(dev, apdev): - """Hotspot 2.0 OSEN-single-SSID connection""" - bssid = apdev[0]['bssid'] - params = hs20_ap_params() - params['wpa_key_mgmt'] = "WPA-EAP OSEN" - params['hessid'] = bssid - hapd = hostapd.add_ap(apdev[0], params) - - dev[0].flush_scan_cache() - - # RSN-OSEN (for OSU) - dev[0].connect("test-hs20", proto="OSEN", key_mgmt="OSEN", pairwise="CCMP", - group="CCMP GTK_NOT_USED", - eap="WFA-UNAUTH-TLS", identity="osen@example.com", - ca_cert="auth_serv/ca.pem", ieee80211w='2', - scan_freq="2412") - # RSN-EAP (for data connection) - dev[1].connect("test-hs20", key_mgmt="WPA-EAP", eap="TTLS", - identity="hs20-test", password="password", - ca_cert="auth_serv/ca.pem", phase2="auth=MSCHAPV2", - pairwise="CCMP", group="CCMP", - ieee80211w='2', scan_freq="2412") - - res = dev[0].get_bss(apdev[0]['bssid'])['flags'] - if "[WPA2-EAP+OSEN-CCMP]" not in res: - raise Exception("OSEN not reported in BSS") - if "[WEP]" in res: - raise Exception("WEP reported in BSS") - res = dev[0].request("SCAN_RESULTS") - if "[WPA2-EAP+OSEN-CCMP]" not in res: - raise Exception("OSEN not reported in SCAN_RESULTS") - - hwsim_utils.test_connectivity(dev[1], hapd) - hwsim_utils.test_connectivity(dev[0], hapd, broadcast=False) - hwsim_utils.test_connectivity(dev[0], hapd, timeout=1, - success_expected=False) - def test_ap_hs20_network_preference(dev, apdev): """Hotspot 2.0 network selection with preferred home network""" check_eap_capa(dev[0], "MSCHAPV2") @@ -3117,896 +2970,6 @@ def test_ap_hs20_interworking_select_blocking_scan(dev, apdev): raise Exception("Unexpected SCAN command result") dev[0].wait_connected(timeout=15) -def test_ap_hs20_fetch_osu(dev, apdev): - """Hotspot 2.0 OSU provider and icon fetch""" - 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) - - bssid2 = apdev[1]['bssid'] - params = hs20_ap_params(ssid="test-hs20b") - params['hessid'] = bssid2 - params['hs20_icon'] = "128:80:zxx:image/png:w1fi_logo:w1fi_logo.png" - params['osu_ssid'] = '"HS 2.0 OSU OSEN"' - params['osu_method_list'] = "0" - params['osu_nai'] = "osen@example.com" - params['osu_friendly_name'] = ["eng:Test2 OSU", "fin:Testi2-OSU"] - params['osu_icon'] = "w1fi_logo" - params['osu_service_desc'] = ["eng:Example services2", "fin:Esimerkkipalveluja2"] - params['osu_server_uri'] = "https://example.org/osu/" - hostapd.add_ap(apdev[1], params) - - with open("w1fi_logo.png", "rb") as f: - orig_logo = f.read() - 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 - try: - dev[1].scan_for_bss(bssid, freq="2412") - dev[2].scan_for_bss(bssid, freq="2412") - dev[0].request("SET osu_dir " + dir) - dev[0].request("FETCH_OSU") - if "FAIL" not in dev[1].request("HS20_ICON_REQUEST foo w1fi_logo"): - raise Exception("Invalid HS20_ICON_REQUEST accepted") - if "OK" not in dev[1].request("HS20_ICON_REQUEST " + bssid + " w1fi_logo"): - raise Exception("HS20_ICON_REQUEST failed") - if "OK" not in dev[2].request("REQ_HS20_ICON " + bssid + " w1fi_logo"): - raise Exception("REQ_HS20_ICON failed") - icons = 0 - while True: - ev = dev[0].wait_event(["OSU provider fetch completed", - "RX-HS20-ANQP-ICON"], timeout=15) - if ev is None: - raise Exception("Timeout on OSU fetch") - if "OSU provider fetch completed" in ev: - break - if "RX-HS20-ANQP-ICON" in ev: - with open(ev.split(' ')[1], "rb") as f: - logo = f.read() - if logo == orig_logo: - icons += 1 - - with open(dir + "/osu-providers.txt", "r") as f: - prov = f.read() - logger.debug("osu-providers.txt: " + prov) - if "OSU-PROVIDER " + bssid not in prov: - raise Exception("Missing OSU_PROVIDER(1)") - if "OSU-PROVIDER " + bssid2 not in prov: - raise Exception("Missing OSU_PROVIDER(2)") - finally: - files = [f for f in os.listdir(dir) if f.startswith("osu-")] - for f in files: - os.remove(dir + "/" + f) - os.rmdir(dir) - - if icons != 2: - raise Exception("Unexpected number of icons fetched") - - ev = dev[1].wait_event(["GAS-QUERY-START"], timeout=5) - if ev is None: - raise Exception("Timeout on GAS-QUERY-DONE") - ev = dev[1].wait_event(["GAS-QUERY-DONE"], timeout=5) - if ev is None: - raise Exception("Timeout on GAS-QUERY-DONE") - if "freq=2412 status_code=0 result=SUCCESS" not in ev: - raise Exception("Unexpected GAS-QUERY-DONE: " + ev) - ev = dev[1].wait_event(["RX-HS20-ANQP"], timeout=15) - if ev is None: - raise Exception("Timeout on icon fetch") - if "Icon Binary File" not in ev: - raise Exception("Unexpected ANQP element") - - ev = dev[2].wait_event(["RX-HS20-ICON"], timeout=5) - if ev is None: - raise Exception("Timeout on RX-HS20-ICON") - event_icon_len = ev.split(' ')[3] - if " w1fi_logo " not in ev: - raise Exception("RX-HS20-ICON did not have the expected file name") - if bssid not in ev: - raise Exception("RX-HS20-ICON did not have the expected BSSID") - if "FAIL" in dev[2].request("GET_HS20_ICON " + bssid + " w1fi_logo 0 10"): - raise Exception("GET_HS20_ICON 0..10 failed") - if "FAIL" in dev[2].request("GET_HS20_ICON " + bssid + " w1fi_logo 5 10"): - raise Exception("GET_HS20_ICON 5..15 failed") - if "FAIL" not in dev[2].request("GET_HS20_ICON " + bssid + " w1fi_logo 100000 10"): - raise Exception("Unexpected success of GET_HS20_ICON with too large offset") - if "FAIL" not in dev[2].request("GET_HS20_ICON " + bssid + " no_such_logo 0 10"): - raise Exception("GET_HS20_ICON for not existing icon succeeded") - if "FAIL" not in dev[2].request("GET_HS20_ICON " + bssid + " w1fi_logo 0 3070"): - raise Exception("GET_HS20_ICON with too many output bytes to fit the buffer succeeded") - if "FAIL" not in dev[2].request("GET_HS20_ICON " + bssid + " w1fi_logo 0 0"): - raise Exception("GET_HS20_ICON 0..0 succeeded") - icon = b'' - pos = 0 - while True: - if pos > 100000: - raise Exception("Unexpectedly long icon") - res = dev[2].request("GET_HS20_ICON " + bssid + " w1fi_logo %d 1000" % pos) - if res.startswith("FAIL"): - break - icon += base64.b64decode(res) - pos += 1000 - hex = binascii.hexlify(icon).decode() - if not hex.startswith("0009696d6167652f706e677d1d"): - raise Exception("Unexpected beacon binary header: " + hex) - with open('w1fi_logo.png', 'rb') as f: - data = f.read() - if icon[13:] != data: - raise Exception("Unexpected icon data") - if len(icon) != int(event_icon_len): - raise Exception("Unexpected RX-HS20-ICON event length: " + event_icon_len) - - for i in range(3): - if "OK" not in dev[i].request("REQ_HS20_ICON " + bssid + " w1fi_logo"): - raise Exception("REQ_HS20_ICON failed [2]") - for i in range(3): - ev = dev[i].wait_event(["RX-HS20-ICON"], timeout=5) - if ev is None: - raise Exception("Timeout on RX-HS20-ICON [2]") - - if "FAIL" not in dev[2].request("DEL_HS20_ICON foo w1fi_logo"): - raise Exception("Invalid DEL_HS20_ICON accepted") - if "OK" not in dev[2].request("DEL_HS20_ICON " + bssid + " w1fi_logo"): - raise Exception("DEL_HS20_ICON failed") - if "OK" not in dev[1].request("DEL_HS20_ICON " + bssid): - raise Exception("DEL_HS20_ICON failed") - if "OK" not in dev[0].request("DEL_HS20_ICON "): - raise Exception("DEL_HS20_ICON failed") - for i in range(3): - if "FAIL" not in dev[i].request("DEL_HS20_ICON "): - raise Exception("DEL_HS20_ICON accepted when no icons left") - -def test_ap_hs20_fetch_osu_no_info(dev, apdev): - """Hotspot 2.0 OSU provider and no AP with info""" - bssid = apdev[0]['bssid'] - params = hs20_ap_params() - 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) - dev[0].request("FETCH_OSU") - 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 test_ap_hs20_fetch_osu_no_icon(dev, apdev): - """Hotspot 2.0 OSU provider and no icon found""" - bssid = apdev[0]['bssid'] - params = hs20_ap_params() - params['hs20_icon'] = "128:80:zxx:image/png:w1fi_logo:w1fi_logo-no-file.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) - dev[0].request("FETCH_OSU") - 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 test_ap_hs20_fetch_osu_single_ssid(dev, apdev): - """Hotspot 2.0 OSU provider and single SSID""" - bssid = apdev[0]['bssid'] - params = hs20_ap_params() - params['hs20_icon'] = "128:80:zxx:image/png:w1fi_logo:w1fi_logo-no-file.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_nai2'] = "osen@example.com" - params['osu_icon'] = "w1fi_logo" - params['osu_service_desc'] = ["eng:Example services", - "fin:Esimerkkipalveluja"] - params['osu_server_uri'] = "https://example.com/osu/" - params['wpa_key_mgmt'] = "WPA-EAP OSEN" - 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) - dev[0].request("FETCH_OSU") - ev = dev[0].wait_event(["OSU provider fetch completed"], timeout=30) - if ev is None: - raise Exception("Timeout on OSU fetch") - osu_ssid = False - osu_ssid2 = False - osu_nai = False - osu_nai2 = False - with open(os.path.join(dir, "osu-providers.txt"), "r") as f: - for l in f.readlines(): - logger.info(l.strip()) - if l.strip() == "osu_ssid=HS 2.0 OSU open": - osu_ssid = True - if l.strip() == "osu_ssid2=test-hs20": - osu_ssid2 = True - if l.strip().startswith("osu_nai="): - osu_nai = True - if l.strip() == "osu_nai2=osen@example.com": - osu_nai2 = True - if not osu_ssid: - raise Exception("osu_ssid not reported") - if not osu_ssid2: - raise Exception("osu_ssid2 not reported") - if osu_nai: - raise Exception("osu_nai reported unexpectedly") - if not osu_nai2: - raise Exception("osu_nai2 not reported") - 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 test_ap_hs20_fetch_osu_single_ssid2(dev, apdev): - """Hotspot 2.0 OSU provider and single SSID (two OSU providers)""" - bssid = apdev[0]['bssid'] - params = hs20_ap_params() - params['hs20_icon'] = "128:80:zxx:image/png:w1fi_logo:w1fi_logo-no-file.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_nai2'] = "osen@example.com" - params['osu_icon'] = "w1fi_logo" - params['osu_service_desc'] = ["eng:Example services", - "fin:Esimerkkipalveluja"] - params['osu_server_uri'] = "https://example.com/osu/" - params['wpa_key_mgmt'] = "WPA-EAP OSEN" - hapd = hostapd.add_ap(apdev[0], params, no_enable=True) - - hapd.set('osu_server_uri', 'https://another.example.com/osu/') - hapd.set('osu_method_list', "1") - hapd.set('osu_nai2', "osen@another.example.com") - hapd.enable() - - 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) - dev[0].request("FETCH_OSU") - ev = dev[0].wait_event(["OSU provider fetch completed"], timeout=30) - if ev is None: - raise Exception("Timeout on OSU fetch") - osu_ssid = False - osu_ssid2 = False - osu_nai = False - osu_nai2 = False - osu_nai2b = False - with open(os.path.join(dir, "osu-providers.txt"), "r") as f: - for l in f.readlines(): - logger.info(l.strip()) - if l.strip() == "osu_ssid=HS 2.0 OSU open": - osu_ssid = True - if l.strip() == "osu_ssid2=test-hs20": - osu_ssid2 = True - if l.strip().startswith("osu_nai="): - osu_nai = True - if l.strip() == "osu_nai2=osen@example.com": - osu_nai2 = True - if l.strip() == "osu_nai2=osen@another.example.com": - osu_nai2b = True - if not osu_ssid: - raise Exception("osu_ssid not reported") - if not osu_ssid2: - raise Exception("osu_ssid2 not reported") - if osu_nai: - raise Exception("osu_nai reported unexpectedly") - if not osu_nai2: - raise Exception("osu_nai2 not reported") - if not osu_nai2b: - raise Exception("osu_nai2b not reported") - 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 get_icon(dev, bssid, iconname): - icon = b'' - 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], params) - - dev[0].scan_for_bss(bssid, freq="2412") - run_req_hs20_icon(dev, bssid) - -def run_req_hs20_icon(dev, bssid): - # 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', 'rb') as f: - data = f.read() - if data1 != data: - raise Exception("Unexpected icon data (1)") - - with open('auth_serv/sha512-server.pem', 'rb') 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_operator_icon(dev, apdev): - """Hotspot 2.0 operator icons""" - bssid = apdev[0]['bssid'] - params = hs20_ap_params() - params['hs20_icon'] = ["128:80:zxx:image/png:w1fi_logo:w1fi_logo.png", - "500:300:fi:image/png:test_logo:auth_serv/sha512-server.pem"] - params['operator_icon'] = ["w1fi_logo", "unknown_logo", "test_logo"] - hostapd.add_ap(apdev[0], params) - - value = struct.pack('