]>
git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_ap_config.py
1 # hostapd configuration tests
2 # Copyright (c) 2014-2016, Jouni Malinen <j@w1.fi>
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
11 logger
= logging
.getLogger(__name__
)
14 from remotehost
import remote_compatible
16 from utils
import alloc_fail
, fail_test
19 def test_ap_config_errors(dev
, apdev
):
20 """Various hostapd configuration errors"""
22 # IEEE 802.11d without country code
23 params
= {"ssid": "foo", "ieee80211d": "1"}
24 hapd
= hostapd
.add_ap(apdev
[0], params
, no_enable
=True)
25 if "FAIL" not in hapd
.request("ENABLE"):
26 raise Exception("Unexpected ENABLE success (ieee80211d without country_code)")
27 hostapd
.remove_bss(apdev
[0])
29 # IEEE 802.11h without IEEE 802.11d
30 params
= {"ssid": "foo", "ieee80211h": "1"}
31 hapd
= hostapd
.add_ap(apdev
[0], params
, no_enable
=True)
32 if "FAIL" not in hapd
.request("ENABLE"):
33 raise Exception("Unexpected ENABLE success (ieee80211h without ieee80211d")
34 hostapd
.remove_bss(apdev
[0])
36 # Power Constraint without IEEE 802.11d
37 params
= {"ssid": "foo", "local_pwr_constraint": "1"}
38 hapd
= hostapd
.add_ap(apdev
[0], params
, no_enable
=True)
39 if "FAIL" not in hapd
.request("ENABLE"):
40 raise Exception("Unexpected ENABLE success (local_pwr_constraint without ieee80211d)")
41 hostapd
.remove_bss(apdev
[0])
43 # Spectrum management without Power Constraint
44 params
= {"ssid": "foo", "spectrum_mgmt_required": "1"}
45 hapd
= hostapd
.add_ap(apdev
[0], params
, no_enable
=True)
46 if "FAIL" not in hapd
.request("ENABLE"):
47 raise Exception("Unexpected ENABLE success (spectrum_mgmt_required without local_pwr_constraint)")
48 hostapd
.remove_bss(apdev
[0])
50 # IEEE 802.1X without authentication server
51 params
= {"ssid": "foo", "ieee8021x": "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 (ieee8021x)")
55 hostapd
.remove_bss(apdev
[0])
57 # RADIUS-PSK without macaddr_acl=2
58 params
= hostapd
.wpa2_params(ssid
="foo", passphrase
="12345678")
59 params
["wpa_psk_radius"] = "1"
60 hapd
= hostapd
.add_ap(apdev
[0], params
, no_enable
=True)
61 if "FAIL" not in hapd
.request("ENABLE"):
62 raise Exception("Unexpected ENABLE success (wpa_psk_radius)")
63 hostapd
.remove_bss(apdev
[0])
65 # FT without NAS-Identifier
67 "wpa_key_mgmt": "FT-PSK",
68 "rsn_pairwise": "CCMP",
69 "wpa_passphrase": "12345678"}
70 hapd
= hostapd
.add_ap(apdev
[0], params
, no_enable
=True)
71 if "FAIL" not in hapd
.request("ENABLE"):
72 raise Exception("Unexpected ENABLE success (FT without nas_identifier)")
73 hostapd
.remove_bss(apdev
[0])
75 # Hotspot 2.0 without WPA2/CCMP
76 params
= hostapd
.wpa2_params(ssid
="foo")
77 params
['wpa_key_mgmt'] = "WPA-EAP"
78 params
['ieee8021x'] = "1"
79 params
['auth_server_addr'] = "127.0.0.1"
80 params
['auth_server_port'] = "1812"
81 params
['auth_server_shared_secret'] = "radius"
82 params
['interworking'] = "1"
85 hapd
= hostapd
.add_ap(apdev
[0], params
, no_enable
=True)
86 if "FAIL" not in hapd
.request("ENABLE"):
87 raise Exception("Unexpected ENABLE success (HS 2.0 without WPA2/CCMP)")
88 hostapd
.remove_bss(apdev
[0])
90 def test_ap_config_reload(dev
, apdev
, params
):
91 """hostapd configuration reload"""
92 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": "foo"})
93 hapd
.set("ssid", "foobar")
94 with
open(os
.path
.join(params
['logdir'], 'hostapd-test.pid'), "r") as f
:
96 os
.kill(pid
, signal
.SIGHUP
)
98 dev
[0].connect("foobar", key_mgmt
="NONE", scan_freq
="2412")
99 hapd
.set("ssid", "foo")
100 os
.kill(pid
, signal
.SIGHUP
)
101 dev
[0].wait_disconnected()
102 dev
[0].request("DISCONNECT")
104 def test_ap_config_reload_file(dev
, apdev
, params
):
105 """hostapd configuration reload from file"""
106 hapd
= hostapd
.add_iface(apdev
[0], "bss-1.conf")
108 hapd
.set("ssid", "foobar")
109 with
open(os
.path
.join(params
['logdir'], 'hostapd-test.pid'), "r") as f
:
111 os
.kill(pid
, signal
.SIGHUP
)
113 dev
[0].connect("foobar", key_mgmt
="NONE", scan_freq
="2412")
114 hapd
.set("ssid", "foo")
115 os
.kill(pid
, signal
.SIGHUP
)
116 dev
[0].wait_disconnected()
117 dev
[0].request("DISCONNECT")
119 def test_ap_config_reload_file_while_disabled(dev
, apdev
, params
):
120 """hostapd configuration reload from file when disabled"""
121 hapd
= hostapd
.add_iface(apdev
[0], "bss-1.conf")
123 ev
= hapd
.wait_event(["AP-ENABLED"], timeout
=3)
125 raise Exception("AP-ENABLED event not reported")
126 hapd
.set("ssid", "foobar")
127 with
open(os
.path
.join(params
['logdir'], 'hostapd-test.pid'), "r") as f
:
130 ev
= hapd
.wait_event(["AP-DISABLED"], timeout
=3)
132 raise Exception("AP-DISABLED event not reported")
134 os
.kill(pid
, signal
.SIGHUP
)
137 dev
[0].connect("foobar", key_mgmt
="NONE", scan_freq
="2412")
139 def write_hostapd_config(conffile
, ifname
, ssid
, ht
=True, bss2
=False):
140 with
open(conffile
, "w") as f
:
141 f
.write("driver=nl80211\n")
142 f
.write("hw_mode=g\n")
143 f
.write("channel=1\n")
145 f
.write("ieee80211n=1\n")
146 f
.write("interface=" + ifname
+ "\n")
147 f
.write("ssid=" + ssid
+ "\n")
149 f
.write("bss=" + ifname
+ "_2\n")
150 f
.write("ssid=" + ssid
+ "-2\n")
152 def test_ap_config_reload_on_sighup(dev
, apdev
, params
):
153 """hostapd configuration reload modification from file on SIGHUP"""
154 run_ap_config_reload_on_sighup(dev
, apdev
, params
)
156 def test_ap_config_reload_on_sighup_no_ht(dev
, apdev
, params
):
157 """hostapd configuration reload modification from file on SIGHUP (no HT)"""
158 run_ap_config_reload_on_sighup(dev
, apdev
, params
, ht
=False)
160 def run_ap_config_reload_on_sighup(dev
, apdev
, params
, ht
=True):
161 name
= "ap_config_reload_on_sighup"
164 pidfile
= os
.path
.join(params
['logdir'], name
+ "-hostapd.pid")
165 logfile
= os
.path
.join(params
['logdir'], name
+ "-hostapd-log")
166 conffile
= os
.path
.join(os
.getcwd(), params
['logdir'],
167 name
+ "-hostapd.conf")
168 prg
= os
.path
.join(params
['logdir'], 'alt-hostapd/hostapd/hostapd')
169 if not os
.path
.exists(prg
):
170 prg
= '../../hostapd/hostapd'
171 write_hostapd_config(conffile
, apdev
[0]['ifname'], "test-1", ht
=ht
)
172 cmd
= [prg
, '-B', '-dddt', '-P', pidfile
, '-f', logfile
, conffile
]
173 res
= subprocess
.check_call(cmd
)
175 raise Exception("Could not start hostapd: %s" % str(res
))
177 dev
[0].connect("test-1", key_mgmt
="NONE", scan_freq
="2412")
178 dev
[0].request("REMOVE_NETWORK all")
179 dev
[0].wait_disconnected()
181 write_hostapd_config(conffile
, apdev
[0]['ifname'], "test-2", ht
=ht
)
182 with
open(pidfile
, "r") as f
:
184 os
.kill(pid
, signal
.SIGHUP
)
187 dev
[0].flush_scan_cache()
189 dev
[0].connect("test-2", key_mgmt
="NONE", scan_freq
="2412")
190 bss
= dev
[0].get_bss(apdev
[0]['bssid'])
191 dev
[0].request("REMOVE_NETWORK all")
192 dev
[0].wait_disconnected()
194 os
.kill(pid
, signal
.SIGTERM
)
198 if not os
.path
.exists(pidfile
):
202 raise Exception("hostapd PID file not removed on SIGTERM")
204 if ht
and "dd180050f202" not in bss
['ie']:
205 raise Exception("Missing WMM IE after reload")
206 if not ht
and "dd180050f202" in bss
['ie']:
207 raise Exception("Unexpected WMM IE after reload")
209 def test_ap_config_reload_on_sighup_bss_changes(dev
, apdev
, params
):
210 """hostapd configuration reload modification from file on SIGHUP with bss remove/add"""
211 name
= "ap_config_reload_on_sighup_bss_changes"
212 pidfile
= os
.path
.join(params
['logdir'], name
+ "-hostapd.pid")
213 logfile
= os
.path
.join(params
['logdir'], name
+ "-hostapd-log")
214 conffile
= os
.path
.join(os
.getcwd(), params
['logdir'],
215 name
+ "-hostapd.conf")
216 prg
= os
.path
.join(params
['logdir'], 'alt-hostapd/hostapd/hostapd')
217 if not os
.path
.exists(prg
):
218 prg
= '../../hostapd/hostapd'
219 write_hostapd_config(conffile
, apdev
[0]['ifname'], "test", bss2
=True)
220 cmd
= [prg
, '-B', '-dddt', '-P', pidfile
, '-f', logfile
, conffile
]
221 res
= subprocess
.check_call(cmd
)
223 raise Exception("Could not start hostapd: %s" % str(res
))
225 dev
[0].connect("test", key_mgmt
="NONE", scan_freq
="2412",
227 dev
[1].connect("test-2", key_mgmt
="NONE", scan_freq
="2412")
228 dev
[0].wait_connected()
229 dev
[0].request("REMOVE_NETWORK all")
230 dev
[1].request("REMOVE_NETWORK all")
231 dev
[0].wait_disconnected()
232 dev
[1].wait_disconnected()
233 dev
[0].dump_monitor()
234 dev
[1].dump_monitor()
236 write_hostapd_config(conffile
, apdev
[0]['ifname'], "test-a", bss2
=False)
237 with
open(pidfile
, "r") as f
:
239 os
.kill(pid
, signal
.SIGHUP
)
242 dev
[0].flush_scan_cache()
244 dev
[0].connect("test-a", key_mgmt
="NONE", scan_freq
="2412")
245 dev
[0].request("REMOVE_NETWORK all")
246 dev
[0].wait_disconnected()
247 dev
[0].dump_monitor()
249 write_hostapd_config(conffile
, apdev
[0]['ifname'], "test-b", bss2
=True)
250 os
.kill(pid
, signal
.SIGHUP
)
253 dev
[0].flush_scan_cache()
254 dev
[1].flush_scan_cache()
256 dev
[0].connect("test-b", key_mgmt
="NONE", scan_freq
="2412",
258 dev
[1].connect("test-b-2", key_mgmt
="NONE", scan_freq
="2412")
259 dev
[0].wait_connected()
260 dev
[0].request("REMOVE_NETWORK all")
261 dev
[1].request("REMOVE_NETWORK all")
262 dev
[0].wait_disconnected()
263 dev
[1].wait_disconnected()
264 dev
[0].dump_monitor()
265 dev
[1].dump_monitor()
267 os
.kill(pid
, signal
.SIGTERM
)
269 def test_ap_config_reload_before_enable(dev
, apdev
, params
):
270 """hostapd configuration reload before enable"""
271 hapd
= hostapd
.add_iface(apdev
[0], "bss-1.conf")
272 with
open(os
.path
.join(params
['logdir'], 'hostapd-test.pid'), "r") as f
:
274 os
.kill(pid
, signal
.SIGHUP
)
277 def test_ap_config_sigusr1(dev
, apdev
, params
):
278 """hostapd SIGUSR1"""
279 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": "foobar"})
280 with
open(os
.path
.join(params
['logdir'], 'hostapd-test.pid'), "r") as f
:
282 os
.kill(pid
, signal
.SIGUSR1
)
283 dev
[0].connect("foobar", key_mgmt
="NONE", scan_freq
="2412")
284 os
.kill(pid
, signal
.SIGUSR1
)
286 def test_ap_config_invalid_value(dev
, apdev
, params
):
287 """Ignoring invalid hostapd configuration parameter updates"""
288 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": "test"}, no_enable
=True)
289 not_exist
= "/tmp/hostapd-test/does-not-exist"
290 tests
= [("driver", "foobar"),
292 ("macaddr_acl", "255"),
293 ("accept_mac_file", not_exist
),
294 ("deny_mac_file", not_exist
),
295 ("eapol_version", "255"),
296 ("eap_user_file", not_exist
),
297 ("wep_key_len_broadcast", "-1"),
298 ("wep_key_len_unicast", "-1"),
299 ("wep_rekey_period", "-1"),
300 ("eap_rekey_period", "-1"),
301 ("radius_client_addr", "foo"),
302 ("acs_chan_bias", "-1:0.8"),
303 ("acs_chan_bias", "1"),
304 ("acs_chan_bias", "1:p"),
305 ("acs_chan_bias", "1:-0.8"),
306 ("acs_chan_bias", "1:0.8p"),
307 ("dtim_period", "0"),
308 ("bss_load_update_period", "-1"),
309 ("send_probe_response", "255"),
310 ("beacon_rate", "ht:-1"),
311 ("beacon_rate", "ht:32"),
312 ("beacon_rate", "vht:-1"),
313 ("beacon_rate", "vht:10"),
314 ("beacon_rate", "9"),
315 ("beacon_rate", "10001"),
316 ("vlan_file", not_exist
),
319 ("extra_cred", not_exist
),
320 ("anqp_elem", "265"),
321 ("anqp_elem", "265"),
322 ("anqp_elem", "265:1"),
323 ("anqp_elem", "265:1q"),
324 ("fst_priority", ""),
325 ("fils_cache_id", "q"),
326 ("venue_url", "foo"),
327 ("venue_url", "1:" + 255*"a"),
328 ("unknown-item", "foo")]
329 for field
, val
in tests
:
330 if "FAIL" not in hapd
.request("SET %s %s" % (field
, val
)):
331 raise Exception("Invalid %s accepted" % field
)
333 dev
[0].connect("test", key_mgmt
="NONE", scan_freq
="2412")
335 def test_ap_config_eap_user_file_parsing(dev
, apdev
, params
):
336 """hostapd eap_user_file parsing"""
337 tmp
= os
.path
.join(params
['logdir'], 'ap_config_eap_user_file_parsing.tmp')
338 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": "foobar"})
341 if "OK" not in hapd
.request("SET eap_user_file auth_serv/eap_user.conf"):
342 raise Exception("eap_user_file rejected")
344 tests
= ["#\n\n*\tTLS\nradius_accept_attr=:",
349 "\"foo\" " + 10*"TLS," + "TLS \"\n",
350 "\"foo\" TLS \nfoo\n",
351 "\"foo\" PEAP hash:foo\n",
352 "\"foo\" PEAP hash:8846f7eaee8fb117ad06bdd830b7586q\n",
353 "\"foo\" PEAP 01020\n",
354 "\"foo\" PEAP 010q\n"
355 '"pwd" PWD ssha1:\n',
356 '"pwd" PWD ssha1:' + 20*'00' + '\n',
357 '"pwd" PWD ssha256:\n',
358 '"pwd" PWD ssha512:\n',
359 '"pwd" PWD ssha1:' + 20*'00' + 'qq\n',
360 '"pwd" PWD ssha1:' + 19*'00' + 'qq00\n',
361 "\"foo\" TLS\nradius_accept_attr=123:x:012\n",
362 "\"foo\" TLS\nradius_accept_attr=123:x:012q\n",
363 "\"foo\" TLS\nradius_accept_attr=123:Q:01\n",
364 "\"foo\" TLS\nradius_accept_attr=123\nfoo\n"]
366 with
open(tmp
, "w") as f
:
368 if "FAIL" not in hapd
.request("SET eap_user_file " + tmp
):
369 raise Exception("Invalid eap_user_file accepted")
371 tests
= [("\"foo\" TLS\n", 2, "hostapd_config_read_eap_user"),
372 ("\"foo\" PEAP \"foo\"\n", 3, "hostapd_config_read_eap_user"),
373 ("\"foo\" PEAP hash:8846f7eaee8fb117ad06bdd830b75861\n", 3,
374 "hostapd_config_read_eap_user"),
375 ("\"foo\" PEAP 0102\n", 3, "hostapd_config_read_eap_user"),
376 ("\"foo\" TLS\nradius_accept_attr=123\n", 1,
377 "=hostapd_parse_radius_attr"),
378 ("\"foo\" TLS\nradius_accept_attr=123\n", 1,
379 "wpabuf_alloc;hostapd_parse_radius_attr"),
380 ("\"foo\" TLS\nradius_accept_attr=123:s:foo\n", 2,
381 "hostapd_parse_radius_attr"),
382 ("\"foo\" TLS\nradius_accept_attr=123:x:0102\n", 2,
383 "hostapd_parse_radius_attr"),
384 ("\"foo\" TLS\nradius_accept_attr=123:d:1\n", 2,
385 "hostapd_parse_radius_attr"),
386 ('"pwd" PWD ssha1:046239e0660a59015231082a071c803e9f5848ae42eaccb4c08c97ae397bc879c4b071b9088ee715\n', 1, "hostapd_config_eap_user_salted"),
387 ('"pwd" PWD ssha1:046239e0660a59015231082a071c803e9f5848ae42eaccb4c08c97ae397bc879c4b071b9088ee715\n', 2, "hostapd_config_eap_user_salted"),
388 ("* TLS\n", 1, "hostapd_config_read_eap_user")]
389 for t
, count
, func
in tests
:
390 with
alloc_fail(hapd
, count
, func
):
391 with
open(tmp
, "w") as f
:
393 if "FAIL" not in hapd
.request("SET eap_user_file " + tmp
):
394 raise Exception("eap_user_file accepted during OOM")
396 def test_ap_config_set_oom(dev
, apdev
):
397 """hostapd configuration parsing OOM"""
398 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": "foobar"})
400 tests
= [(1, "hostapd_parse_das_client",
401 "SET radius_das_client 192.168.1.123 pw"),
402 (1, "hostapd_config_read_wep", "SET wep_key0 \"hello\""),
403 (1, "hostapd_config_read_wep", "SET wep_key0 0102030405"),
404 (1, "hostapd_parse_chanlist", "SET chanlist 1 6 11-13"),
405 (1, "hostapd_config_bss", "SET bss foo"),
406 (2, "hostapd_config_bss", "SET bss foo"),
407 (3, "hostapd_config_bss", "SET bss foo"),
409 "SET r0kh 02:01:02:03:04:05 r0kh-1.example.com 000102030405060708090a0b0c0d0e0f"),
411 "SET r1kh 02:01:02:03:04:05 02:11:22:33:44:55 000102030405060708090a0b0c0d0e0f"),
412 (1, "parse_roaming_consortium", "SET roaming_consortium 021122"),
413 (1, "parse_lang_string", "SET venue_name eng:Example venue"),
414 (1, "parse_3gpp_cell_net",
415 "SET anqp_3gpp_cell_net 244,91;310,026;234,56"),
416 (1, "parse_nai_realm", "SET nai_realm 0,example.com;example.net"),
417 (2, "parse_nai_realm", "SET nai_realm 0,example.com;example.net"),
418 (1, "parse_anqp_elem", "SET anqp_elem 265:0000"),
419 (2, "parse_anqp_elem", "SET anqp_elem 266:000000"),
420 (1, "parse_venue_url", "SET venue_url 1:http://example.com/"),
421 (1, "hs20_parse_conn_capab", "SET hs20_conn_capab 1:0:2"),
422 (1, "hs20_parse_wan_metrics",
423 "SET hs20_wan_metrics 01:8000:1000:80:240:3000"),
424 (1, "hs20_parse_icon",
425 "SET hs20_icon 32:32:eng:image/png:icon32:/tmp/icon32.png"),
426 (1, "hs20_parse_osu_server_uri",
427 "SET osu_server_uri https://example.com/osu/"),
428 (1, "hostapd_config_parse_acs_chan_bias",
429 "SET acs_chan_bias 1:0.8 6:0.8 11:0.8"),
430 (2, "hostapd_config_parse_acs_chan_bias",
431 "SET acs_chan_bias 1:0.8 6:0.8 11:0.8"),
432 (1, "parse_wpabuf_hex", "SET vendor_elements 01020304"),
433 (1, "parse_fils_realm", "SET fils_realm example.com"),
434 (1, "hostapd_config_fill",
435 "SET pac_opaque_encr_key 000102030405060708090a0b0c0d0e0f"),
436 (1, "hostapd_config_fill", "SET eap_message hello"),
437 (1, "hostapd_config_fill",
438 "SET wpa_psk 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"),
439 (1, "hostapd_config_fill", "SET time_zone EST5"),
440 (1, "hostapd_config_fill",
441 "SET network_auth_type 02http://www.example.com/redirect/"),
442 (1, "hostapd_config_fill", "SET domain_name example.com"),
443 (1, "hostapd_config_fill", "SET hs20_operating_class 5173"),
444 (1, "hostapd_config_fill", "SET own_ie_override 11223344"),
445 (1, "hostapd_parse_intlist", "SET sae_groups 19 25"),
446 (1, "hostapd_parse_intlist", "SET basic_rates 10 20 55 110"),
447 (1, "hostapd_parse_intlist", "SET supported_rates 10 20 55 110")]
448 for count
, func
, cmd
in tests
:
449 with
alloc_fail(hapd
, count
, func
):
450 if "FAIL" not in hapd
.request(cmd
):
451 raise Exception("Command accepted during OOM: " + cmd
)
453 hapd
.set("hs20_icon", "32:32:eng:image/png:icon32:/tmp/icon32.png")
454 hapd
.set("hs20_conn_capab", "1:0:2")
455 hapd
.set("nai_realm", "0,example.com;example.net")
456 hapd
.set("venue_name", "eng:Example venue")
457 hapd
.set("roaming_consortium", "021122")
458 hapd
.set("osu_server_uri", "https://example.com/osu/")
459 hapd
.set("vendor_elements", "01020304")
460 hapd
.set("vendor_elements", "01020304")
461 hapd
.set("vendor_elements", "")
462 hapd
.set("lci", "11223344")
463 hapd
.set("civic", "11223344")
465 hapd
.set("civic", "")
467 tests
= [(1, "hs20_parse_icon",
468 "SET hs20_icon 32:32:eng:image/png:icon32:/tmp/icon32.png"),
469 (1, "parse_roaming_consortium", "SET roaming_consortium 021122"),
470 (2, "parse_nai_realm", "SET nai_realm 0,example.com;example.net"),
471 (1, "parse_lang_string", "SET venue_name eng:Example venue"),
472 (1, "hs20_parse_osu_server_uri",
473 "SET osu_server_uri https://example.com/osu/"),
474 (1, "hs20_parse_osu_nai", "SET osu_nai anonymous@example.com"),
475 (1, "hs20_parse_osu_nai2", "SET osu_nai2 anonymous@example.com"),
476 (1, "hostapd_parse_intlist", "SET osu_method_list 1 0"),
477 (1, "hs20_parse_osu_icon", "SET osu_icon icon32"),
478 (2, "hs20_parse_osu_icon", "SET osu_icon icon32"),
479 (2, "hs20_parse_osu_icon", "SET osu_icon icon32"),
480 (1, "hs20_parse_conn_capab", "SET hs20_conn_capab 1:0:2")]
481 for count
, func
, cmd
in tests
:
482 with
alloc_fail(hapd
, count
, func
):
483 if "FAIL" not in hapd
.request(cmd
):
484 raise Exception("Command accepted during OOM (2): " + cmd
)
486 tests
= [(1, "parse_fils_realm", "SET fils_realm example.com")]
487 for count
, func
, cmd
in tests
:
488 with
fail_test(hapd
, count
, func
):
489 if "FAIL" not in hapd
.request(cmd
):
490 raise Exception("Command accepted during FAIL_TEST: " + cmd
)
492 def test_ap_config_set_errors(dev
, apdev
):
493 """hostapd configuration parsing errors"""
494 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": "foobar"})
495 hapd
.set("wep_key0", '"hello"')
496 hapd
.set("wep_key1", '"hello"')
497 hapd
.set("wep_key0", '')
498 hapd
.set("wep_key0", '"hello"')
499 if "FAIL" not in hapd
.request("SET wep_key1 \"hello\""):
500 raise Exception("SET wep_key1 allowed to override existing key")
501 hapd
.set("wep_key1", '')
502 hapd
.set("wep_key1", '"hello"')
504 hapd
.set("auth_server_addr", "127.0.0.1")
505 hapd
.set("acct_server_addr", "127.0.0.1")
507 tests
= ["SET eap_reauth_period -1",
509 "SET auth_server_addr_replace foo",
510 "SET acct_server_addr_replace foo"]
512 if "FAIL" not in hapd
.request(t
):
513 raise Exception("Invalid command accepted: " + t
)
516 hapd
.set("tx_queue_after_beacon_aifs", '2')
517 hapd
.set("tx_queue_beacon_aifs", '2')
518 hapd
.set("tx_queue_data9_aifs", '2')
519 hapd
.set("debug", '1')
520 hapd
.set("dump_file", '/tmp/hostapd-test-dump')
521 hapd
.set("eap_authenticator", '0')
522 hapd
.set("radio_measurements", '0')
523 hapd
.set("radio_measurements", '1')
525 # Various extra coverage (not really errors)
526 hapd
.set("logger_syslog_level", '1')
527 hapd
.set("logger_syslog", '0')
529 for i
in range(50000):
530 if "OK" not in hapd
.request("SET hs20_conn_capab 17:5060:0"):
531 logger
.info("hs20_conn_capab limit at %d" % i
)
533 if i
< 1000 or i
>= 49999:
534 raise Exception("hs20_conn_capab limit not seen")