From efd43d85bdc27fd0a1b9b3082dee2f0a7dc28954 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 20 Oct 2013 13:41:23 +0300 Subject: [PATCH] tests: Test case for Hotspot 2.0 with external SIM processing This verifies network selection using 3GPP Network Information and connection using EAP-SIM with GSM authentication handled by an external program. Signed-hostap: Jouni Malinen --- tests/hwsim/test_ap_hs20.py | 68 ++++++++++++++++++++++++++++++++++++ tests/hwsim/wpasupplicant.py | 1 + 2 files changed, 69 insertions(+) diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index 95ff8050e..16be9ece5 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -10,6 +10,8 @@ import time import subprocess import logging logger = logging.getLogger(__name__) +import os.path +import subprocess import hostapd @@ -99,3 +101,69 @@ def test_ap_hs20_select(dev, apdev): raise Exception("Network selection timed out"); if "INTERWORKING-NO-MATCH" not in ev: raise Exception("Unexpected network match") + +def test_ap_hs20_ext_sim(dev, apdev): + """Hotspot 2.0 with external SIM processing""" + if not os.path.exists("/tmp/hlr_auc_gw.sock"): + logger.info("No hlr_auc_gw available"); + return "skip" + if not os.path.exists("../../hostapd/hlr_auc_gw"): + logger.info("No hlr_auc_gw available"); + return "skip" + bssid = apdev[0]['bssid'] + params = hs20_ap_params() + params['hessid'] = bssid + params['anqp_3gpp_cell_net'] = "232,01" + params['domain_name'] = "wlan.mnc001.mcc232.3gppnetwork.org" + hostapd.add_ap(apdev[0]['ifname'], params) + + dev[0].request("SET interworking 1") + dev[0].request("SET hs20 1") + dev[0].request("SET external_sim 1") + + id = dev[0].add_cred() + dev[0].set_cred_quoted(id, "imsi", "23201-0000000000") + dev[0].set_cred(id, "eap", "SIM") + + dev[0].dump_monitor() + dev[0].request("INTERWORKING_SELECT") + ev = dev[0].wait_event(["INTERWORKING-AP", "INTERWORKING-NO-MATCH"], + timeout=15) + if ev is None: + raise Exception("Network selection timed out") + if "INTERWORKING-NO-MATCH" in ev: + raise Exception("Matching network not found") + if bssid not in ev: + raise Exception("Unexpected BSSID in match") + if "type=home" not in ev: + raise Exception("Home network not recognized") + + dev[0].request("INTERWORKING_CONNECT " + bssid) + + ev = dev[0].wait_event(["CTRL-EVENT-EAP-METHOD"], timeout=15) + if ev is None: + raise Exception("Network connected timed out") + if "(SIM)" not in ev: + raise Exception("Unexpected EAP method selection") + + ev = dev[0].wait_event(["CTRL-REQ-SIM"], timeout=15) + if ev is None: + raise Exception("Wait for external SIM processing request timed out") + p = ev.split(':', 2) + if p[1] != "GSM-AUTH": + raise Exception("Unexpected CTRL-REQ-SIM type") + id = p[0].split('-')[3] + rand = p[2].split(' ')[0] + + res = subprocess.check_output(["../../hostapd/hlr_auc_gw", + "-m", + "auth_serv/hlr_auc_gw.milenage_db", + "GSM-AUTH-REQ 232010000000000 " + rand]) + if "GSM-AUTH-RESP" not in res: + raise Exception("Unexpected hlr_auc_gw response") + resp = res.split(' ')[2].rstrip() + + dev[0].request("CTRL-RSP-SIM-" + id + ":GSM-AUTH:" + resp) + ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15) + if ev is None: + raise Exception("Connection timed out") diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index cdc97b478..c2f085981 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -56,6 +56,7 @@ class WpaSupplicant: if not "OK" in res: logger.info("FLUSH to " + self.ifname + " failed: " + res) self.request("SET ignore_old_scan_res 0") + self.request("SET external_sim 0") self.request("P2P_SET per_sta_psk 0") self.request("P2P_SET disabled 0") self.request("P2P_SERVICE_FLUSH")