tests: cfg80211 P2P Device misuses
Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
44b9ea5bb2
commit
5de945fcc0
1 changed files with 59 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
# cfg80211 P2P Device
|
||||
# Copyright (c) 2013, Jouni Malinen <j@w1.fi>
|
||||
# Copyright (c) 2013-2015, Jouni Malinen <j@w1.fi>
|
||||
#
|
||||
# This software may be distributed under the terms of the BSD license.
|
||||
# See README for more details.
|
||||
|
@ -14,6 +14,7 @@ from test_p2p_grpform import check_grpform_results
|
|||
from test_p2p_grpform import remove_group
|
||||
from test_nfc_p2p import set_ip_addr_info, check_ip_addr, grpform_events
|
||||
from hwsim import HWSimRadio
|
||||
import hostapd
|
||||
import hwsim_utils
|
||||
|
||||
def test_p2p_device_grpform(dev, apdev):
|
||||
|
@ -116,3 +117,60 @@ def test_p2p_device_nfc_invite(dev, apdev):
|
|||
res = wpas.group_form_result(ev)
|
||||
hwsim_utils.test_connectivity_p2p(dev[0], wpas)
|
||||
check_ip_addr(res)
|
||||
|
||||
def test_p2p_device_misuses(dev, apdev):
|
||||
"""cfg80211 P2P Device misuses"""
|
||||
hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
|
||||
with HWSimRadio(use_p2p_device=True) as (radio, iface):
|
||||
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
|
||||
wpas.interface_add(iface)
|
||||
|
||||
# Add a normal network profile to the P2P Device management only
|
||||
# interface to verify that it does not get used.
|
||||
id = int(wpas.global_request('IFNAME=p2p-dev-%s ADD_NETWORK' % iface).strip())
|
||||
wpas.global_request('IFNAME=p2p-dev-%s SET_NETWORK %d ssid "open"' % (iface, id))
|
||||
wpas.global_request('IFNAME=p2p-dev-%s SET_NETWORK %d key_mgmt NONE' % (iface, id))
|
||||
wpas.global_request('IFNAME=p2p-dev-%s ENABLE_NETWORK %d' % (iface, id))
|
||||
|
||||
# Scan requests get ignored on p2p-dev
|
||||
wpas.global_request('IFNAME=p2p-dev-%s SCAN' % iface)
|
||||
|
||||
dev[0].p2p_start_go(freq=2412)
|
||||
addr = dev[0].p2p_interface_addr()
|
||||
wpas.scan_for_bss(addr, freq=2412)
|
||||
wpas.connect("open", key_mgmt="NONE", scan_freq="2412")
|
||||
hwsim_utils.test_connectivity(wpas, hapd)
|
||||
|
||||
pin = wpas.wps_read_pin()
|
||||
dev[0].p2p_go_authorize_client(pin)
|
||||
res = wpas.p2p_connect_group(dev[0].p2p_dev_addr(), pin, timeout=60,
|
||||
social=True, freq=2412)
|
||||
hwsim_utils.test_connectivity_p2p(dev[0], wpas)
|
||||
|
||||
# Optimize scan-after-disconnect
|
||||
wpas.group_request("SET_NETWORK 0 scan_freq 2412")
|
||||
|
||||
dev[0].request("DISASSOCIATE " + wpas.p2p_interface_addr())
|
||||
ev = wpas.wait_group_event(["CTRL-EVENT-DISCONNECT"])
|
||||
if ev is None:
|
||||
raise Exception("Did not see disconnect event on P2P group interface")
|
||||
dev[0].remove_group()
|
||||
|
||||
ev = wpas.wait_group_event(["CTRL-EVENT-SCAN-STARTED"], timeout=5)
|
||||
if ev is None:
|
||||
raise Exception("Scan not started")
|
||||
ev = wpas.wait_group_event(["CTRL-EVENT-SCAN-RESULTS"], timeout=15)
|
||||
if ev is None:
|
||||
raise Exception("Scan not completed")
|
||||
time.sleep(1)
|
||||
hwsim_utils.test_connectivity(wpas, hapd)
|
||||
|
||||
ev = hapd.wait_event([ "AP-STA-DISCONNECTED" ], timeout=0.1)
|
||||
if ev is not None:
|
||||
raise Exception("Unexpected disconnection event received from hostapd")
|
||||
ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.1)
|
||||
if ev is not None:
|
||||
raise Exception("Unexpected disconnection event received from wpa_supplicant")
|
||||
|
||||
wpas.request("DISCONNECT")
|
||||
wpas.wait_disconnected()
|
||||
|
|
Loading…
Reference in a new issue