tests: Add helper functions for Hotspot 2.0 test cases
These make it easier to add new test cases for Interworking network selection. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
f4defd91cd
commit
bbe867672e
2 changed files with 87 additions and 92 deletions
|
@ -44,109 +44,50 @@ def hs20_ap_params():
|
||||||
params['anqp_3gpp_cell_net'] = "244,91"
|
params['anqp_3gpp_cell_net'] = "244,91"
|
||||||
return params
|
return params
|
||||||
|
|
||||||
def test_ap_hs20_select(dev, apdev):
|
def interworking_select(dev, bssid, type=None, no_match=False):
|
||||||
"""Hotspot 2.0 network selection"""
|
dev.dump_monitor()
|
||||||
bssid = apdev[0]['bssid']
|
dev.request("INTERWORKING_SELECT")
|
||||||
params = hs20_ap_params()
|
ev = dev.wait_event(["INTERWORKING-AP", "INTERWORKING-NO-MATCH"],
|
||||||
params['hessid'] = bssid
|
timeout=15)
|
||||||
hostapd.add_ap(apdev[0]['ifname'], params)
|
|
||||||
|
|
||||||
dev[0].request("SET interworking 1")
|
|
||||||
dev[0].request("SET hs20 1")
|
|
||||||
|
|
||||||
id = dev[0].add_cred()
|
|
||||||
dev[0].set_cred_quoted(id, "realm", "example.com");
|
|
||||||
dev[0].set_cred_quoted(id, "username", "test");
|
|
||||||
dev[0].set_cred_quoted(id, "password", "secret");
|
|
||||||
dev[0].set_cred_quoted(id, "domain", "example.com");
|
|
||||||
|
|
||||||
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:
|
if ev is None:
|
||||||
raise Exception("Network selection timed out");
|
raise Exception("Network selection timed out");
|
||||||
|
if no_match:
|
||||||
|
if "INTERWORKING-NO-MATCH" not in ev:
|
||||||
|
raise Exception("Unexpected network match")
|
||||||
|
return
|
||||||
if "INTERWORKING-NO-MATCH" in ev:
|
if "INTERWORKING-NO-MATCH" in ev:
|
||||||
raise Exception("Matching network not found")
|
raise Exception("Matching network not found")
|
||||||
if bssid not in ev:
|
if bssid not in ev:
|
||||||
raise Exception("Unexpected BSSID in match")
|
raise Exception("Unexpected BSSID in match")
|
||||||
if "type=home" not in ev:
|
if type and "type=" + type not in ev:
|
||||||
raise Exception("Home network not recognized")
|
raise Exception("Network type not recognized correctly")
|
||||||
|
|
||||||
dev[0].remove_cred(id)
|
def check_sp_type(dev, sp_type):
|
||||||
id = dev[0].add_cred()
|
type = dev.get_status_field("sp_type")
|
||||||
dev[0].set_cred_quoted(id, "realm", "example.com")
|
if type is None:
|
||||||
dev[0].set_cred_quoted(id, "username", "test")
|
raise Exception("sp_type not available")
|
||||||
dev[0].set_cred_quoted(id, "password", "secret")
|
if type != sp_type:
|
||||||
dev[0].set_cred_quoted(id, "domain", "no.match.example.com")
|
raise Exception("sp_type did not indicate home network")
|
||||||
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=roaming" not in ev:
|
|
||||||
raise Exception("Roaming network not recognized")
|
|
||||||
|
|
||||||
dev[0].set_cred_quoted(id, "realm", "no.match.example.com");
|
def hlr_auc_gw_available():
|
||||||
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" 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"):
|
if not os.path.exists("/tmp/hlr_auc_gw.sock"):
|
||||||
logger.info("No hlr_auc_gw available");
|
logger.info("No hlr_auc_gw available");
|
||||||
return "skip"
|
return False
|
||||||
if not os.path.exists("../../hostapd/hlr_auc_gw"):
|
if not os.path.exists("../../hostapd/hlr_auc_gw"):
|
||||||
logger.info("No hlr_auc_gw available");
|
logger.info("No hlr_auc_gw available");
|
||||||
return "skip"
|
return False
|
||||||
bssid = apdev[0]['bssid']
|
return True
|
||||||
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")
|
def interworking_ext_sim_connect(dev, bssid, method):
|
||||||
dev[0].request("SET hs20 1")
|
dev.request("INTERWORKING_CONNECT " + bssid)
|
||||||
dev[0].request("SET external_sim 1")
|
|
||||||
|
|
||||||
id = dev[0].add_cred()
|
ev = dev.wait_event(["CTRL-EVENT-EAP-METHOD"], timeout=15)
|
||||||
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:
|
if ev is None:
|
||||||
raise Exception("Network connected timed out")
|
raise Exception("Network connected timed out")
|
||||||
if "(SIM)" not in ev:
|
if "(" + method + ")" not in ev:
|
||||||
raise Exception("Unexpected EAP method selection")
|
raise Exception("Unexpected EAP method selection")
|
||||||
|
|
||||||
ev = dev[0].wait_event(["CTRL-REQ-SIM"], timeout=15)
|
ev = dev.wait_event(["CTRL-REQ-SIM"], timeout=15)
|
||||||
if ev is None:
|
if ev is None:
|
||||||
raise Exception("Wait for external SIM processing request timed out")
|
raise Exception("Wait for external SIM processing request timed out")
|
||||||
p = ev.split(':', 2)
|
p = ev.split(':', 2)
|
||||||
|
@ -163,13 +104,46 @@ def test_ap_hs20_ext_sim(dev, apdev):
|
||||||
raise Exception("Unexpected hlr_auc_gw response")
|
raise Exception("Unexpected hlr_auc_gw response")
|
||||||
resp = res.split(' ')[2].rstrip()
|
resp = res.split(' ')[2].rstrip()
|
||||||
|
|
||||||
dev[0].request("CTRL-RSP-SIM-" + id + ":GSM-AUTH:" + resp)
|
dev.request("CTRL-RSP-SIM-" + id + ":GSM-AUTH:" + resp)
|
||||||
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
|
ev = dev.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
|
||||||
if ev is None:
|
if ev is None:
|
||||||
raise Exception("Connection timed out")
|
raise Exception("Connection timed out")
|
||||||
|
|
||||||
type = dev[0].get_status_field("sp_type")
|
def test_ap_hs20_select(dev, apdev):
|
||||||
if type is None:
|
"""Hotspot 2.0 network selection"""
|
||||||
raise Exception("sp_type not available")
|
bssid = apdev[0]['bssid']
|
||||||
if type != "home":
|
params = hs20_ap_params()
|
||||||
raise Exception("sp_type did not indicate home network")
|
params['hessid'] = bssid
|
||||||
|
hostapd.add_ap(apdev[0]['ifname'], params)
|
||||||
|
|
||||||
|
dev[0].hs20_enable()
|
||||||
|
id = dev[0].add_cred_values(realm="example.com", username="test",
|
||||||
|
password="secret", domain="example.com")
|
||||||
|
interworking_select(dev[0], bssid, "home")
|
||||||
|
|
||||||
|
dev[0].remove_cred(id)
|
||||||
|
id = dev[0].add_cred_values(realm="example.com", username="test",
|
||||||
|
password="secret",
|
||||||
|
domain="no.match.example.com")
|
||||||
|
interworking_select(dev[0], bssid, "roaming")
|
||||||
|
|
||||||
|
dev[0].set_cred_quoted(id, "realm", "no.match.example.com");
|
||||||
|
interworking_select(dev[0], bssid, no_match=True)
|
||||||
|
|
||||||
|
def test_ap_hs20_ext_sim(dev, apdev):
|
||||||
|
"""Hotspot 2.0 with external SIM processing"""
|
||||||
|
if not 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].hs20_enable()
|
||||||
|
dev[0].request("SET external_sim 1")
|
||||||
|
dev[0].add_cred_values(imsi="23201-0000000000", eap="SIM")
|
||||||
|
interworking_select(dev[0], "home")
|
||||||
|
interworking_ext_sim_connect(dev[0], bssid, "SIM")
|
||||||
|
check_sp_type(dev[0], "home")
|
||||||
|
|
|
@ -118,6 +118,10 @@ class WpaSupplicant:
|
||||||
raise Exception("SET_NETWORK failed")
|
raise Exception("SET_NETWORK failed")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def hs20_enable(self):
|
||||||
|
self.request("SET interworking 1")
|
||||||
|
self.request("SET hs20 1")
|
||||||
|
|
||||||
def add_cred(self):
|
def add_cred(self):
|
||||||
id = self.request("ADD_CRED")
|
id = self.request("ADD_CRED")
|
||||||
if "FAIL" in id:
|
if "FAIL" in id:
|
||||||
|
@ -142,6 +146,23 @@ class WpaSupplicant:
|
||||||
raise Exception("SET_CRED failed")
|
raise Exception("SET_CRED failed")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def add_cred_values(self, realm=None, username=None, password=None,
|
||||||
|
domain=None, imsi=None, eap=None):
|
||||||
|
id = self.add_cred()
|
||||||
|
if realm:
|
||||||
|
self.set_cred_quoted(id, "realm", realm)
|
||||||
|
if username:
|
||||||
|
self.set_cred_quoted(id, "username", username)
|
||||||
|
if password:
|
||||||
|
self.set_cred_quoted(id, "password", password)
|
||||||
|
if domain:
|
||||||
|
self.set_cred_quoted(id, "domain", domain)
|
||||||
|
if imsi:
|
||||||
|
self.set_cred_quoted(id, "imsi", imsi)
|
||||||
|
if eap:
|
||||||
|
self.set_cred(id, "eap", eap)
|
||||||
|
return id;
|
||||||
|
|
||||||
def select_network(self, id):
|
def select_network(self, id):
|
||||||
id = self.request("SELECT_NETWORK " + str(id))
|
id = self.request("SELECT_NETWORK " + str(id))
|
||||||
if "FAIL" in id:
|
if "FAIL" in id:
|
||||||
|
|
Loading…
Reference in a new issue