From d1ba402fe518ce96353e9aef461708b6750bee45 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 4 Nov 2013 13:11:31 +0200 Subject: [PATCH] tests: HS 2.0 required roaming consortium Signed-hostap: Jouni Malinen --- tests/hwsim/test_ap_hs20.py | 46 ++++++++++++++++++++++++++++++++++++ tests/hwsim/wpasupplicant.py | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index ec907b328..ea67fd141 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -247,3 +247,49 @@ def test_ap_hs20_username_unknown2(dev, apdev): interworking_select(dev[0], bssid, "unknown") interworking_connect(dev[0], bssid, "TTLS") check_sp_type(dev[0], "unknown") + +def policy_test(dev, ap, values, only_one=True): + dev.dump_monitor() + logger.info("Verify network selection to AP " + ap['ifname']) + bssid = ap['bssid'] + dev.hs20_enable() + id = dev.add_cred_values(values) + dev.request("INTERWORKING_SELECT auto") + while True: + ev = dev.wait_event(["INTERWORKING-AP", "INTERWORKING-NO-MATCH", + "CTRL-EVENT-CONNECTED"], timeout=15) + if ev is None: + raise Exception("Connection timed out") + if "INTERWORKING-NO-MATCH" in ev: + raise Exception("Matching AP not found") + if only_one and "INTERWORKING-AP" in ev and bssid not in ev: + raise Exception("Unexpected AP claimed acceptable") + if "CTRL-EVENT-CONNECTED" in ev: + if bssid not in ev: + raise Exception("Connected to incorrect BSS") + break + + conn_bssid = dev.get_status_field("bssid") + if conn_bssid != bssid: + raise Exception("bssid information points to incorrect BSS") + + dev.remove_cred(id) + dev.dump_monitor() + +def test_ap_hs20_req_roaming_consortium(dev, apdev): + """Hotspot 2.0 required roaming consortium""" + params = hs20_ap_params() + hostapd.add_ap(apdev[0]['ifname'], params) + + params = hs20_ap_params() + params['ssid'] = "test-hs20-other" + params['roaming_consortium'] = [ "223344" ] + hostapd.add_ap(apdev[1]['ifname'], params) + + values = { 'realm': "example.com", + 'username': "hs20-test", + 'password': "password", + 'required_roaming_consortium': "223344" } + policy_test(dev[0], apdev[1], values) + values['required_roaming_consortium'] = "112233" + policy_test(dev[0], apdev[0], values) diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index 0501d0257..fddc2f9a2 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -154,7 +154,7 @@ class WpaSupplicant: if field in params: self.set_cred_quoted(id, field, params[field]) - not_quoted = [ "eap" ] + not_quoted = [ "eap", "required_roaming_consortium" ] for field in not_quoted: if field in params: self.set_cred(id, field, params[field])