Updated to hostap_2_6
[mech_eap.git] / libeap / 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 from remotehost import remote_compatible
8 import hostapd
9
10 @remote_compatible
11 def test_ap_config_errors(dev, apdev):
12     """Various hostapd configuration errors"""
13
14     # IEEE 802.11d without country code
15     params = { "ssid": "foo", "ieee80211d": "1" }
16     hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
17     if "FAIL" not in hapd.request("ENABLE"):
18         raise Exception("Unexpected ENABLE success (ieee80211d without country_code)")
19     hostapd.remove_bss(apdev[0])
20
21     # IEEE 802.11h without IEEE 802.11d
22     params = { "ssid": "foo", "ieee80211h": "1" }
23     hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
24     if "FAIL" not in hapd.request("ENABLE"):
25         raise Exception("Unexpected ENABLE success (ieee80211h without ieee80211d")
26     hostapd.remove_bss(apdev[0])
27
28     # Power Constraint without IEEE 802.11d
29     params = { "ssid": "foo", "local_pwr_constraint": "1" }
30     hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
31     if "FAIL" not in hapd.request("ENABLE"):
32         raise Exception("Unexpected ENABLE success (local_pwr_constraint without ieee80211d)")
33     hostapd.remove_bss(apdev[0])
34
35     # Spectrum management without Power Constraint
36     params = { "ssid": "foo", "spectrum_mgmt_required": "1" }
37     hapd = hostapd.add_ap(apdev[0], 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     hostapd.remove_bss(apdev[0])
41
42     # IEEE 802.1X without authentication server
43     params = { "ssid": "foo", "ieee8021x": "1" }
44     hapd = hostapd.add_ap(apdev[0], params, no_enable=True)
45     if "FAIL" not in hapd.request("ENABLE"):
46         raise Exception("Unexpected ENABLE success (ieee8021x)")
47     hostapd.remove_bss(apdev[0])
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(apdev[0], params, no_enable=True)
53     if "FAIL" not in hapd.request("ENABLE"):
54         raise Exception("Unexpected ENABLE success (wpa_psk_radius)")
55     hostapd.remove_bss(apdev[0])
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(apdev[0], params, no_enable=True)
63     if "FAIL" not in hapd.request("ENABLE"):
64         raise Exception("Unexpected ENABLE success (FT without nas_identifier)")
65     hostapd.remove_bss(apdev[0])
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(apdev[0], 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     hostapd.remove_bss(apdev[0])