From 6a0b400273a9561d45f3c216b980f2a38e2a48e7 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 6 Nov 2013 23:35:19 +0200 Subject: [PATCH] tests: Verify no-duplicate-networks with Interworking connection Signed-hostap: Jouni Malinen --- tests/hwsim/test_ap_hs20.py | 37 ++++++++++++++++++++++++++++++++++++ tests/hwsim/wpasupplicant.py | 16 ++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index 9a525d157..9e125f25b 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -248,6 +248,43 @@ def test_ap_hs20_username_unknown2(dev, apdev): interworking_connect(dev[0], bssid, "TTLS") check_sp_type(dev[0], "unknown") +def test_ap_hs20_multiple_connects(dev, apdev): + """Hotspot 2.0 connection through multiple network selections""" + bssid = apdev[0]['bssid'] + params = hs20_ap_params() + params['hessid'] = bssid + hostapd.add_ap(apdev[0]['ifname'], params) + + dev[0].hs20_enable() + values = { 'realm': "example.com", + 'username': "hs20-test", + 'password': "password", + 'domain': "example.com" } + id = dev[0].add_cred_values(values) + + for i in range(0, 3): + logger.info("Starting Interworking network selection") + dev[0].request("INTERWORKING_SELECT auto") + while True: + ev = dev[0].wait_event(["INTERWORKING-NO-MATCH", + "INTERWORKING-ALREADY-CONNECTED", + "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 "CTRL-EVENT-CONNECTED" in ev: + break + if i == 2 and "INTERWORKING-ALREADY-CONNECTED" in ev: + break + if i == 0: + dev[0].request("DISCONNECT") + dev[0].dump_monitor() + + networks = dev[0].list_networks() + if len(networks) > 1: + raise Exception("Duplicated network block detected") + def policy_test(dev, ap, values, only_one=True): dev.dump_monitor() logger.info("Verify network selection to AP " + ap['ifname']) diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index 40d3d33ae..32b7267ff 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -118,6 +118,22 @@ class WpaSupplicant: raise Exception("SET_NETWORK failed") return None + def list_networks(self): + res = self.request("LIST_NETWORKS") + lines = res.splitlines() + networks = [] + for l in lines: + if "network id" in l: + continue + [id,ssid,bssid,flags] = l.split('\t') + network = {} + network['id'] = id + network['ssid'] = ssid + network['bssid'] = bssid + network['flags'] = flags + networks.append(network) + return networks + def hs20_enable(self): self.request("SET interworking 1") self.request("SET hs20 1")