]> git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_ap_config.py
tests: hostapd configuration file error cases
[thirdparty/hostap.git] / tests / hwsim / test_ap_config.py
1 # hostapd configuration 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
9 def test_ap_config_errors(dev, apdev):
10 """Various hostapd configuration errors"""
11 hapd_global = hostapd.HostapdGlobal()
12 ifname = apdev[0]['ifname']
13
14 # IEEE 802.11d without country code
15 params = { "ssid": "foo", "ieee80211d": "1" }
16 hapd = hostapd.add_ap(ifname, params, no_enable=True)
17 if "FAIL" not in hapd.request("ENABLE"):
18 raise Exception("Unexpected ENABLE success (ieee80211d without country_code)")
19 hapd_global.remove(ifname)
20
21 # IEEE 802.11h without IEEE 802.11d
22 params = { "ssid": "foo", "ieee80211h": "1" }
23 hapd = hostapd.add_ap(ifname, params, no_enable=True)
24 if "FAIL" not in hapd.request("ENABLE"):
25 raise Exception("Unexpected ENABLE success (ieee80211h without ieee80211d")
26 hapd_global.remove(ifname)
27
28 # Power Constraint without IEEE 802.11d
29 params = { "ssid": "foo", "local_pwr_constraint": "1" }
30 hapd = hostapd.add_ap(ifname, params, no_enable=True)
31 if "FAIL" not in hapd.request("ENABLE"):
32 raise Exception("Unexpected ENABLE success (local_pwr_constraint without ieee80211d)")
33 hapd_global.remove(ifname)
34
35 # Spectrum management without Power Constraint
36 params = { "ssid": "foo", "spectrum_mgmt_required": "1" }
37 hapd = hostapd.add_ap(ifname, params, no_enable=True)
38 if "FAIL" not in hapd.request("ENABLE"):
39 raise Exception("Unexpected ENABLE success (spectrum_mgmt_required without local_pwr_constraint)")
40 hapd_global.remove(ifname)
41
42 # IEEE 802.1X without authentication server
43 params = { "ssid": "foo", "ieee8021x": "1" }
44 hapd = hostapd.add_ap(ifname, params, no_enable=True)
45 if "FAIL" not in hapd.request("ENABLE"):
46 raise Exception("Unexpected ENABLE success (ieee8021x)")
47 hapd_global.remove(ifname)
48
49 # RADIUS-PSK without macaddr_acl=2
50 params = hostapd.wpa2_params(ssid="foo", passphrase="12345678")
51 params["wpa_psk_radius"] = "1"
52 hapd = hostapd.add_ap(ifname, params, no_enable=True)
53 if "FAIL" not in hapd.request("ENABLE"):
54 raise Exception("Unexpected ENABLE success (wpa_psk_radius)")
55 hapd_global.remove(ifname)
56
57 # FT without NAS-Identifier
58 params = { "wpa": "2",
59 "wpa_key_mgmt": "FT-PSK",
60 "rsn_pairwise": "CCMP",
61 "wpa_passphrase": "12345678" }
62 hapd = hostapd.add_ap(ifname, params, no_enable=True)
63 if "FAIL" not in hapd.request("ENABLE"):
64 raise Exception("Unexpected ENABLE success (FT without nas_identifier)")
65 hapd_global.remove(ifname)
66
67 # Hotspot 2.0 without WPA2/CCMP
68 params = hostapd.wpa2_params(ssid="foo")
69 params['wpa_key_mgmt'] = "WPA-EAP"
70 params['ieee8021x'] = "1"
71 params['auth_server_addr'] = "127.0.0.1"
72 params['auth_server_port'] = "1812"
73 params['auth_server_shared_secret'] = "radius"
74 params['interworking'] = "1"
75 params['hs20'] = "1"
76 params['wpa'] = "1"
77 hapd = hostapd.add_ap(ifname, params, no_enable=True)
78 if "FAIL" not in hapd.request("ENABLE"):
79 raise Exception("Unexpected ENABLE success (HS 2.0 without WPA2/CCMP)")
80 hapd_global.remove(ifname)