]>
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 ("sae_password", "secret|mac=qq"),
329 ("unknown-item", "foo")]
330 for field
, val
in tests
:
331 if "FAIL" not in hapd
.request("SET %s %s" % (field
, val
)):
332 raise Exception("Invalid %s accepted" % field
)
334 dev
[0].connect("test", key_mgmt
="NONE", scan_freq
="2412")
336 def test_ap_config_eap_user_file_parsing(dev
, apdev
, params
):
337 """hostapd eap_user_file parsing"""
338 tmp
= os
.path
.join(params
['logdir'], 'ap_config_eap_user_file_parsing.tmp')
339 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": "foobar"})
342 if "OK" not in hapd
.request("SET eap_user_file auth_serv/eap_user.conf"):
343 raise Exception("eap_user_file rejected")
345 tests
= ["#\n\n*\tTLS\nradius_accept_attr=:",
350 "\"foo\" " + 10*"TLS," + "TLS \"\n",
351 "\"foo\" TLS \nfoo\n",
352 "\"foo\" PEAP hash:foo\n",
353 "\"foo\" PEAP hash:8846f7eaee8fb117ad06bdd830b7586q\n",
354 "\"foo\" PEAP 01020\n",
355 "\"foo\" PEAP 010q\n"
356 '"pwd" PWD ssha1:\n',
357 '"pwd" PWD ssha1:' + 20*'00' + '\n',
358 '"pwd" PWD ssha256:\n',
359 '"pwd" PWD ssha512:\n',
360 '"pwd" PWD ssha1:' + 20*'00' + 'qq\n',
361 '"pwd" PWD ssha1:' + 19*'00' + 'qq00\n',
362 "\"foo\" TLS\nradius_accept_attr=123:x:012\n",
363 "\"foo\" TLS\nradius_accept_attr=123:x:012q\n",
364 "\"foo\" TLS\nradius_accept_attr=123:Q:01\n",
365 "\"foo\" TLS\nradius_accept_attr=123\nfoo\n"]
367 with
open(tmp
, "w") as f
:
369 if "FAIL" not in hapd
.request("SET eap_user_file " + tmp
):
370 raise Exception("Invalid eap_user_file accepted")
372 tests
= [("\"foo\" TLS\n", 2, "hostapd_config_read_eap_user"),
373 ("\"foo\" PEAP \"foo\"\n", 3, "hostapd_config_read_eap_user"),
374 ("\"foo\" PEAP hash:8846f7eaee8fb117ad06bdd830b75861\n", 3,
375 "hostapd_config_read_eap_user"),
376 ("\"foo\" PEAP 0102\n", 3, "hostapd_config_read_eap_user"),
377 ("\"foo\" TLS\nradius_accept_attr=123\n", 1,
378 "=hostapd_parse_radius_attr"),
379 ("\"foo\" TLS\nradius_accept_attr=123\n", 1,
380 "wpabuf_alloc;hostapd_parse_radius_attr"),
381 ("\"foo\" TLS\nradius_accept_attr=123:s:foo\n", 2,
382 "hostapd_parse_radius_attr"),
383 ("\"foo\" TLS\nradius_accept_attr=123:x:0102\n", 2,
384 "hostapd_parse_radius_attr"),
385 ("\"foo\" TLS\nradius_accept_attr=123:d:1\n", 2,
386 "hostapd_parse_radius_attr"),
387 ('"pwd" PWD ssha1:046239e0660a59015231082a071c803e9f5848ae42eaccb4c08c97ae397bc879c4b071b9088ee715\n', 1, "hostapd_config_eap_user_salted"),
388 ('"pwd" PWD ssha1:046239e0660a59015231082a071c803e9f5848ae42eaccb4c08c97ae397bc879c4b071b9088ee715\n', 2, "hostapd_config_eap_user_salted"),
389 ("* TLS\n", 1, "hostapd_config_read_eap_user")]
390 for t
, count
, func
in tests
:
391 with
alloc_fail(hapd
, count
, func
):
392 with
open(tmp
, "w") as f
:
394 if "FAIL" not in hapd
.request("SET eap_user_file " + tmp
):
395 raise Exception("eap_user_file accepted during OOM")
397 def test_ap_config_set_oom(dev
, apdev
):
398 """hostapd configuration parsing OOM"""
399 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": "foobar"})
401 tests
= [(1, "hostapd_parse_das_client",
402 "SET radius_das_client 192.168.1.123 pw"),
403 (1, "hostapd_config_read_wep", "SET wep_key0 \"hello\""),
404 (1, "hostapd_config_read_wep", "SET wep_key0 0102030405"),
405 (1, "hostapd_parse_chanlist", "SET chanlist 1 6 11-13"),
406 (1, "hostapd_config_bss", "SET bss foo"),
407 (2, "hostapd_config_bss", "SET bss foo"),
408 (3, "hostapd_config_bss", "SET bss foo"),
410 "SET r0kh 02:01:02:03:04:05 r0kh-1.example.com 000102030405060708090a0b0c0d0e0f"),
412 "SET r1kh 02:01:02:03:04:05 02:11:22:33:44:55 000102030405060708090a0b0c0d0e0f"),
413 (1, "parse_roaming_consortium", "SET roaming_consortium 021122"),
414 (1, "parse_lang_string", "SET venue_name eng:Example venue"),
415 (1, "parse_3gpp_cell_net",
416 "SET anqp_3gpp_cell_net 244,91;310,026;234,56"),
417 (1, "parse_nai_realm", "SET nai_realm 0,example.com;example.net"),
418 (2, "parse_nai_realm", "SET nai_realm 0,example.com;example.net"),
419 (1, "parse_anqp_elem", "SET anqp_elem 265:0000"),
420 (2, "parse_anqp_elem", "SET anqp_elem 266:000000"),
421 (1, "parse_venue_url", "SET venue_url 1:http://example.com/"),
422 (1, "hs20_parse_operator_icon", "SET operator_icon icon"),
423 (2, "hs20_parse_operator_icon", "SET operator_icon icon"),
424 (1, "hs20_parse_conn_capab", "SET hs20_conn_capab 1:0:2"),
425 (1, "hs20_parse_wan_metrics",
426 "SET hs20_wan_metrics 01:8000:1000:80:240:3000"),
427 (1, "hs20_parse_icon",
428 "SET hs20_icon 32:32:eng:image/png:icon32:/tmp/icon32.png"),
429 (1, "hs20_parse_osu_server_uri",
430 "SET osu_server_uri https://example.com/osu/"),
431 (1, "hostapd_config_parse_acs_chan_bias",
432 "SET acs_chan_bias 1:0.8 6:0.8 11:0.8"),
433 (2, "hostapd_config_parse_acs_chan_bias",
434 "SET acs_chan_bias 1:0.8 6:0.8 11:0.8"),
435 (1, "parse_wpabuf_hex", "SET vendor_elements 01020304"),
436 (1, "parse_fils_realm", "SET fils_realm example.com"),
437 (1, "parse_sae_password", "SET sae_password secret"),
438 (2, "parse_sae_password", "SET sae_password secret"),
439 (2, "parse_sae_password", "SET sae_password secret|id=pw"),
440 (3, "parse_sae_password", "SET sae_password secret|id=pw"),
441 (1, "hostapd_config_fill",
442 "SET pac_opaque_encr_key 000102030405060708090a0b0c0d0e0f"),
443 (1, "hostapd_config_fill", "SET eap_message hello"),
444 (1, "hostapd_config_fill",
445 "SET wpa_psk 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"),
446 (1, "hostapd_config_fill", "SET time_zone EST5"),
447 (1, "hostapd_config_fill",
448 "SET network_auth_type 02http://www.example.com/redirect/"),
449 (1, "hostapd_config_fill", "SET domain_name example.com"),
450 (1, "hostapd_config_fill", "SET hs20_operating_class 5173"),
451 (1, "hostapd_config_fill", "SET own_ie_override 11223344"),
452 (1, "hostapd_parse_intlist", "SET sae_groups 19 25"),
453 (1, "hostapd_parse_intlist", "SET basic_rates 10 20 55 110"),
454 (1, "hostapd_parse_intlist", "SET supported_rates 10 20 55 110")]
455 for count
, func
, cmd
in tests
:
456 with
alloc_fail(hapd
, count
, func
):
457 if "FAIL" not in hapd
.request(cmd
):
458 raise Exception("Command accepted during OOM: " + cmd
)
460 hapd
.set("hs20_icon", "32:32:eng:image/png:icon32:/tmp/icon32.png")
461 hapd
.set("hs20_conn_capab", "1:0:2")
462 hapd
.set("nai_realm", "0,example.com;example.net")
463 hapd
.set("venue_name", "eng:Example venue")
464 hapd
.set("roaming_consortium", "021122")
465 hapd
.set("osu_server_uri", "https://example.com/osu/")
466 hapd
.set("vendor_elements", "01020304")
467 hapd
.set("vendor_elements", "01020304")
468 hapd
.set("vendor_elements", "")
469 hapd
.set("lci", "11223344")
470 hapd
.set("civic", "11223344")
472 hapd
.set("civic", "")
474 tests
= [(1, "hs20_parse_icon",
475 "SET hs20_icon 32:32:eng:image/png:icon32:/tmp/icon32.png"),
476 (1, "parse_roaming_consortium", "SET roaming_consortium 021122"),
477 (2, "parse_nai_realm", "SET nai_realm 0,example.com;example.net"),
478 (1, "parse_lang_string", "SET venue_name eng:Example venue"),
479 (1, "hs20_parse_osu_server_uri",
480 "SET osu_server_uri https://example.com/osu/"),
481 (1, "hs20_parse_osu_nai", "SET osu_nai anonymous@example.com"),
482 (1, "hs20_parse_osu_nai2", "SET osu_nai2 anonymous@example.com"),
483 (1, "hostapd_parse_intlist", "SET osu_method_list 1 0"),
484 (1, "hs20_parse_osu_icon", "SET osu_icon icon32"),
485 (2, "hs20_parse_osu_icon", "SET osu_icon icon32"),
486 (2, "hs20_parse_osu_icon", "SET osu_icon icon32"),
487 (1, "hs20_parse_conn_capab", "SET hs20_conn_capab 1:0:2")]
488 for count
, func
, cmd
in tests
:
489 with
alloc_fail(hapd
, count
, func
):
490 if "FAIL" not in hapd
.request(cmd
):
491 raise Exception("Command accepted during OOM (2): " + cmd
)
493 tests
= [(1, "parse_fils_realm", "SET fils_realm example.com")]
494 for count
, func
, cmd
in tests
:
495 with
fail_test(hapd
, count
, func
):
496 if "FAIL" not in hapd
.request(cmd
):
497 raise Exception("Command accepted during FAIL_TEST: " + cmd
)
499 def test_ap_config_set_errors(dev
, apdev
):
500 """hostapd configuration parsing errors"""
501 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": "foobar"})
502 hapd
.set("wep_key0", '"hello"')
503 hapd
.set("wep_key1", '"hello"')
504 hapd
.set("wep_key0", '')
505 hapd
.set("wep_key0", '"hello"')
506 if "FAIL" not in hapd
.request("SET wep_key1 \"hello\""):
507 raise Exception("SET wep_key1 allowed to override existing key")
508 hapd
.set("wep_key1", '')
509 hapd
.set("wep_key1", '"hello"')
511 hapd
.set("auth_server_addr", "127.0.0.1")
512 hapd
.set("acct_server_addr", "127.0.0.1")
514 tests
= ["SET eap_reauth_period -1",
516 "SET auth_server_addr_replace foo",
517 "SET acct_server_addr_replace foo"]
519 if "FAIL" not in hapd
.request(t
):
520 raise Exception("Invalid command accepted: " + t
)
523 hapd
.set("tx_queue_after_beacon_aifs", '2')
524 hapd
.set("tx_queue_beacon_aifs", '2')
525 hapd
.set("tx_queue_data9_aifs", '2')
526 hapd
.set("debug", '1')
527 hapd
.set("dump_file", '/tmp/hostapd-test-dump')
528 hapd
.set("eap_authenticator", '0')
529 hapd
.set("radio_measurements", '0')
530 hapd
.set("radio_measurements", '1')
532 # Various extra coverage (not really errors)
533 hapd
.set("logger_syslog_level", '1')
534 hapd
.set("logger_syslog", '0')
535 hapd
.set("tls_flags", "[ALLOW-SIGN-RSA-MD5][DISABLE-TIME-CHECKS][DISABLE-TLSv1.0]")
537 for i
in range(50000):
538 if "OK" not in hapd
.request("SET hs20_conn_capab 17:5060:0"):
539 logger
.info("hs20_conn_capab limit at %d" % i
)
541 if i
< 1000 or i
>= 49999:
542 raise Exception("hs20_conn_capab limit not seen")