8dbc9be7b5e3d613f33755e8690febe0f1cb84cf
[mech_eap.git] / tests / hwsim / test_wep.py
1 # WEP tests
2 # Copyright (c) 2014, Jouni Malinen <j@w1.fi>
3 #
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
6
7 import hostapd
8 import hwsim_utils
9
10 def test_wep_open_auth(dev, apdev):
11     """WEP Open System authentication"""
12     hostapd.add_ap(apdev[0]['ifname'],
13                    { "ssid": "wep-open",
14                      "wep_key0": '"hello"' })
15     dev[0].connect("wep-open", key_mgmt="NONE", wep_key0='"hello"',
16                    scan_freq="2412")
17     hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
18
19 def test_wep_shared_key_auth(dev, apdev):
20     """WEP Shared Key authentication"""
21     hostapd.add_ap(apdev[0]['ifname'],
22                    { "ssid": "wep-shared-key",
23                      "wep_key0": '"hello12345678"',
24                      "auth_algs": "2" })
25     dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
26                    wep_key0='"hello12345678"',
27                    scan_freq="2412")
28     hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
29     dev[1].connect("wep-shared-key", key_mgmt="NONE", auth_alg="OPEN SHARED",
30                    wep_key0='"hello12345678"',
31                    scan_freq="2412")
32
33 def test_wep_shared_key_auth_not_allowed(dev, apdev):
34     """WEP Shared Key authentication not allowed"""
35     hostapd.add_ap(apdev[0]['ifname'],
36                    { "ssid": "wep-shared-key",
37                      "wep_key0": '"hello12345678"',
38                      "auth_algs": "1" })
39     dev[0].connect("wep-shared-key", key_mgmt="NONE", auth_alg="SHARED",
40                    wep_key0='"hello12345678"',
41                    scan_freq="2412", wait_connect=False)
42     ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
43     if ev is not None:
44         raise Exception("Unexpected association")