]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Verify sharing and unsharing of ANQP results
authorJouni Malinen <j@w1.fi>
Wed, 25 Dec 2013 18:49:02 +0000 (20:49 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 26 Dec 2013 14:55:44 +0000 (16:55 +0200)
Signed-hostap: Jouni Malinen <j@w1.fi>

tests/hwsim/test_ap_hs20.py
tests/hwsim/wpasupplicant.py

index 4a17b65cc834dec2eb3c50227117b4747fd164d5..b7ac1002436b0c0d72a9079f95175ed1ac6fb85d 100644 (file)
@@ -58,7 +58,7 @@ def interworking_select(dev, bssid, type=None, no_match=False):
         return
     if "INTERWORKING-NO-MATCH" in ev:
         raise Exception("Matching network not found")
-    if bssid not in ev:
+    if bssid and bssid not in ev:
         raise Exception("Unexpected BSSID in match")
     if type and "type=" + type not in ev:
         raise Exception("Network type not recognized correctly")
@@ -134,6 +134,49 @@ def check_probe_resp(wt, bssid_unexpected, bssid_expected):
         if count == 0:
             raise Exception("No Probe Response frame from AP")
 
+def test_ap_anqp_sharing(dev, apdev):
+    """ANQP sharing within ESS and explicit unshare"""
+    bssid = apdev[0]['bssid']
+    params = hs20_ap_params()
+    params['hessid'] = bssid
+    hostapd.add_ap(apdev[0]['ifname'], params)
+
+    bssid2 = apdev[1]['bssid']
+    params = hs20_ap_params()
+    params['hessid'] = bssid
+    params['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]" ]
+    hostapd.add_ap(apdev[1]['ifname'], params)
+
+    dev[0].request("SET ignore_old_scan_res 1")
+    dev[0].hs20_enable()
+    id = dev[0].add_cred_values({ 'realm': "example.com", 'username': "test",
+                                  'password': "secret",
+                                  'domain': "example.com" })
+    logger.info("Normal network selection with shared ANQP results")
+    interworking_select(dev[0], None, "home")
+    dev[0].dump_monitor()
+
+    res1 = dev[0].get_bss(bssid)
+    res2 = dev[0].get_bss(bssid2)
+    if res1['anqp_nai_realm'] != res2['anqp_nai_realm']:
+        raise Exception("ANQP results were not shared between BSSes")
+
+    logger.info("Explicit ANQP request to unshare ANQP results")
+    dev[0].request("ANQP_GET " + bssid + " 263")
+    ev = dev[0].wait_event(["RX-ANQP"], timeout=5)
+    if ev is None:
+        raise Exception("ANQP operation timed out")
+
+    dev[0].request("ANQP_GET " + bssid2 + " 263")
+    ev = dev[0].wait_event(["RX-ANQP"], timeout=5)
+    if ev is None:
+        raise Exception("ANQP operation timed out")
+
+    res1 = dev[0].get_bss(bssid)
+    res2 = dev[0].get_bss(bssid2)
+    if res1['anqp_nai_realm'] == res2['anqp_nai_realm']:
+        raise Exception("ANQP results were not unshared")
+
 def test_ap_interworking_scan_filtering(dev, apdev):
     """Interworking scan filtering with HESSID and access network type"""
     bssid = apdev[0]['bssid']
index 04ea5860246a0fa23984867de51cc4d2c1fff818..90dd698f24f089bb1b3f96b641e23c0d746f7da0 100644 (file)
@@ -639,3 +639,12 @@ class WpaSupplicant:
         if "FAIL" in res:
             return None
         return res.split(' ')
+
+    def get_bss(self, bssid):
+        res = self.request("BSS " + bssid)
+        lines = res.splitlines()
+        vals = dict()
+        for l in lines:
+            [name,value] = l.split('=', 1)
+            vals[name] = value
+        return vals