]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: NAI Home Realm Query
authorJouni Malinen <j@w1.fi>
Fri, 31 Jan 2014 21:00:07 +0000 (23:00 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 4 Feb 2014 11:10:57 +0000 (13:10 +0200)
Signed-hostap: Jouni Malinen <j@w1.fi>

tests/hwsim/test_ap_hs20.py

index ac63d17f8e489883112eaf31bbef4b52f6da99da..3983030c6d62b0455468b543cc8f5ae469e50906 100644 (file)
@@ -177,6 +177,39 @@ def test_ap_anqp_sharing(dev, apdev):
     if res1['anqp_nai_realm'] == res2['anqp_nai_realm']:
         raise Exception("ANQP results were not unshared")
 
+def test_ap_nai_home_realm_query(dev, apdev):
+    """NAI Home Realm Query"""
+    bssid = apdev[0]['bssid']
+    params = hs20_ap_params()
+    params['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]",
+                            "0,another.example.org" ]
+    hostapd.add_ap(apdev[0]['ifname'], params)
+
+    dev[0].scan(freq="2412")
+    dev[0].request("HS20_GET_NAI_HOME_REALM_LIST " + bssid + " realm=example.com")
+    ev = dev[0].wait_event(["RX-ANQP"], timeout=5)
+    if ev is None:
+        raise Exception("ANQP operation timed out")
+    nai1 = dev[0].get_bss(bssid)['anqp_nai_realm']
+    dev[0].dump_monitor()
+
+    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")
+    nai2 = dev[0].get_bss(bssid)['anqp_nai_realm']
+
+    if len(nai1) >= len(nai2):
+        raise Exception("Unexpected NAI Realm list response lengths")
+    if "example.com".encode('hex') not in nai1:
+        raise Exception("Home realm not reported")
+    if "example.org".encode('hex') in nai1:
+        raise Exception("Non-home realm reported")
+    if "example.com".encode('hex') not in nai2:
+        raise Exception("Home realm not reported in wildcard query")
+    if "example.org".encode('hex') not in nai2:
+        raise Exception("Non-home realm not reported in wildcard query ")
+
 def test_ap_interworking_scan_filtering(dev, apdev):
     """Interworking scan filtering with HESSID and access network type"""
     bssid = apdev[0]['bssid']