tests: Pass AP devices to test cases
This removes hardcoded assumptions about AP interfaces from test_*.py. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
302b7a1b09
commit
ae3ad3284a
5 changed files with 177 additions and 168 deletions
|
@ -16,12 +16,12 @@ import logging
|
|||
from wpasupplicant import WpaSupplicant
|
||||
from hostapd import HostapdGlobal
|
||||
|
||||
def reset_devs(dev, hapd_ifaces):
|
||||
def reset_devs(dev, apdev):
|
||||
for d in dev:
|
||||
d.reset()
|
||||
hapd = HostapdGlobal()
|
||||
for h in hapd_ifaces:
|
||||
hapd.remove(h)
|
||||
for ap in apdev:
|
||||
hapd.remove(ap['ifname'])
|
||||
|
||||
def main():
|
||||
idx = 1
|
||||
|
@ -42,7 +42,9 @@ def main():
|
|||
dev0 = WpaSupplicant('wlan0')
|
||||
dev1 = WpaSupplicant('wlan1')
|
||||
dev = [ dev0, dev1 ]
|
||||
hapd_ifaces = [ 'wlan2', 'wlan3' ]
|
||||
apdev = [ ]
|
||||
apdev.append({"ifname": 'wlan2', "bssid": "02:00:00:00:02:00"})
|
||||
apdev.append({"ifname": 'wlan3', "bssid": "02:00:00:00:03:00"})
|
||||
|
||||
for d in dev:
|
||||
if not d.ping():
|
||||
|
@ -50,6 +52,8 @@ def main():
|
|||
return
|
||||
d.reset()
|
||||
print "DEV: " + d.ifname + ": " + d.p2p_dev_addr()
|
||||
for ap in apdev:
|
||||
print "APDEV: " + ap['ifname']
|
||||
|
||||
tests = []
|
||||
for t in os.listdir("."):
|
||||
|
@ -69,13 +73,16 @@ def main():
|
|||
if test_filter:
|
||||
if test_filter != t.__name__:
|
||||
continue
|
||||
reset_devs(dev, hapd_ifaces)
|
||||
reset_devs(dev, apdev)
|
||||
print "START " + t.__name__
|
||||
if t.__doc__:
|
||||
print "Test: " + t.__doc__
|
||||
for d in dev:
|
||||
d.request("NOTE TEST-START " + t.__name__)
|
||||
try:
|
||||
if t.func_code.co_argcount > 1:
|
||||
t(dev, apdev)
|
||||
else:
|
||||
t(dev)
|
||||
passed.append(t.__name__)
|
||||
print "PASS " + t.__name__
|
||||
|
@ -87,7 +94,7 @@ def main():
|
|||
d.request("NOTE TEST-STOP " + t.__name__)
|
||||
|
||||
if not test_filter:
|
||||
reset_devs(dev, hapd_ifaces)
|
||||
reset_devs(dev, apdev)
|
||||
|
||||
print "passed tests: " + str(passed)
|
||||
print "failed tests: " + str(failed)
|
||||
|
|
|
@ -15,10 +15,7 @@ import hwsim_utils
|
|||
import hostapd
|
||||
from wlantest import Wlantest
|
||||
|
||||
ap_ifname = 'wlan2'
|
||||
bssid = "02:00:00:00:02:00"
|
||||
|
||||
def test_ap_pmf_required(dev):
|
||||
def test_ap_pmf_required(dev, apdev):
|
||||
"""WPA2-PSK AP with PMF required"""
|
||||
ssid = "test-pmf-required"
|
||||
wt = Wlantest()
|
||||
|
@ -27,26 +24,28 @@ def test_ap_pmf_required(dev):
|
|||
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
|
||||
params["wpa_key_mgmt"] = "WPA-PSK-SHA256";
|
||||
params["ieee80211w"] = "2";
|
||||
hostapd.add_ap(ap_ifname, params)
|
||||
dev[0].connect(ssid, psk="12345678", ieee80211w="1", key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2")
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, ap_ifname)
|
||||
dev[1].connect(ssid, psk="12345678", ieee80211w="2", key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2")
|
||||
hwsim_utils.test_connectivity(dev[1].ifname, ap_ifname)
|
||||
hapd = hostapd.Hostapd(ap_ifname)
|
||||
hostapd.add_ap(apdev[0]['ifname'], params)
|
||||
dev[0].connect(ssid, psk="12345678", ieee80211w="1",
|
||||
key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2")
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
|
||||
dev[1].connect(ssid, psk="12345678", ieee80211w="2",
|
||||
key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2")
|
||||
hwsim_utils.test_connectivity(dev[1].ifname, apdev[0]['ifname'])
|
||||
hapd = hostapd.Hostapd(apdev[0]['ifname'])
|
||||
hapd.request("SA_QUERY " + dev[0].p2p_interface_addr())
|
||||
hapd.request("SA_QUERY " + dev[1].p2p_interface_addr())
|
||||
wt.require_ap_pmf_mandatory(bssid)
|
||||
wt.require_sta_pmf(bssid, dev[0].p2p_interface_addr())
|
||||
wt.require_sta_pmf_mandatory(bssid, dev[1].p2p_interface_addr())
|
||||
wt.require_ap_pmf_mandatory(apdev[0]['bssid'])
|
||||
wt.require_sta_pmf(apdev[0]['bssid'], dev[0].p2p_interface_addr())
|
||||
wt.require_sta_pmf_mandatory(apdev[0]['bssid'], dev[1].p2p_interface_addr())
|
||||
time.sleep(0.1)
|
||||
if wt.get_sta_counter("valid_saqueryresp_tx", bssid,
|
||||
if wt.get_sta_counter("valid_saqueryresp_tx", apdev[0]['bssid'],
|
||||
dev[0].p2p_interface_addr()) < 1:
|
||||
raise Exception("STA did not reply to SA Query")
|
||||
if wt.get_sta_counter("valid_saqueryresp_tx", bssid,
|
||||
if wt.get_sta_counter("valid_saqueryresp_tx", apdev[0]['bssid'],
|
||||
dev[1].p2p_interface_addr()) < 1:
|
||||
raise Exception("STA did not reply to SA Query")
|
||||
|
||||
def test_ap_pmf_optional(dev):
|
||||
def test_ap_pmf_optional(dev, apdev):
|
||||
"""WPA2-PSK AP with PMF optional"""
|
||||
ssid = "test-pmf-optional"
|
||||
wt = Wlantest()
|
||||
|
@ -55,16 +54,18 @@ def test_ap_pmf_optional(dev):
|
|||
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
|
||||
params["wpa_key_mgmt"] = "WPA-PSK";
|
||||
params["ieee80211w"] = "1";
|
||||
hostapd.add_ap(ap_ifname, params)
|
||||
dev[0].connect(ssid, psk="12345678", ieee80211w="1", key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2")
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, ap_ifname)
|
||||
dev[1].connect(ssid, psk="12345678", ieee80211w="2", key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2")
|
||||
hwsim_utils.test_connectivity(dev[1].ifname, ap_ifname)
|
||||
wt.require_ap_pmf_optional(bssid)
|
||||
wt.require_sta_pmf(bssid, dev[0].p2p_interface_addr())
|
||||
wt.require_sta_pmf_mandatory(bssid, dev[1].p2p_interface_addr())
|
||||
hostapd.add_ap(apdev[0]['ifname'], params)
|
||||
dev[0].connect(ssid, psk="12345678", ieee80211w="1",
|
||||
key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2")
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
|
||||
dev[1].connect(ssid, psk="12345678", ieee80211w="2",
|
||||
key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2")
|
||||
hwsim_utils.test_connectivity(dev[1].ifname, apdev[0]['ifname'])
|
||||
wt.require_ap_pmf_optional(apdev[0]['bssid'])
|
||||
wt.require_sta_pmf(apdev[0]['bssid'], dev[0].p2p_interface_addr())
|
||||
wt.require_sta_pmf_mandatory(apdev[0]['bssid'], dev[1].p2p_interface_addr())
|
||||
|
||||
def test_ap_pmf_optional_2akm(dev):
|
||||
def test_ap_pmf_optional_2akm(dev, apdev):
|
||||
"""WPA2-PSK AP with PMF optional (2 AKMs)"""
|
||||
ssid = "test-pmf-optional-2akm"
|
||||
wt = Wlantest()
|
||||
|
@ -73,31 +74,37 @@ def test_ap_pmf_optional_2akm(dev):
|
|||
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
|
||||
params["wpa_key_mgmt"] = "WPA-PSK WPA-PSK-SHA256";
|
||||
params["ieee80211w"] = "1";
|
||||
hostapd.add_ap(ap_ifname, params)
|
||||
dev[0].connect(ssid, psk="12345678", ieee80211w="1", key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2")
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, ap_ifname)
|
||||
dev[1].connect(ssid, psk="12345678", ieee80211w="2", key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2")
|
||||
hwsim_utils.test_connectivity(dev[1].ifname, ap_ifname)
|
||||
wt.require_ap_pmf_optional(bssid)
|
||||
wt.require_sta_pmf(bssid, dev[0].p2p_interface_addr())
|
||||
wt.require_sta_key_mgmt(bssid, dev[0].p2p_interface_addr(), "PSK-SHA256")
|
||||
wt.require_sta_pmf_mandatory(bssid, dev[1].p2p_interface_addr())
|
||||
wt.require_sta_key_mgmt(bssid, dev[1].p2p_interface_addr(), "PSK-SHA256")
|
||||
hostapd.add_ap(apdev[0]['ifname'], params)
|
||||
dev[0].connect(ssid, psk="12345678", ieee80211w="1",
|
||||
key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2")
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
|
||||
dev[1].connect(ssid, psk="12345678", ieee80211w="2",
|
||||
key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2")
|
||||
hwsim_utils.test_connectivity(dev[1].ifname, apdev[0]['ifname'])
|
||||
wt.require_ap_pmf_optional(apdev[0]['bssid'])
|
||||
wt.require_sta_pmf(apdev[0]['bssid'], dev[0].p2p_interface_addr())
|
||||
wt.require_sta_key_mgmt(apdev[0]['bssid'], dev[0].p2p_interface_addr(),
|
||||
"PSK-SHA256")
|
||||
wt.require_sta_pmf_mandatory(apdev[0]['bssid'], dev[1].p2p_interface_addr())
|
||||
wt.require_sta_key_mgmt(apdev[0]['bssid'], dev[1].p2p_interface_addr(),
|
||||
"PSK-SHA256")
|
||||
|
||||
def test_ap_pmf_negative(dev):
|
||||
def test_ap_pmf_negative(dev, apdev):
|
||||
"""WPA2-PSK AP without PMF (negative test)"""
|
||||
ssid = "test-pmf-negative"
|
||||
wt = Wlantest()
|
||||
wt.flush()
|
||||
wt.add_passphrase("12345678")
|
||||
params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
|
||||
hostapd.add_ap(ap_ifname, params)
|
||||
dev[0].connect(ssid, psk="12345678", ieee80211w="1", key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2")
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, ap_ifname)
|
||||
hostapd.add_ap(apdev[0]['ifname'], params)
|
||||
dev[0].connect(ssid, psk="12345678", ieee80211w="1",
|
||||
key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2")
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
|
||||
try:
|
||||
dev[1].connect(ssid, psk="12345678", ieee80211w="2", key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2")
|
||||
hwsim_utils.test_connectivity(dev[1].ifname, ap_ifname)
|
||||
dev[1].connect(ssid, psk="12345678", ieee80211w="2",
|
||||
key_mgmt="WPA-PSK WPA-PSK-SHA256", proto="WPA2")
|
||||
hwsim_utils.test_connectivity(dev[1].ifname, apdev[0]['ifname'])
|
||||
raise Exception("PMF required STA connected to no PMF AP")
|
||||
except Exception, e:
|
||||
logger.debug("Ignore expected exception: " + str(e))
|
||||
wt.require_ap_no_pmf(bssid)
|
||||
wt.require_ap_no_pmf(apdev[0]['bssid'])
|
||||
|
|
|
@ -14,32 +14,27 @@ logger = logging.getLogger(__name__)
|
|||
import hwsim_utils
|
||||
import hostapd
|
||||
|
||||
ap_ifname = 'wlan2'
|
||||
bssid = "02:00:00:00:02:00"
|
||||
ap2_ifname = 'wlan3'
|
||||
bssid2 = "02:00:00:00:03:00"
|
||||
|
||||
def test_ap_roam_open(dev):
|
||||
def test_ap_roam_open(dev, apdev):
|
||||
"""Roam between two open APs"""
|
||||
hostapd.add_ap(ap_ifname, { "ssid": "test-open" })
|
||||
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
|
||||
dev[0].connect("test-open", key_mgmt="NONE")
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, ap_ifname)
|
||||
hostapd.add_ap(ap2_ifname, { "ssid": "test-open" })
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
|
||||
hostapd.add_ap(apdev[1]['ifname'], { "ssid": "test-open" })
|
||||
dev[0].scan(type="ONLY")
|
||||
dev[0].roam(bssid2)
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, ap2_ifname)
|
||||
dev[0].roam(bssid)
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, ap_ifname)
|
||||
dev[0].roam(apdev[1]['bssid'])
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, apdev[1]['ifname'])
|
||||
dev[0].roam(apdev[0]['bssid'])
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
|
||||
|
||||
def test_ap_roam_wpa2_psk(dev):
|
||||
def test_ap_roam_wpa2_psk(dev, apdev):
|
||||
"""Roam between two WPA2-PSK APs"""
|
||||
params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678")
|
||||
hostapd.add_ap(ap_ifname, params)
|
||||
hostapd.add_ap(apdev[0]['ifname'], params)
|
||||
dev[0].connect("test-wpa2-psk", psk="12345678")
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, ap_ifname)
|
||||
hostapd.add_ap(ap2_ifname, params)
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
|
||||
hostapd.add_ap(apdev[1]['ifname'], params)
|
||||
dev[0].scan(type="ONLY")
|
||||
dev[0].roam(bssid2)
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, ap2_ifname)
|
||||
dev[0].roam(bssid)
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, ap_ifname)
|
||||
dev[0].roam(apdev[1]['bssid'])
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, apdev[1]['ifname'])
|
||||
dev[0].roam(apdev[0]['bssid'])
|
||||
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
|
||||
|
|
|
@ -16,8 +16,6 @@ from hostapd import Hostapd
|
|||
import hostapd
|
||||
from wlantest import Wlantest
|
||||
|
||||
ap_ifname = 'wlan2'
|
||||
|
||||
def start_ap_wpa2_psk(ifname):
|
||||
params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678")
|
||||
hostapd.add_ap(ifname, params)
|
||||
|
@ -27,28 +25,28 @@ def connectivity(dev, ap_ifname):
|
|||
hwsim_utils.test_connectivity(dev[0].ifname, ap_ifname)
|
||||
hwsim_utils.test_connectivity(dev[1].ifname, ap_ifname)
|
||||
|
||||
def connect_2sta(dev, ssid):
|
||||
def connect_2sta(dev, ssid, ap_ifname):
|
||||
dev[0].connect(ssid, psk="12345678")
|
||||
dev[1].connect(ssid, psk="12345678")
|
||||
connectivity(dev, ap_ifname)
|
||||
|
||||
def connect_2sta_wpa2_psk(dev):
|
||||
connect_2sta(dev, "test-wpa2-psk")
|
||||
def connect_2sta_wpa2_psk(dev, ap_ifname):
|
||||
connect_2sta(dev, "test-wpa2-psk", ap_ifname)
|
||||
|
||||
def connect_2sta_wpa_psk(dev):
|
||||
connect_2sta(dev, "test-wpa-psk")
|
||||
def connect_2sta_wpa_psk(dev, ap_ifname):
|
||||
connect_2sta(dev, "test-wpa-psk", ap_ifname)
|
||||
|
||||
def connect_2sta_wpa_psk_mixed(dev):
|
||||
def connect_2sta_wpa_psk_mixed(dev, ap_ifname):
|
||||
dev[0].connect("test-wpa-mixed-psk", psk="12345678", proto="WPA")
|
||||
dev[1].connect("test-wpa-mixed-psk", psk="12345678", proto="WPA2")
|
||||
connectivity(dev, ap_ifname)
|
||||
|
||||
def connect_2sta_wep(dev):
|
||||
def connect_2sta_wep(dev, ap_ifname):
|
||||
dev[0].connect("test-wep", key_mgmt="NONE", wep_key0='"hello"')
|
||||
dev[1].connect("test-wep", key_mgmt="NONE", wep_key0='"hello"')
|
||||
connectivity(dev, ap_ifname)
|
||||
|
||||
def connect_2sta_open(dev):
|
||||
def connect_2sta_open(dev, ap_ifname):
|
||||
dev[0].connect("test-open", key_mgmt="NONE")
|
||||
dev[1].connect("test-open", key_mgmt="NONE")
|
||||
connectivity(dev, ap_ifname)
|
||||
|
@ -127,129 +125,134 @@ def teardown_tdls(sta0, sta1, bssid):
|
|||
raise Exception("No TDLS Setup Teardown seen")
|
||||
tdls_check_ap(sta0, sta1, bssid, addr0, addr1)
|
||||
|
||||
def test_ap_wpa2_tdls(dev):
|
||||
def test_ap_wpa2_tdls(dev, apdev):
|
||||
"""WPA2-PSK AP and two stations using TDLS"""
|
||||
start_ap_wpa2_psk(ap_ifname)
|
||||
bssid = "02:00:00:00:02:00"
|
||||
start_ap_wpa2_psk(apdev[0]['ifname'])
|
||||
bssid = apdev[0]['bssid']
|
||||
wlantest_setup()
|
||||
connect_2sta_wpa2_psk(dev)
|
||||
connect_2sta_wpa2_psk(dev, apdev[0]['ifname'])
|
||||
setup_tdls(dev[0], dev[1], bssid)
|
||||
teardown_tdls(dev[0], dev[1], bssid)
|
||||
setup_tdls(dev[1], dev[0], bssid)
|
||||
#teardown_tdls(dev[0], dev[1], bssid)
|
||||
|
||||
def test_ap_wpa2_tdls_concurrent_init(dev):
|
||||
def test_ap_wpa2_tdls_concurrent_init(dev, apdev):
|
||||
"""Concurrent TDLS setup initiation"""
|
||||
start_ap_wpa2_psk(ap_ifname)
|
||||
bssid = "02:00:00:00:02:00"
|
||||
start_ap_wpa2_psk(apdev[0]['ifname'])
|
||||
bssid = apdev[0]['bssid']
|
||||
wlantest_setup()
|
||||
connect_2sta_wpa2_psk(dev)
|
||||
connect_2sta_wpa2_psk(dev, apdev[0]['ifname'])
|
||||
dev[0].request("SET tdls_testing 0x80")
|
||||
setup_tdls(dev[1], dev[0], bssid, reverse=True)
|
||||
|
||||
def test_ap_wpa2_tdls_concurrent_init2(dev):
|
||||
def test_ap_wpa2_tdls_concurrent_init2(dev, apdev):
|
||||
"""Concurrent TDLS setup initiation (reverse)"""
|
||||
start_ap_wpa2_psk(ap_ifname)
|
||||
bssid = "02:00:00:00:02:00"
|
||||
start_ap_wpa2_psk(apdev[0]['ifname'])
|
||||
bssid = apdev[0]['bssid']
|
||||
wlantest_setup()
|
||||
connect_2sta_wpa2_psk(dev)
|
||||
connect_2sta_wpa2_psk(dev, apdev[0]['ifname'])
|
||||
dev[1].request("SET tdls_testing 0x80")
|
||||
setup_tdls(dev[0], dev[1], bssid)
|
||||
|
||||
def test_ap_wpa2_tdls_decline_resp(dev):
|
||||
def test_ap_wpa2_tdls_decline_resp(dev, apdev):
|
||||
"""Decline TDLS Setup Response"""
|
||||
start_ap_wpa2_psk(ap_ifname)
|
||||
bssid = "02:00:00:00:02:00"
|
||||
start_ap_wpa2_psk(apdev[0]['ifname'])
|
||||
bssid = apdev[0]['bssid']
|
||||
wlantest_setup()
|
||||
connect_2sta_wpa2_psk(dev)
|
||||
connect_2sta_wpa2_psk(dev, apdev[0]['ifname'])
|
||||
dev[1].request("SET tdls_testing 0x200")
|
||||
setup_tdls(dev[1], dev[0], bssid, expect_fail=True)
|
||||
|
||||
def test_ap_wpa2_tdls_long_lifetime(dev):
|
||||
def test_ap_wpa2_tdls_long_lifetime(dev, apdev):
|
||||
"""TDLS with long TPK lifetime"""
|
||||
start_ap_wpa2_psk(ap_ifname)
|
||||
bssid = "02:00:00:00:02:00"
|
||||
start_ap_wpa2_psk(apdev[0]['ifname'])
|
||||
bssid = apdev[0]['bssid']
|
||||
wlantest_setup()
|
||||
connect_2sta_wpa2_psk(dev)
|
||||
connect_2sta_wpa2_psk(dev, apdev[0]['ifname'])
|
||||
dev[1].request("SET tdls_testing 0x40")
|
||||
setup_tdls(dev[1], dev[0], bssid)
|
||||
|
||||
def test_ap_wpa2_tdls_long_frame(dev):
|
||||
def test_ap_wpa2_tdls_long_frame(dev, apdev):
|
||||
"""TDLS with long setup/teardown frames"""
|
||||
start_ap_wpa2_psk(ap_ifname)
|
||||
bssid = "02:00:00:00:02:00"
|
||||
start_ap_wpa2_psk(apdev[0]['ifname'])
|
||||
bssid = apdev[0]['bssid']
|
||||
wlantest_setup()
|
||||
connect_2sta_wpa2_psk(dev)
|
||||
connect_2sta_wpa2_psk(dev, apdev[0]['ifname'])
|
||||
dev[0].request("SET tdls_testing 0x1")
|
||||
dev[1].request("SET tdls_testing 0x1")
|
||||
setup_tdls(dev[1], dev[0], bssid)
|
||||
teardown_tdls(dev[1], dev[0], bssid)
|
||||
setup_tdls(dev[0], dev[1], bssid)
|
||||
|
||||
def test_ap_wpa2_tdls_reneg(dev):
|
||||
def test_ap_wpa2_tdls_reneg(dev, apdev):
|
||||
"""Renegotiate TDLS link"""
|
||||
start_ap_wpa2_psk(ap_ifname)
|
||||
bssid = "02:00:00:00:02:00"
|
||||
start_ap_wpa2_psk(apdev[0]['ifname'])
|
||||
bssid = apdev[0]['bssid']
|
||||
wlantest_setup()
|
||||
connect_2sta_wpa2_psk(dev)
|
||||
connect_2sta_wpa2_psk(dev, apdev[0]['ifname'])
|
||||
setup_tdls(dev[1], dev[0], bssid)
|
||||
setup_tdls(dev[0], dev[1], bssid)
|
||||
|
||||
def test_ap_wpa2_tdls_wrong_lifetime_resp(dev):
|
||||
def test_ap_wpa2_tdls_wrong_lifetime_resp(dev, apdev):
|
||||
"""Incorrect TPK lifetime in TDLS Setup Response"""
|
||||
start_ap_wpa2_psk(ap_ifname)
|
||||
bssid = "02:00:00:00:02:00"
|
||||
start_ap_wpa2_psk(apdev[0]['ifname'])
|
||||
bssid = apdev[0]['bssid']
|
||||
wlantest_setup()
|
||||
connect_2sta_wpa2_psk(dev)
|
||||
connect_2sta_wpa2_psk(dev, apdev[0]['ifname'])
|
||||
dev[1].request("SET tdls_testing 0x10")
|
||||
setup_tdls(dev[0], dev[1], bssid, expect_fail=True)
|
||||
|
||||
def test_ap_wpa2_tdls_diff_rsnie(dev):
|
||||
def test_ap_wpa2_tdls_diff_rsnie(dev, apdev):
|
||||
"""TDLS with different RSN IEs"""
|
||||
start_ap_wpa2_psk(ap_ifname)
|
||||
bssid = "02:00:00:00:02:00"
|
||||
start_ap_wpa2_psk(apdev[0]['ifname'])
|
||||
bssid = apdev[0]['bssid']
|
||||
wlantest_setup()
|
||||
connect_2sta_wpa2_psk(dev)
|
||||
connect_2sta_wpa2_psk(dev, apdev[0]['ifname'])
|
||||
dev[1].request("SET tdls_testing 0x2")
|
||||
setup_tdls(dev[1], dev[0], bssid)
|
||||
teardown_tdls(dev[1], dev[0], bssid)
|
||||
|
||||
def test_ap_wpa_tdls(dev):
|
||||
def test_ap_wpa_tdls(dev, apdev):
|
||||
"""WPA-PSK AP and two stations using TDLS"""
|
||||
hostapd.add_ap(ap_ifname, hostapd.wpa_params(ssid="test-wpa-psk", passphrase="12345678"))
|
||||
bssid = "02:00:00:00:02:00"
|
||||
hostapd.add_ap(apdev[0]['ifname'],
|
||||
hostapd.wpa_params(ssid="test-wpa-psk",
|
||||
passphrase="12345678"))
|
||||
bssid = apdev[0]['bssid']
|
||||
wlantest_setup()
|
||||
connect_2sta_wpa_psk(dev)
|
||||
connect_2sta_wpa_psk(dev, apdev[0]['ifname'])
|
||||
setup_tdls(dev[0], dev[1], bssid)
|
||||
teardown_tdls(dev[0], dev[1], bssid)
|
||||
setup_tdls(dev[1], dev[0], bssid)
|
||||
|
||||
def test_ap_wpa_mixed_tdls(dev):
|
||||
def test_ap_wpa_mixed_tdls(dev, apdev):
|
||||
"""WPA+WPA2-PSK AP and two stations using TDLS"""
|
||||
hostapd.add_ap(ap_ifname, hostapd.wpa_mixed_params(ssid="test-wpa-mixed-psk", passphrase="12345678"))
|
||||
bssid = "02:00:00:00:02:00"
|
||||
hostapd.add_ap(apdev[0]['ifname'],
|
||||
hostapd.wpa_mixed_params(ssid="test-wpa-mixed-psk",
|
||||
passphrase="12345678"))
|
||||
bssid = apdev[0]['bssid']
|
||||
wlantest_setup()
|
||||
connect_2sta_wpa_psk_mixed(dev)
|
||||
connect_2sta_wpa_psk_mixed(dev, apdev[0]['ifname'])
|
||||
setup_tdls(dev[0], dev[1], bssid)
|
||||
teardown_tdls(dev[0], dev[1], bssid)
|
||||
setup_tdls(dev[1], dev[0], bssid)
|
||||
|
||||
def test_ap_wep_tdls(dev):
|
||||
def test_ap_wep_tdls(dev, apdev):
|
||||
"""WEP AP and two stations using TDLS"""
|
||||
hostapd.add_ap(ap_ifname, { "ssid": "test-wep", "wep_key0": '"hello"' })
|
||||
bssid = "02:00:00:00:02:00"
|
||||
hostapd.add_ap(apdev[0]['ifname'],
|
||||
{ "ssid": "test-wep", "wep_key0": '"hello"' })
|
||||
bssid = apdev[0]['bssid']
|
||||
wlantest_setup()
|
||||
connect_2sta_wep(dev)
|
||||
connect_2sta_wep(dev, apdev[0]['ifname'])
|
||||
setup_tdls(dev[0], dev[1], bssid)
|
||||
teardown_tdls(dev[0], dev[1], bssid)
|
||||
setup_tdls(dev[1], dev[0], bssid)
|
||||
|
||||
def test_ap_open_tdls(dev):
|
||||
def test_ap_open_tdls(dev, apdev):
|
||||
"""Open AP and two stations using TDLS"""
|
||||
hostapd.add_ap(ap_ifname, { "ssid": "test-open" })
|
||||
bssid = "02:00:00:00:02:00"
|
||||
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
|
||||
bssid = apdev[0]['bssid']
|
||||
wlantest_setup()
|
||||
connect_2sta_open(dev)
|
||||
connect_2sta_open(dev, apdev[0]['ifname'])
|
||||
setup_tdls(dev[0], dev[1], bssid)
|
||||
teardown_tdls(dev[0], dev[1], bssid)
|
||||
setup_tdls(dev[1], dev[0], bssid)
|
||||
|
|
|
@ -14,17 +14,12 @@ logger = logging.getLogger(__name__)
|
|||
import hwsim_utils
|
||||
import hostapd
|
||||
|
||||
ap_ifname = 'wlan2'
|
||||
bssid = "02:00:00:00:02:00"
|
||||
ap2_ifname = 'wlan3'
|
||||
bssid2 = "02:00:00:00:03:00"
|
||||
|
||||
def test_ap_wps_init(dev):
|
||||
def test_ap_wps_init(dev, apdev):
|
||||
"""Initial AP configuration with first WPS Enrollee"""
|
||||
ssid = "test-wps"
|
||||
hostapd.add_ap(ap_ifname,
|
||||
hostapd.add_ap(apdev[0]['ifname'],
|
||||
{ "ssid": ssid, "eap_server": "1", "wps_state": "1" })
|
||||
hapd = hostapd.Hostapd(ap_ifname)
|
||||
hapd = hostapd.Hostapd(apdev[0]['ifname'])
|
||||
logger.info("WPS provisioning step")
|
||||
hapd.request("WPS_PBC")
|
||||
dev[0].dump_monitor()
|
||||
|
@ -33,7 +28,7 @@ def test_ap_wps_init(dev):
|
|||
if ev is None:
|
||||
raise Exception("Association with the AP timed out")
|
||||
status = dev[0].get_status()
|
||||
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != bssid:
|
||||
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
|
||||
raise Exception("Not fully connected")
|
||||
if status['ssid'] != ssid:
|
||||
raise Exception("Unexpected SSID")
|
||||
|
@ -42,14 +37,14 @@ def test_ap_wps_init(dev):
|
|||
if status['key_mgmt'] != 'WPA2-PSK':
|
||||
raise Exception("Unexpected key_mgmt")
|
||||
|
||||
def test_ap_wps_conf(dev):
|
||||
def test_ap_wps_conf(dev, apdev):
|
||||
"""WPS PBC provisioning with configured AP"""
|
||||
ssid = "test-wps-conf"
|
||||
hostapd.add_ap(ap_ifname,
|
||||
hostapd.add_ap(apdev[0]['ifname'],
|
||||
{ "ssid": ssid, "eap_server": "1", "wps_state": "2",
|
||||
"wpa_passphrase": "12345678", "wpa": "2",
|
||||
"wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"})
|
||||
hapd = hostapd.Hostapd(ap_ifname)
|
||||
hapd = hostapd.Hostapd(apdev[0]['ifname'])
|
||||
logger.info("WPS provisioning step")
|
||||
hapd.request("WPS_PBC")
|
||||
dev[0].dump_monitor()
|
||||
|
@ -58,8 +53,10 @@ def test_ap_wps_conf(dev):
|
|||
if ev is None:
|
||||
raise Exception("Association with the AP timed out")
|
||||
status = dev[0].get_status()
|
||||
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != bssid:
|
||||
if status['wpa_state'] != 'COMPLETED':
|
||||
raise Exception("Not fully connected")
|
||||
if status['bssid'] != apdev[0]['bssid']:
|
||||
raise Exception("Unexpected BSSID")
|
||||
if status['ssid'] != ssid:
|
||||
raise Exception("Unexpected SSID")
|
||||
if status['pairwise_cipher'] != 'CCMP' or status['group_cipher'] != 'CCMP':
|
||||
|
@ -67,14 +64,14 @@ def test_ap_wps_conf(dev):
|
|||
if status['key_mgmt'] != 'WPA2-PSK':
|
||||
raise Exception("Unexpected key_mgmt")
|
||||
|
||||
def test_ap_wps_conf_pin(dev):
|
||||
def test_ap_wps_conf_pin(dev, apdev):
|
||||
"""WPS PIN provisioning with configured AP"""
|
||||
ssid = "test-wps-conf-pin"
|
||||
hostapd.add_ap(ap_ifname,
|
||||
hostapd.add_ap(apdev[0]['ifname'],
|
||||
{ "ssid": ssid, "eap_server": "1", "wps_state": "2",
|
||||
"wpa_passphrase": "12345678", "wpa": "2",
|
||||
"wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"})
|
||||
hapd = hostapd.Hostapd(ap_ifname)
|
||||
hapd = hostapd.Hostapd(apdev[0]['ifname'])
|
||||
logger.info("WPS provisioning step")
|
||||
pin = dev[0].wps_read_pin()
|
||||
hapd.request("WPS_PIN any " + pin)
|
||||
|
@ -84,7 +81,7 @@ def test_ap_wps_conf_pin(dev):
|
|||
if ev is None:
|
||||
raise Exception("Association with the AP timed out")
|
||||
status = dev[0].get_status()
|
||||
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != bssid:
|
||||
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
|
||||
raise Exception("Not fully connected")
|
||||
if status['ssid'] != ssid:
|
||||
raise Exception("Unexpected SSID")
|
||||
|
@ -93,11 +90,11 @@ def test_ap_wps_conf_pin(dev):
|
|||
if status['key_mgmt'] != 'WPA2-PSK':
|
||||
raise Exception("Unexpected key_mgmt")
|
||||
|
||||
def test_ap_wps_reg_connect(dev):
|
||||
def test_ap_wps_reg_connect(dev, apdev):
|
||||
"""WPS registrar using AP PIN to connect"""
|
||||
ssid = "test-wps-conf-ap-pin"
|
||||
appin = "12345670"
|
||||
hostapd.add_ap(ap_ifname,
|
||||
hostapd.add_ap(apdev[0]['ifname'],
|
||||
{ "ssid": ssid, "eap_server": "1", "wps_state": "2",
|
||||
"wpa_passphrase": "12345678", "wpa": "2",
|
||||
"wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
|
||||
|
@ -105,12 +102,12 @@ def test_ap_wps_reg_connect(dev):
|
|||
logger.info("WPS provisioning step")
|
||||
dev[0].request("BSS_FLUSH")
|
||||
dev[0].dump_monitor()
|
||||
dev[0].request("WPS_REG " + bssid + " " + appin)
|
||||
dev[0].request("WPS_REG " + apdev[0]['bssid'] + " " + appin)
|
||||
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
|
||||
if ev is None:
|
||||
raise Exception("Association with the AP timed out")
|
||||
status = dev[0].get_status()
|
||||
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != bssid:
|
||||
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
|
||||
raise Exception("Not fully connected")
|
||||
if status['ssid'] != ssid:
|
||||
raise Exception("Unexpected SSID")
|
||||
|
@ -119,11 +116,11 @@ def test_ap_wps_reg_connect(dev):
|
|||
if status['key_mgmt'] != 'WPA2-PSK':
|
||||
raise Exception("Unexpected key_mgmt")
|
||||
|
||||
def test_ap_wps_reg_config(dev):
|
||||
def test_ap_wps_reg_config(dev, apdev):
|
||||
"""WPS registrar configuring and AP using AP PIN"""
|
||||
ssid = "test-wps-init-ap-pin"
|
||||
appin = "12345670"
|
||||
hostapd.add_ap(ap_ifname,
|
||||
hostapd.add_ap(apdev[0]['ifname'],
|
||||
{ "ssid": ssid, "eap_server": "1", "wps_state": "2",
|
||||
"ap_pin": appin})
|
||||
logger.info("WPS configuration step")
|
||||
|
@ -131,12 +128,12 @@ def test_ap_wps_reg_config(dev):
|
|||
dev[0].dump_monitor()
|
||||
new_ssid = "wps-new-ssid"
|
||||
new_passphrase = "1234567890"
|
||||
dev[0].request("WPS_REG " + bssid + " " + appin + " " + new_ssid.encode("hex") + " WPA2PSK CCMP " + new_passphrase.encode("hex"))
|
||||
dev[0].request("WPS_REG " + apdev[0]['bssid'] + " " + appin + " " + new_ssid.encode("hex") + " WPA2PSK CCMP " + new_passphrase.encode("hex"))
|
||||
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
|
||||
if ev is None:
|
||||
raise Exception("Association with the AP timed out")
|
||||
status = dev[0].get_status()
|
||||
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != bssid:
|
||||
if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
|
||||
raise Exception("Not fully connected")
|
||||
if status['ssid'] != new_ssid:
|
||||
raise Exception("Unexpected SSID")
|
||||
|
@ -145,21 +142,21 @@ def test_ap_wps_reg_config(dev):
|
|||
if status['key_mgmt'] != 'WPA2-PSK':
|
||||
raise Exception("Unexpected key_mgmt")
|
||||
|
||||
def test_ap_wps_pbc_overlap_2ap(dev):
|
||||
def test_ap_wps_pbc_overlap_2ap(dev, apdev):
|
||||
"""WPS PBC session overlap with two active APs"""
|
||||
hostapd.add_ap(ap_ifname,
|
||||
hostapd.add_ap(apdev[0]['ifname'],
|
||||
{ "ssid": "wps1", "eap_server": "1", "wps_state": "2",
|
||||
"wpa_passphrase": "12345678", "wpa": "2",
|
||||
"wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
|
||||
"wps_independent": "1"})
|
||||
hostapd.add_ap(ap2_ifname,
|
||||
hostapd.add_ap(apdev[1]['ifname'],
|
||||
{ "ssid": "wps2", "eap_server": "1", "wps_state": "2",
|
||||
"wpa_passphrase": "123456789", "wpa": "2",
|
||||
"wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP",
|
||||
"wps_independent": "1"})
|
||||
hapd = hostapd.Hostapd(ap_ifname)
|
||||
hapd = hostapd.Hostapd(apdev[0]['ifname'])
|
||||
hapd.request("WPS_PBC")
|
||||
hapd2 = hostapd.Hostapd(ap2_ifname)
|
||||
hapd2 = hostapd.Hostapd(apdev[1]['ifname'])
|
||||
hapd2.request("WPS_PBC")
|
||||
logger.info("WPS provisioning step")
|
||||
dev[0].dump_monitor()
|
||||
|
@ -168,14 +165,14 @@ def test_ap_wps_pbc_overlap_2ap(dev):
|
|||
if ev is None:
|
||||
raise Exception("PBC session overlap not detected")
|
||||
|
||||
def test_ap_wps_pbc_overlap_2sta(dev):
|
||||
def test_ap_wps_pbc_overlap_2sta(dev, apdev):
|
||||
"""WPS PBC session overlap with two active STAs"""
|
||||
ssid = "test-wps-pbc-overlap"
|
||||
hostapd.add_ap(ap_ifname,
|
||||
hostapd.add_ap(apdev[0]['ifname'],
|
||||
{ "ssid": ssid, "eap_server": "1", "wps_state": "2",
|
||||
"wpa_passphrase": "12345678", "wpa": "2",
|
||||
"wpa_key_mgmt": "WPA-PSK", "rsn_pairwise": "CCMP"})
|
||||
hapd = hostapd.Hostapd(ap_ifname)
|
||||
hapd = hostapd.Hostapd(apdev[0]['ifname'])
|
||||
logger.info("WPS provisioning step")
|
||||
hapd.request("WPS_PBC")
|
||||
dev[0].request("BSS_FLUSH")
|
||||
|
|
Loading…
Reference in a new issue