From ae750570b6f8d9d2b723eefd136896a2dbdfa0d2 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 24 Feb 2020 20:04:21 +0200 Subject: [PATCH] tests: WPS PBC session overlap detection with single BSSID selected Update grpform_pbc_overlap not to require PBC session overlap to be detected since in this sequence a single BSSID is specified and other APs can be ignored while checking for session overlap. Add other test cases to explicitly check for the PBC session overlap detection in non-P2P and P2P cases when the BSSID is specified. Signed-off-by: Jouni Malinen --- tests/hwsim/test_ap_wps.py | 33 ++++++++++++++++++++++++++++----- tests/hwsim/test_p2p_autogo.py | 23 +++++++++++++++++++++++ tests/hwsim/test_p2p_grpform.py | 22 +++++++++------------- 3 files changed, 60 insertions(+), 18 deletions(-) diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py index dc8635087..958341667 100644 --- a/tests/hwsim/test_ap_wps.py +++ b/tests/hwsim/test_ap_wps.py @@ -956,9 +956,7 @@ def test_ap_wps_setup_locked_2(dev, apdev): dev[0].request("WPS_CANCEL") dev[0].wait_disconnected() -@remote_compatible -def test_ap_wps_pbc_overlap_2ap(dev, apdev): - """WPS PBC session overlap with two active APs""" +def setup_ap_wps_pbc_overlap_2ap(apdev): params = {"ssid": "wps1", "eap_server": "1", "wps_state": "2", "wpa_passphrase": "12345678", "wpa": "2", "wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP", @@ -971,16 +969,41 @@ def test_ap_wps_pbc_overlap_2ap(dev, apdev): hapd2 = hostapd.add_ap(apdev[1], params) hapd.request("WPS_PBC") hapd2.request("WPS_PBC") + return hapd, hapd2 + +@remote_compatible +def test_ap_wps_pbc_overlap_2ap(dev, apdev): + """WPS PBC session overlap with two active APs""" + hapd, hapd2 = setup_ap_wps_pbc_overlap_2ap(apdev) logger.info("WPS provisioning step") dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412", force_scan=True) dev[0].scan_for_bss(apdev[1]['bssid'], freq="2412") dev[0].request("WPS_PBC") ev = dev[0].wait_event(["WPS-OVERLAP-DETECTED"], timeout=15) - if ev is None: - raise Exception("PBC session overlap not detected") hapd.request("DISABLE") hapd2.request("DISABLE") dev[0].flush_scan_cache() + if ev is None: + raise Exception("PBC session overlap not detected") + +@remote_compatible +def test_ap_wps_pbc_overlap_2ap_specific_bssid(dev, apdev): + """WPS PBC session overlap with two active APs (specific BSSID selected)""" + hapd, hapd2 = setup_ap_wps_pbc_overlap_2ap(apdev) + logger.info("WPS provisioning step") + dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412", force_scan=True) + dev[0].scan_for_bss(apdev[1]['bssid'], freq="2412") + dev[0].request("WPS_PBC " + apdev[0]['bssid']) + ev = dev[0].wait_event(["WPS-OVERLAP-DETECTED", + "CTRL-EVENT-CONNECTED"], timeout=15) + dev[0].request("DISCONNECT") + hapd.request("DISABLE") + hapd2.request("DISABLE") + dev[0].flush_scan_cache() + if ev is None: + raise Exception("PBC session overlap result not reported") + if "CTRL-EVENT-CONNECTED" not in ev: + raise Exception("Connection did not complete") @remote_compatible def test_ap_wps_pbc_overlap_2sta(dev, apdev): diff --git a/tests/hwsim/test_p2p_autogo.py b/tests/hwsim/test_p2p_autogo.py index e896323f1..f0e861e2f 100644 --- a/tests/hwsim/test_p2p_autogo.py +++ b/tests/hwsim/test_p2p_autogo.py @@ -10,6 +10,7 @@ import subprocess import logging logger = logging.getLogger() +import hostapd import hwsim_utils import utils from utils import HwsimSkip @@ -231,6 +232,28 @@ def test_autogo_pbc(dev): dev[1].p2p_connect_group(dev[0].p2p_dev_addr(), "pbc", timeout=15, social=True) +def test_autogo_pbc_session_overlap(dev, apdev): + """P2P autonomous GO and PBC session overlap""" + params = {"ssid": "wps", "eap_server": "1", "wps_state": "1"} + hapd = hostapd.add_ap(apdev[0], params) + hapd.request("WPS_PBC") + bssid = hapd.own_addr() + time.sleep(0.1) + + dev[0].scan_for_bss(bssid, freq=2412) + dev[1].scan_for_bss(bssid, freq=2412) + + dev[1].global_request("SET p2p_no_group_iface 0") + autogo(dev[0], freq=2412) + if "OK" not in dev[0].group_request("WPS_PBC p2p_dev_addr=" + dev[1].p2p_dev_addr()): + raise Exception("WPS_PBC failed") + dev[1].p2p_connect_group(dev[0].p2p_dev_addr(), "pbc", timeout=15, + social=True) + hapd.disable() + remove_group(dev[0], dev[1]) + dev[0].flush_scan_cache() + dev[1].flush_scan_cache() + def test_autogo_tdls(dev): """P2P autonomous GO and two clients using TDLS""" go = dev[0] diff --git a/tests/hwsim/test_p2p_grpform.py b/tests/hwsim/test_p2p_grpform.py index 47882cce2..88c7d7e93 100644 --- a/tests/hwsim/test_p2p_grpform.py +++ b/tests/hwsim/test_p2p_grpform.py @@ -638,6 +638,7 @@ def clear_pbc_overlap(dev, ap): dev[1].request("P2P_CANCEL") dev[0].p2p_stop_find() dev[1].p2p_stop_find() + remove_group(dev[0], dev[1], allow_failure=True) dev[0].dump_monitor() dev[1].dump_monitor() time.sleep(0.1) @@ -653,9 +654,9 @@ def test_grpform_pbc_overlap(dev, apdev): hapd.request("WPS_PBC") time.sleep(0.1) - # Since P2P Client scan case is now optimzied to use a specific SSID, the + # Since P2P Client scan case is now optimized to use a specific SSID, the # WPS AP will not reply to that and the scan after GO Negotiation can quite - # likely miss the AP due to dwell time being short enoguh to miss the Beacon + # likely miss the AP due to dwell time being short enough to miss the Beacon # frame. This has made the test case somewhat pointless, but keep it here # for now with an additional scan to confirm that PBC detection works if # there is a BSS entry for a overlapping AP. @@ -677,11 +678,11 @@ def test_grpform_pbc_overlap(dev, apdev): raise Exception("Failed to authorize GO Neg") if "OK" not in dev[1].global_request("P2P_CONNECT " + addr0 + " pbc go_intent=15 freq=2412"): raise Exception("Failed to initiate GO Neg") - ev = dev[0].wait_global_event(["WPS-OVERLAP-DETECTED"], timeout=15) - if ev is None: - raise Exception("PBC overlap not reported") - + ev = dev[0].wait_global_event(["WPS-OVERLAP-DETECTED", + "P2P-GROUP-FORMATION-SUCCESS"], timeout=15) clear_pbc_overlap(dev, apdev[0]) + if ev is None or "P2P-GROUP-FORMATION-SUCCESS" not in ev: + raise Exception("P2P group formation did not complete") @remote_compatible def test_grpform_pbc_overlap_group_iface(dev, apdev): @@ -713,14 +714,9 @@ def test_grpform_pbc_overlap_group_iface(dev, apdev): raise Exception("Failed to initiate GO Neg") ev = dev[0].wait_global_event(["WPS-OVERLAP-DETECTED", "P2P-GROUP-FORMATION-SUCCESS"], timeout=15) - if ev is None or "WPS-OVERLAP-DETECTED" not in ev: - # Do not report this as failure since the P2P group formation case - # using a separate group interface has limited chances of "seeing" the - # overlapping AP due to a per-SSID scan and no prior scan operations on - # the group interface. - logger.info("PBC overlap not reported") - clear_pbc_overlap(dev, apdev[0]) + if ev is None or "P2P-GROUP-FORMATION-SUCCESS" not in ev: + raise Exception("P2P group formation did not complete") @remote_compatible def test_grpform_goneg_fail_with_group_iface(dev):