From d463c5566fdd0be5e0346ac478895ac27c8760ad Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 7 Dec 2014 23:27:45 +0200 Subject: [PATCH] tests: Additional coverage for SCAN_RESULTS and BSS entry flags This increases wpa_supplicant_ie_txt(), print_bss_info(), and wpa_supplicant_ctrl_iface_scan_result() testing coverage to include the previously missing key management options. Signed-off-by: Jouni Malinen --- tests/hwsim/test_ap_eap.py | 6 ++++++ tests/hwsim/test_ap_hs20.py | 4 ++++ tests/hwsim/test_ibss.py | 25 +++++++++++++++++++++++++ tests/hwsim/test_p2p_autogo.py | 4 ++++ tests/hwsim/test_sae.py | 5 +++++ tests/hwsim/test_suite_b.py | 7 +++++++ tests/hwsim/test_wep.py | 6 ++++++ 7 files changed, 57 insertions(+) diff --git a/tests/hwsim/test_ap_eap.py b/tests/hwsim/test_ap_eap.py index f5a7e6bac..aca575155 100644 --- a/tests/hwsim/test_ap_eap.py +++ b/tests/hwsim/test_ap_eap.py @@ -1695,6 +1695,12 @@ def test_ap_wpa2_eap_psk(dev, apdev): check_mib(dev[0], [ ("dot11RSNAAuthenticationSuiteRequested", "00-0f-ac-5"), ("dot11RSNAAuthenticationSuiteSelected", "00-0f-ac-5") ]) + bss = dev[0].get_bss(apdev[0]['bssid']) + if 'flags' not in bss: + raise Exception("Could not get BSS flags from BSS table") + if "[WPA2-EAP-SHA256-CCMP]" not in bss['flags']: + raise Exception("Unexpected BSS flags: " + bss['flags']) + logger.info("Negative test with incorrect password") dev[0].request("REMOVE_NETWORK all") eap_connect(dev[0], apdev[0], "PSK", "psk.user@example.com", diff --git a/tests/hwsim/test_ap_hs20.py b/tests/hwsim/test_ap_hs20.py index fdb267d1f..0ee7c53e7 100644 --- a/tests/hwsim/test_ap_hs20.py +++ b/tests/hwsim/test_ap_hs20.py @@ -345,6 +345,10 @@ def test_ap_hs20_select(dev, apdev): dev[0].set_cred_quoted(id, "realm", "no.match.example.com"); interworking_select(dev[0], bssid, no_match=True, freq="2412") + res = dev[0].request("SCAN_RESULTS") + if "[HS20]" not in res: + raise Exception("HS20 flag missing from scan results: " + res) + bssid2 = apdev[1]['bssid'] params = hs20_ap_params() params['nai_realm'] = [ "0,example.org,21" ] diff --git a/tests/hwsim/test_ibss.py b/tests/hwsim/test_ibss.py index fd5c32dae..a05e2d723 100644 --- a/tests/hwsim/test_ibss.py +++ b/tests/hwsim/test_ibss.py @@ -169,6 +169,16 @@ def test_ibss_wpa_none(dev): print bssid1 print bssid2 + bss = dev[0].get_bss(bssid0) + if not bss: + bss = dev[1].get_bss(bssid1) + if not bss: + raise Exception("Could not find BSS entry for IBSS") + if 'flags' not in bss: + raise Exception("Could not get BSS flags from BSS table") + if "[WPA-None-TKIP]" not in bss['flags']: + raise Exception("Unexpected BSS flags: " + bss['flags']) + # Allow some time for all peers to complete key setup time.sleep(1) @@ -240,6 +250,21 @@ def test_ibss_open(dev): if bssid0 != bssid1: logger.info("STA0 BSSID " + bssid0 + " differs from STA1 BSSID " + bssid1) + res = dev[0].request("SCAN_RESULTS") + if "[IBSS]" not in res: + res = dev[1].request("SCAN_RESULTS") + if "[IBSS]" not in res: + raise Exception("IBSS flag missing from scan results: " + res) + bss = dev[0].get_bss(bssid0) + if not bss: + bss = dev[1].get_bss(bssid1) + if not bss: + raise Exception("Could not find BSS entry for IBSS") + if 'flags' not in bss: + raise Exception("Could not get BSS flags from BSS table") + if "[IBSS]" not in bss['flags']: + raise Exception("Unexpected BSS flags: " + bss['flags']) + def test_ibss_open_fixed_bssid(dev): """IBSS open (no security) and fixed BSSID""" ssid="ibss" diff --git a/tests/hwsim/test_p2p_autogo.py b/tests/hwsim/test_p2p_autogo.py index 4aa1932d2..79abd4c50 100644 --- a/tests/hwsim/test_p2p_autogo.py +++ b/tests/hwsim/test_p2p_autogo.py @@ -49,6 +49,10 @@ def test_autogo(dev): if "id=" + id not in res: raise Exception("Could not find BSS entry based on id range") + res = dev[1].request("SCAN_RESULTS") + if "[P2P]" not in res: + raise Exception("P2P flag missing from scan results: " + res) + # Presence request to increase testing coverage if "FAIL" in dev[1].group_request("P2P_PRESENCE_REQ 30000 102400"): raise Exception("Could not send presence request") diff --git a/tests/hwsim/test_sae.py b/tests/hwsim/test_sae.py index f870dd60e..c57bb0643 100644 --- a/tests/hwsim/test_sae.py +++ b/tests/hwsim/test_sae.py @@ -27,6 +27,11 @@ def test_sae(dev, apdev): scan_freq="2412") if dev[0].get_status_field('sae_group') != '19': raise Exception("Expected default SAE group not used") + bss = dev[0].get_bss(apdev[0]['bssid']) + if 'flags' not in bss: + raise Exception("Could not get BSS flags from BSS table") + if "[WPA2-SAE-CCMP]" not in bss['flags']: + raise Exception("Unexpected BSS flags: " + bss['flags']) def test_sae_pmksa_caching(dev, apdev): """SAE and PMKSA caching""" diff --git a/tests/hwsim/test_suite_b.py b/tests/hwsim/test_suite_b.py index dec9eb7b1..f37861409 100644 --- a/tests/hwsim/test_suite_b.py +++ b/tests/hwsim/test_suite_b.py @@ -24,6 +24,13 @@ def test_suite_b(dev, apdev): client_cert="auth_serv/user.pem", private_key="auth_serv/user.key", pairwise="GCMP", group="GCMP", scan_freq="2412") + + bss = dev[0].get_bss(apdev[0]['bssid']) + if 'flags' not in bss: + raise Exception("Could not get BSS flags from BSS table") + if "[WPA2-EAP-SUITE-B-GCMP]" not in bss['flags']: + raise Exception("Unexpected BSS flags: " + bss['flags']) + dev[0].request("DISCONNECT") ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=20) if ev is None: diff --git a/tests/hwsim/test_wep.py b/tests/hwsim/test_wep.py index 7f3a9417e..7237aaf4f 100644 --- a/tests/hwsim/test_wep.py +++ b/tests/hwsim/test_wep.py @@ -18,6 +18,12 @@ def test_wep_open_auth(dev, apdev): if "[WEP]" not in dev[0].request("SCAN_RESULTS"): raise Exception("WEP flag not indicated in scan results") + bss = dev[0].get_bss(apdev[0]['bssid']) + if 'flags' not in bss: + raise Exception("Could not get BSS flags from BSS table") + if "[WEP]" not in bss['flags']: + raise Exception("Unexpected BSS flags: " + bss['flags']) + def test_wep_shared_key_auth(dev, apdev): """WEP Shared Key authentication""" hapd = hostapd.add_ap(apdev[0]['ifname'],