X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=tests%2Fhwsim%2Ftest_wep.py;h=bd8fec067586f3692a2329cff87b8873d012bac8;hb=5b3c40a65bf14b00746f061570f9376fee38fbf3;hp=7b70484ac47011622d3eb08441c565d12b4a088e;hpb=da102662243a88173104956477e1d08996b43a5a;p=thirdparty%2Fhostap.git diff --git a/tests/hwsim/test_wep.py b/tests/hwsim/test_wep.py index 7b70484ac..bd8fec067 100644 --- a/tests/hwsim/test_wep.py +++ b/tests/hwsim/test_wep.py @@ -1,5 +1,3 @@ -#!/usr/bin/python -# # WEP tests # Copyright (c) 2014, Jouni Malinen # @@ -11,23 +9,32 @@ import hwsim_utils def test_wep_open_auth(dev, apdev): """WEP Open System authentication""" - hostapd.add_ap(apdev[0]['ifname'], - { "ssid": "wep-open", - "wep_key0": '"hello"' }) + hapd = hostapd.add_ap(apdev[0]['ifname'], + { "ssid": "wep-open", + "wep_key0": '"hello"' }) + dev[0].flush_scan_cache() dev[0].connect("wep-open", key_mgmt="NONE", wep_key0='"hello"', scan_freq="2412") - hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) + hwsim_utils.test_connectivity(dev[0], hapd) + 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""" - hostapd.add_ap(apdev[0]['ifname'], - { "ssid": "wep-shared-key", - "wep_key0": '"hello12345678"', - "auth_algs": "2" }) + hapd = hostapd.add_ap(apdev[0]['ifname'], + { "ssid": "wep-shared-key", + "wep_key0": '"hello12345678"', + "auth_algs": "2" }) dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED", wep_key0='"hello12345678"', scan_freq="2412") - hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname']) + hwsim_utils.test_connectivity(dev[0], hapd) dev[1].connect("wep-shared-key", key_mgmt="NONE", auth_alg="OPEN SHARED", wep_key0='"hello12345678"', scan_freq="2412") @@ -44,3 +51,32 @@ def test_wep_shared_key_auth_not_allowed(dev, apdev): ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1) if ev is not None: raise Exception("Unexpected association") + +def test_wep_shared_key_auth_multi_key(dev, apdev): + """WEP Shared Key authentication with multiple keys""" + hapd = hostapd.add_ap(apdev[0]['ifname'], + { "ssid": "wep-shared-key", + "wep_key0": '"hello12345678"', + "wep_key1": '"other12345678"', + "auth_algs": "2" }) + dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED", + wep_key0='"hello12345678"', + scan_freq="2412") + dev[1].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED", + wep_key0='"hello12345678"', + wep_key1='"other12345678"', + wep_tx_keyidx="1", + scan_freq="2412") + id = dev[2].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED", + wep_key0='"hello12345678"', + wep_key1='"other12345678"', + wep_tx_keyidx="0", + scan_freq="2412") + hwsim_utils.test_connectivity(dev[0], hapd) + hwsim_utils.test_connectivity(dev[1], hapd) + hwsim_utils.test_connectivity(dev[2], hapd) + + dev[2].set_network(id, "wep_tx_keyidx", "1") + dev[2].request("REASSOCIATE") + dev[2].wait_connected(timeout=10, error="Reassociation timed out") + hwsim_utils.test_connectivity(dev[2], hapd)