]>
git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_ap_hs20.py
2 # Copyright (c) 2013-2014, Jouni Malinen <j@w1.fi>
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
10 logger
= logging
.getLogger()
15 from wlantest
import Wlantest
17 def hs20_ap_params(ssid
="test-hs20"):
18 params
= hostapd
.wpa2_params(ssid
=ssid
)
19 params
['wpa_key_mgmt'] = "WPA-EAP"
20 params
['ieee80211w'] = "1"
21 params
['ieee8021x'] = "1"
22 params
['auth_server_addr'] = "127.0.0.1"
23 params
['auth_server_port'] = "1812"
24 params
['auth_server_shared_secret'] = "radius"
25 params
['interworking'] = "1"
26 params
['access_network_type'] = "14"
27 params
['internet'] = "1"
31 params
['venue_group'] = "7"
32 params
['venue_type'] = "1"
33 params
['venue_name'] = [ "eng:Example venue", "fin:Esimerkkipaikka" ]
34 params
['roaming_consortium'] = [ "112233", "1020304050", "010203040506",
36 params
['domain_name'] = "example.com,another.example.com"
37 params
['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]",
38 "0,another.example.com" ]
40 params
['hs20_wan_metrics'] = "01:8000:1000:80:240:3000"
41 params
['hs20_conn_capab'] = [ "1:0:2", "6:22:1", "17:5060:0" ]
42 params
['hs20_operating_class'] = "5173"
43 params
['anqp_3gpp_cell_net'] = "244,91"
46 def interworking_select(dev
, bssid
, type=None, no_match
=False, freq
=None):
48 freq_extra
= " freq=" + freq
if freq
else ""
49 dev
.request("INTERWORKING_SELECT" + freq_extra
)
50 ev
= dev
.wait_event(["INTERWORKING-AP", "INTERWORKING-NO-MATCH"],
53 raise Exception("Network selection timed out");
55 if "INTERWORKING-NO-MATCH" not in ev
:
56 raise Exception("Unexpected network match")
58 if "INTERWORKING-NO-MATCH" in ev
:
59 raise Exception("Matching network not found")
60 if bssid
and bssid
not in ev
:
61 raise Exception("Unexpected BSSID in match")
62 if type and "type=" + type not in ev
:
63 raise Exception("Network type not recognized correctly")
65 def check_sp_type(dev
, sp_type
):
66 type = dev
.get_status_field("sp_type")
68 raise Exception("sp_type not available")
70 raise Exception("sp_type did not indicate home network")
72 def hlr_auc_gw_available():
73 if not os
.path
.exists("/tmp/hlr_auc_gw.sock"):
74 logger
.info("No hlr_auc_gw available");
76 if not os
.path
.exists("../../hostapd/hlr_auc_gw"):
77 logger
.info("No hlr_auc_gw available");
81 def interworking_ext_sim_connect(dev
, bssid
, method
):
82 dev
.request("INTERWORKING_CONNECT " + bssid
)
83 interworking_ext_sim_auth(dev
, method
)
85 def interworking_ext_sim_auth(dev
, method
):
86 ev
= dev
.wait_event(["CTRL-EVENT-EAP-METHOD"], timeout
=15)
88 raise Exception("Network connected timed out")
89 if "(" + method
+ ")" not in ev
:
90 raise Exception("Unexpected EAP method selection")
92 ev
= dev
.wait_event(["CTRL-REQ-SIM"], timeout
=15)
94 raise Exception("Wait for external SIM processing request timed out")
96 if p
[1] != "GSM-AUTH":
97 raise Exception("Unexpected CTRL-REQ-SIM type")
98 id = p
[0].split('-')[3]
99 rand
= p
[2].split(' ')[0]
101 res
= subprocess
.check_output(["../../hostapd/hlr_auc_gw",
103 "auth_serv/hlr_auc_gw.milenage_db",
104 "GSM-AUTH-REQ 232010000000000 " + rand
])
105 if "GSM-AUTH-RESP" not in res
:
106 raise Exception("Unexpected hlr_auc_gw response")
107 resp
= res
.split(' ')[2].rstrip()
109 dev
.request("CTRL-RSP-SIM-" + id + ":GSM-AUTH:" + resp
)
110 ev
= dev
.wait_event(["CTRL-EVENT-CONNECTED"], timeout
=15)
112 raise Exception("Connection timed out")
114 def interworking_connect(dev
, bssid
, method
):
115 dev
.request("INTERWORKING_CONNECT " + bssid
)
116 interworking_auth(dev
, method
)
118 def interworking_auth(dev
, method
):
119 ev
= dev
.wait_event(["CTRL-EVENT-EAP-METHOD"], timeout
=15)
121 raise Exception("Network connected timed out")
122 if "(" + method
+ ")" not in ev
:
123 raise Exception("Unexpected EAP method selection")
125 ev
= dev
.wait_event(["CTRL-EVENT-CONNECTED"], timeout
=15)
127 raise Exception("Connection timed out")
129 def check_probe_resp(wt
, bssid_unexpected
, bssid_expected
):
131 count
= wt
.get_bss_counter("probe_response", bssid_unexpected
)
133 raise Exception("Unexpected Probe Response frame from AP")
136 count
= wt
.get_bss_counter("probe_response", bssid_expected
)
138 raise Exception("No Probe Response frame from AP")
140 def test_ap_anqp_sharing(dev
, apdev
):
141 """ANQP sharing within ESS and explicit unshare"""
142 bssid
= apdev
[0]['bssid']
143 params
= hs20_ap_params()
144 params
['hessid'] = bssid
145 hostapd
.add_ap(apdev
[0]['ifname'], params
)
147 bssid2
= apdev
[1]['bssid']
148 params
= hs20_ap_params()
149 params
['hessid'] = bssid
150 params
['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]" ]
151 hostapd
.add_ap(apdev
[1]['ifname'], params
)
154 id = dev
[0].add_cred_values({ 'realm': "example.com", 'username': "test",
155 'password': "secret",
156 'domain': "example.com" })
157 logger
.info("Normal network selection with shared ANQP results")
158 interworking_select(dev
[0], None, "home", freq
="2412")
159 dev
[0].dump_monitor()
161 res1
= dev
[0].get_bss(bssid
)
162 res2
= dev
[0].get_bss(bssid2
)
163 if res1
['anqp_nai_realm'] != res2
['anqp_nai_realm']:
164 raise Exception("ANQP results were not shared between BSSes")
166 logger
.info("Explicit ANQP request to unshare ANQP results")
167 dev
[0].request("ANQP_GET " + bssid
+ " 263")
168 ev
= dev
[0].wait_event(["RX-ANQP"], timeout
=5)
170 raise Exception("ANQP operation timed out")
172 dev
[0].request("ANQP_GET " + bssid2
+ " 263")
173 ev
= dev
[0].wait_event(["RX-ANQP"], timeout
=5)
175 raise Exception("ANQP operation timed out")
177 res1
= dev
[0].get_bss(bssid
)
178 res2
= dev
[0].get_bss(bssid2
)
179 if res1
['anqp_nai_realm'] == res2
['anqp_nai_realm']:
180 raise Exception("ANQP results were not unshared")
182 def test_ap_nai_home_realm_query(dev
, apdev
):
183 """NAI Home Realm Query"""
184 bssid
= apdev
[0]['bssid']
185 params
= hs20_ap_params()
186 params
['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]",
187 "0,another.example.org" ]
188 hostapd
.add_ap(apdev
[0]['ifname'], params
)
190 dev
[0].scan(freq
="2412")
191 dev
[0].request("HS20_GET_NAI_HOME_REALM_LIST " + bssid
+ " realm=example.com")
192 ev
= dev
[0].wait_event(["RX-ANQP"], timeout
=5)
194 raise Exception("ANQP operation timed out")
195 nai1
= dev
[0].get_bss(bssid
)['anqp_nai_realm']
196 dev
[0].dump_monitor()
198 dev
[0].request("ANQP_GET " + bssid
+ " 263")
199 ev
= dev
[0].wait_event(["RX-ANQP"], timeout
=5)
201 raise Exception("ANQP operation timed out")
202 nai2
= dev
[0].get_bss(bssid
)['anqp_nai_realm']
204 if len(nai1
) >= len(nai2
):
205 raise Exception("Unexpected NAI Realm list response lengths")
206 if "example.com".encode('hex') not in nai1
:
207 raise Exception("Home realm not reported")
208 if "example.org".encode('hex') in nai1
:
209 raise Exception("Non-home realm reported")
210 if "example.com".encode('hex') not in nai2
:
211 raise Exception("Home realm not reported in wildcard query")
212 if "example.org".encode('hex') not in nai2
:
213 raise Exception("Non-home realm not reported in wildcard query ")
215 def test_ap_interworking_scan_filtering(dev
, apdev
):
216 """Interworking scan filtering with HESSID and access network type"""
217 bssid
= apdev
[0]['bssid']
218 params
= hs20_ap_params()
219 ssid
= "test-hs20-ap1"
220 params
['ssid'] = ssid
221 params
['hessid'] = bssid
222 hostapd
.add_ap(apdev
[0]['ifname'], params
)
224 bssid2
= apdev
[1]['bssid']
225 params
= hs20_ap_params()
226 ssid2
= "test-hs20-ap2"
227 params
['ssid'] = ssid2
228 params
['hessid'] = bssid2
229 params
['access_network_type'] = "1"
230 del params
['venue_group']
231 del params
['venue_type']
232 hostapd
.add_ap(apdev
[1]['ifname'], params
)
239 logger
.info("Check probe request filtering based on HESSID")
241 dev
[0].request("SET hessid " + bssid2
)
242 dev
[0].scan(freq
="2412")
244 check_probe_resp(wt
, bssid
, bssid2
)
246 logger
.info("Check probe request filtering based on access network type")
248 wt
.clear_bss_counters(bssid
)
249 wt
.clear_bss_counters(bssid2
)
250 dev
[0].request("SET hessid 00:00:00:00:00:00")
251 dev
[0].request("SET access_network_type 14")
252 dev
[0].scan(freq
="2412")
254 check_probe_resp(wt
, bssid2
, bssid
)
256 wt
.clear_bss_counters(bssid
)
257 wt
.clear_bss_counters(bssid2
)
258 dev
[0].request("SET hessid 00:00:00:00:00:00")
259 dev
[0].request("SET access_network_type 1")
260 dev
[0].scan(freq
="2412")
262 check_probe_resp(wt
, bssid
, bssid2
)
264 logger
.info("Check probe request filtering based on HESSID and ANT")
266 wt
.clear_bss_counters(bssid
)
267 wt
.clear_bss_counters(bssid2
)
268 dev
[0].request("SET hessid " + bssid
)
269 dev
[0].request("SET access_network_type 14")
270 dev
[0].scan(freq
="2412")
272 check_probe_resp(wt
, bssid2
, bssid
)
274 wt
.clear_bss_counters(bssid
)
275 wt
.clear_bss_counters(bssid2
)
276 dev
[0].request("SET hessid " + bssid2
)
277 dev
[0].request("SET access_network_type 14")
278 dev
[0].scan(freq
="2412")
280 check_probe_resp(wt
, bssid
, None)
281 check_probe_resp(wt
, bssid2
, None)
283 wt
.clear_bss_counters(bssid
)
284 wt
.clear_bss_counters(bssid2
)
285 dev
[0].request("SET hessid " + bssid
)
286 dev
[0].request("SET access_network_type 1")
287 dev
[0].scan(freq
="2412")
289 check_probe_resp(wt
, bssid
, None)
290 check_probe_resp(wt
, bssid2
, None)
292 def test_ap_hs20_select(dev
, apdev
):
293 """Hotspot 2.0 network selection"""
294 bssid
= apdev
[0]['bssid']
295 params
= hs20_ap_params()
296 params
['hessid'] = bssid
297 hostapd
.add_ap(apdev
[0]['ifname'], params
)
300 id = dev
[0].add_cred_values({ 'realm': "example.com", 'username': "test",
301 'password': "secret",
302 'domain': "example.com" })
303 interworking_select(dev
[0], bssid
, "home")
305 dev
[0].remove_cred(id)
306 id = dev
[0].add_cred_values({ 'realm': "example.com", 'username': "test",
307 'password': "secret",
308 'domain': "no.match.example.com" })
309 interworking_select(dev
[0], bssid
, "roaming", freq
="2412")
311 dev
[0].set_cred_quoted(id, "realm", "no.match.example.com");
312 interworking_select(dev
[0], bssid
, no_match
=True, freq
="2412")
314 bssid2
= apdev
[1]['bssid']
315 params
= hs20_ap_params()
316 params
['nai_realm'] = [ "0,example.org,21" ]
317 params
['hessid'] = bssid2
318 params
['domain_name'] = "example.org"
319 hostapd
.add_ap(apdev
[1]['ifname'], params
)
320 dev
[0].remove_cred(id)
321 id = dev
[0].add_cred_values({ 'realm': "example.org", 'username': "test",
322 'password': "secret",
323 'domain': "example.org" })
324 interworking_select(dev
[0], bssid2
, "home", freq
="2412")
326 def hs20_simulated_sim(dev
, ap
, method
):
328 params
= hs20_ap_params()
329 params
['hessid'] = bssid
330 params
['anqp_3gpp_cell_net'] = "555,444"
331 params
['domain_name'] = "wlan.mnc444.mcc555.3gppnetwork.org"
332 hostapd
.add_ap(ap
['ifname'], params
)
335 dev
.add_cred_values({ 'imsi': "555444-333222111", 'eap': method
,
336 'milenage': "5122250214c33e723a5dd523fc145fc0:981d464c7c52eb6e5036234984ad0bcf:000000000123"})
337 interworking_select(dev
, "home", freq
="2412")
338 interworking_connect(dev
, bssid
, method
)
339 check_sp_type(dev
, "home")
341 def test_ap_hs20_sim(dev
, apdev
):
342 """Hotspot 2.0 with simulated SIM and EAP-SIM"""
343 if not hlr_auc_gw_available():
345 hs20_simulated_sim(dev
[0], apdev
[0], "SIM")
347 def test_ap_hs20_aka(dev
, apdev
):
348 """Hotspot 2.0 with simulated USIM and EAP-AKA"""
349 if not hlr_auc_gw_available():
351 hs20_simulated_sim(dev
[0], apdev
[0], "AKA")
353 def test_ap_hs20_aka_prime(dev
, apdev
):
354 """Hotspot 2.0 with simulated USIM and EAP-AKA'"""
355 if not hlr_auc_gw_available():
357 hs20_simulated_sim(dev
[0], apdev
[0], "AKA'")
359 def test_ap_hs20_ext_sim(dev
, apdev
):
360 """Hotspot 2.0 with external SIM processing"""
361 if not hlr_auc_gw_available():
363 bssid
= apdev
[0]['bssid']
364 params
= hs20_ap_params()
365 params
['hessid'] = bssid
366 params
['anqp_3gpp_cell_net'] = "232,01"
367 params
['domain_name'] = "wlan.mnc001.mcc232.3gppnetwork.org"
368 hostapd
.add_ap(apdev
[0]['ifname'], params
)
371 dev
[0].request("SET external_sim 1")
372 dev
[0].add_cred_values({ 'imsi': "23201-0000000000", 'eap': "SIM" })
373 interworking_select(dev
[0], "home", freq
="2412")
374 interworking_ext_sim_connect(dev
[0], bssid
, "SIM")
375 check_sp_type(dev
[0], "home")
377 def test_ap_hs20_ext_sim_roaming(dev
, apdev
):
378 """Hotspot 2.0 with external SIM processing in roaming network"""
379 if not hlr_auc_gw_available():
381 bssid
= apdev
[0]['bssid']
382 params
= hs20_ap_params()
383 params
['hessid'] = bssid
384 params
['anqp_3gpp_cell_net'] = "244,91;310,026;232,01;234,56"
385 params
['domain_name'] = "wlan.mnc091.mcc244.3gppnetwork.org"
386 hostapd
.add_ap(apdev
[0]['ifname'], params
)
389 dev
[0].request("SET external_sim 1")
390 dev
[0].add_cred_values({ 'imsi': "23201-0000000000", 'eap': "SIM" })
391 interworking_select(dev
[0], "roaming", freq
="2412")
392 interworking_ext_sim_connect(dev
[0], bssid
, "SIM")
393 check_sp_type(dev
[0], "roaming")
395 def test_ap_hs20_username(dev
, apdev
):
396 """Hotspot 2.0 connection in username/password credential"""
397 bssid
= apdev
[0]['bssid']
398 params
= hs20_ap_params()
399 params
['hessid'] = bssid
400 hostapd
.add_ap(apdev
[0]['ifname'], params
)
403 id = dev
[0].add_cred_values({ 'realm': "example.com",
404 'username': "hs20-test",
405 'password': "password",
406 'domain': "example.com",
407 'update_identifier': "1234" })
408 interworking_select(dev
[0], bssid
, "home", freq
="2412")
409 interworking_connect(dev
[0], bssid
, "TTLS")
410 check_sp_type(dev
[0], "home")
412 def eap_test(dev
, ap
, eap_params
, method
, user
):
414 params
= hs20_ap_params()
415 params
['nai_realm'] = [ "0,example.com," + eap_params
]
416 hostapd
.add_ap(ap
['ifname'], params
)
419 dev
.add_cred_values({ 'realm': "example.com",
421 'password': "password" })
422 interworking_select(dev
, bssid
, freq
="2412")
423 interworking_connect(dev
, bssid
, method
)
425 def test_ap_hs20_eap_peap_mschapv2(dev
, apdev
):
426 """Hotspot 2.0 connection with PEAP/MSCHAPV2"""
427 eap_test(dev
[0], apdev
[0], "25[3:26]", "PEAP", "user")
429 def test_ap_hs20_eap_peap_gtc(dev
, apdev
):
430 """Hotspot 2.0 connection with PEAP/GTC"""
431 eap_test(dev
[0], apdev
[0], "25[3:6]", "PEAP", "user")
433 def test_ap_hs20_eap_ttls_chap(dev
, apdev
):
434 """Hotspot 2.0 connection with TTLS/CHAP"""
435 eap_test(dev
[0], apdev
[0], "21[2:2]", "TTLS", "chap user")
437 def test_ap_hs20_eap_ttls_mschap(dev
, apdev
):
438 """Hotspot 2.0 connection with TTLS/MSCHAP"""
439 eap_test(dev
[0], apdev
[0], "21[2:3]", "TTLS", "mschap user")
441 def test_ap_hs20_eap_ttls_eap_mschapv2(dev
, apdev
):
442 """Hotspot 2.0 connection with TTLS/EAP-MSCHAPv2"""
443 eap_test(dev
[0], apdev
[0], "21[3:26]", "TTLS", "user")
445 def test_ap_hs20_eap_fast_mschapv2(dev
, apdev
):
446 """Hotspot 2.0 connection with FAST/EAP-MSCHAPV2"""
447 eap_test(dev
[0], apdev
[0], "43[3:26]", "FAST", "user")
449 def test_ap_hs20_eap_fast_gtc(dev
, apdev
):
450 """Hotspot 2.0 connection with FAST/EAP-GTC"""
451 eap_test(dev
[0], apdev
[0], "43[3:6]", "FAST", "user")
453 def test_ap_hs20_eap_tls(dev
, apdev
):
454 """Hotspot 2.0 connection with EAP-TLS"""
455 bssid
= apdev
[0]['bssid']
456 params
= hs20_ap_params()
457 params
['nai_realm'] = [ "0,example.com,13[5:6]" ]
458 hostapd
.add_ap(apdev
[0]['ifname'], params
)
461 dev
[0].add_cred_values({ 'realm': "example.com",
462 'username': "certificate-user",
463 'ca_cert': "auth_serv/ca.pem",
464 'client_cert': "auth_serv/user.pem",
465 'private_key': "auth_serv/user.key"})
466 interworking_select(dev
[0], bssid
, freq
="2412")
467 interworking_connect(dev
[0], bssid
, "TLS")
469 def test_ap_hs20_nai_realms(dev
, apdev
):
470 """Hotspot 2.0 connection and multiple NAI realms and TTLS/PAP"""
471 bssid
= apdev
[0]['bssid']
472 params
= hs20_ap_params()
473 params
['hessid'] = bssid
474 params
['nai_realm'] = [ "0,no.match.here;example.com;no.match.here.either,21[2:1][5:7]" ]
475 hostapd
.add_ap(apdev
[0]['ifname'], params
)
478 id = dev
[0].add_cred_values({ 'realm': "example.com",
479 'username': "pap user",
480 'password': "password",
481 'domain': "example.com" })
482 interworking_select(dev
[0], bssid
, "home", freq
="2412")
483 interworking_connect(dev
[0], bssid
, "TTLS")
484 check_sp_type(dev
[0], "home")
486 def test_ap_hs20_roaming_consortium(dev
, apdev
):
487 """Hotspot 2.0 connection based on roaming consortium match"""
488 bssid
= apdev
[0]['bssid']
489 params
= hs20_ap_params()
490 params
['hessid'] = bssid
491 hostapd
.add_ap(apdev
[0]['ifname'], params
)
494 id = dev
[0].add_cred_values({ 'realm': "example.com",
496 'password': "password",
497 'domain': "example.com",
498 'roaming_consortium': "fedcba",
500 interworking_select(dev
[0], bssid
, "home", freq
="2412")
501 interworking_connect(dev
[0], bssid
, "PEAP")
502 check_sp_type(dev
[0], "home")
504 def test_ap_hs20_username_roaming(dev
, apdev
):
505 """Hotspot 2.0 connection in username/password credential (roaming)"""
506 bssid
= apdev
[0]['bssid']
507 params
= hs20_ap_params()
508 params
['nai_realm'] = [ "0,example.com,13[5:6],21[2:4][5:7]",
509 "0,roaming.example.com,21[2:4][5:7]",
510 "0,another.example.com" ]
511 params
['domain_name'] = "another.example.com"
512 params
['hessid'] = bssid
513 hostapd
.add_ap(apdev
[0]['ifname'], params
)
516 id = dev
[0].add_cred_values({ 'realm': "roaming.example.com",
517 'username': "hs20-test",
518 'password': "password",
519 'domain': "example.com" })
520 interworking_select(dev
[0], bssid
, "roaming", freq
="2412")
521 interworking_connect(dev
[0], bssid
, "TTLS")
522 check_sp_type(dev
[0], "roaming")
524 def test_ap_hs20_username_unknown(dev
, apdev
):
525 """Hotspot 2.0 connection in username/password credential (no domain in cred)"""
526 bssid
= apdev
[0]['bssid']
527 params
= hs20_ap_params()
528 params
['hessid'] = bssid
529 hostapd
.add_ap(apdev
[0]['ifname'], params
)
532 id = dev
[0].add_cred_values({ 'realm': "example.com",
533 'username': "hs20-test",
534 'password': "password" })
535 interworking_select(dev
[0], bssid
, "unknown", freq
="2412")
536 interworking_connect(dev
[0], bssid
, "TTLS")
537 check_sp_type(dev
[0], "unknown")
539 def test_ap_hs20_username_unknown2(dev
, apdev
):
540 """Hotspot 2.0 connection in username/password credential (no domain advertized)"""
541 bssid
= apdev
[0]['bssid']
542 params
= hs20_ap_params()
543 params
['hessid'] = bssid
544 del params
['domain_name']
545 hostapd
.add_ap(apdev
[0]['ifname'], params
)
548 id = dev
[0].add_cred_values({ 'realm': "example.com",
549 'username': "hs20-test",
550 'password': "password",
551 'domain': "example.com" })
552 interworking_select(dev
[0], bssid
, "unknown", freq
="2412")
553 interworking_connect(dev
[0], bssid
, "TTLS")
554 check_sp_type(dev
[0], "unknown")
556 def test_ap_hs20_gas_while_associated(dev
, apdev
):
557 """Hotspot 2.0 connection with GAS query while associated"""
558 bssid
= apdev
[0]['bssid']
559 params
= hs20_ap_params()
560 params
['hessid'] = bssid
561 hostapd
.add_ap(apdev
[0]['ifname'], params
)
564 id = dev
[0].add_cred_values({ 'realm': "example.com",
565 'username': "hs20-test",
566 'password': "password",
567 'domain': "example.com" })
568 interworking_select(dev
[0], bssid
, "home", freq
="2412")
569 interworking_connect(dev
[0], bssid
, "TTLS")
571 logger
.info("Verifying GAS query while associated")
572 dev
[0].request("FETCH_ANQP")
573 for i
in range(0, 6):
574 ev
= dev
[0].wait_event(["RX-ANQP"], timeout
=5)
576 raise Exception("Operation timed out")
578 def test_ap_hs20_gas_while_associated_with_pmf(dev
, apdev
):
579 """Hotspot 2.0 connection with GAS query while associated and using PMF"""
580 bssid
= apdev
[0]['bssid']
581 params
= hs20_ap_params()
582 params
['hessid'] = bssid
583 hostapd
.add_ap(apdev
[0]['ifname'], params
)
585 bssid2
= apdev
[1]['bssid']
586 params
= hs20_ap_params()
587 params
['hessid'] = bssid2
588 params
['nai_realm'] = [ "0,no-match.example.org,13[5:6],21[2:4][5:7]" ]
589 hostapd
.add_ap(apdev
[1]['ifname'], params
)
592 dev
[0].request("SET pmf 2")
593 id = dev
[0].add_cred_values({ 'realm': "example.com",
594 'username': "hs20-test",
595 'password': "password",
596 'domain': "example.com" })
597 interworking_select(dev
[0], bssid
, "home", freq
="2412")
598 interworking_connect(dev
[0], bssid
, "TTLS")
600 logger
.info("Verifying GAS query while associated")
601 dev
[0].request("FETCH_ANQP")
602 for i
in range(0, 2 * 6):
603 ev
= dev
[0].wait_event(["RX-ANQP"], timeout
=5)
605 raise Exception("Operation timed out")
607 def test_ap_hs20_gas_frag_while_associated(dev
, apdev
):
608 """Hotspot 2.0 connection with fragmented GAS query while associated"""
609 bssid
= apdev
[0]['bssid']
610 params
= hs20_ap_params()
611 params
['hessid'] = bssid
612 hostapd
.add_ap(apdev
[0]['ifname'], params
)
613 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
614 hapd
.set("gas_frag_limit", "50")
617 id = dev
[0].add_cred_values({ 'realm': "example.com",
618 'username': "hs20-test",
619 'password': "password",
620 'domain': "example.com" })
621 interworking_select(dev
[0], bssid
, "home", freq
="2412")
622 interworking_connect(dev
[0], bssid
, "TTLS")
624 logger
.info("Verifying GAS query while associated")
625 dev
[0].request("FETCH_ANQP")
626 for i
in range(0, 6):
627 ev
= dev
[0].wait_event(["RX-ANQP"], timeout
=5)
629 raise Exception("Operation timed out")
631 def test_ap_hs20_multiple_connects(dev
, apdev
):
632 """Hotspot 2.0 connection through multiple network selections"""
633 bssid
= apdev
[0]['bssid']
634 params
= hs20_ap_params()
635 params
['hessid'] = bssid
636 hostapd
.add_ap(apdev
[0]['ifname'], params
)
639 values
= { 'realm': "example.com",
640 'username': "hs20-test",
641 'password': "password",
642 'domain': "example.com" }
643 id = dev
[0].add_cred_values(values
)
645 for i
in range(0, 3):
646 logger
.info("Starting Interworking network selection")
647 dev
[0].request("INTERWORKING_SELECT auto freq=2412")
649 ev
= dev
[0].wait_event(["INTERWORKING-NO-MATCH",
650 "INTERWORKING-ALREADY-CONNECTED",
651 "CTRL-EVENT-CONNECTED"], timeout
=15)
653 raise Exception("Connection timed out")
654 if "INTERWORKING-NO-MATCH" in ev
:
655 raise Exception("Matching AP not found")
656 if "CTRL-EVENT-CONNECTED" in ev
:
658 if i
== 2 and "INTERWORKING-ALREADY-CONNECTED" in ev
:
661 dev
[0].request("DISCONNECT")
662 dev
[0].dump_monitor()
664 networks
= dev
[0].list_networks()
665 if len(networks
) > 1:
666 raise Exception("Duplicated network block detected")
668 def test_ap_hs20_disallow_aps(dev
, apdev
):
669 """Hotspot 2.0 connection and disallow_aps"""
670 bssid
= apdev
[0]['bssid']
671 params
= hs20_ap_params()
672 params
['hessid'] = bssid
673 hostapd
.add_ap(apdev
[0]['ifname'], params
)
676 values
= { 'realm': "example.com",
677 'username': "hs20-test",
678 'password': "password",
679 'domain': "example.com" }
680 id = dev
[0].add_cred_values(values
)
682 logger
.info("Verify disallow_aps bssid")
683 dev
[0].request("SET disallow_aps bssid " + bssid
.translate(None, ':'))
684 dev
[0].request("INTERWORKING_SELECT auto")
685 ev
= dev
[0].wait_event(["INTERWORKING-NO-MATCH"], timeout
=15)
687 raise Exception("Network selection timed out")
688 dev
[0].dump_monitor()
690 logger
.info("Verify disallow_aps ssid")
691 dev
[0].request("SET disallow_aps ssid 746573742d68733230")
692 dev
[0].request("INTERWORKING_SELECT auto freq=2412")
693 ev
= dev
[0].wait_event(["INTERWORKING-NO-MATCH"], timeout
=15)
695 raise Exception("Network selection timed out")
696 dev
[0].dump_monitor()
698 logger
.info("Verify disallow_aps clear")
699 dev
[0].request("SET disallow_aps ")
700 interworking_select(dev
[0], bssid
, "home", freq
="2412")
702 dev
[0].request("SET disallow_aps bssid " + bssid
.translate(None, ':'))
703 ret
= dev
[0].request("INTERWORKING_CONNECT " + bssid
)
704 if "FAIL" not in ret
:
705 raise Exception("INTERWORKING_CONNECT to disallowed BSS not rejected")
707 def policy_test(dev
, ap
, values
, only_one
=True):
710 logger
.info("Verify network selection to AP " + ap
['ifname'])
713 logger
.info("Verify network selection")
716 id = dev
.add_cred_values(values
)
717 dev
.request("INTERWORKING_SELECT auto freq=2412")
720 ev
= dev
.wait_event(["INTERWORKING-AP", "INTERWORKING-NO-MATCH",
721 "INTERWORKING-BLACKLISTED",
722 "INTERWORKING-SELECTED"], timeout
=15)
724 raise Exception("Network selection timed out")
726 if "INTERWORKING-NO-MATCH" in ev
:
727 raise Exception("Matching AP not found")
728 if bssid
and only_one
and "INTERWORKING-AP" in ev
and bssid
not in ev
:
729 raise Exception("Unexpected AP claimed acceptable")
730 if "INTERWORKING-SELECTED" in ev
:
731 if bssid
and bssid
not in ev
:
732 raise Exception("Selected incorrect BSS")
735 ev
= dev
.wait_event(["CTRL-EVENT-CONNECTED"], timeout
=15)
737 raise Exception("Connection timed out")
738 if bssid
and bssid
not in ev
:
739 raise Exception("Connected to incorrect BSS")
741 conn_bssid
= dev
.get_status_field("bssid")
742 if bssid
and conn_bssid
!= bssid
:
743 raise Exception("bssid information points to incorrect BSS")
750 return { 'realm': "example.com",
751 'username': "hs20-test",
752 'password': "password" }
754 def test_ap_hs20_req_roaming_consortium(dev
, apdev
):
755 """Hotspot 2.0 required roaming consortium"""
756 params
= hs20_ap_params()
757 hostapd
.add_ap(apdev
[0]['ifname'], params
)
759 params
= hs20_ap_params()
760 params
['ssid'] = "test-hs20-other"
761 params
['roaming_consortium'] = [ "223344" ]
762 hostapd
.add_ap(apdev
[1]['ifname'], params
)
764 values
= default_cred()
765 values
['required_roaming_consortium'] = "223344"
766 policy_test(dev
[0], apdev
[1], values
)
767 values
['required_roaming_consortium'] = "112233"
768 policy_test(dev
[0], apdev
[0], values
)
770 id = dev
[0].add_cred()
771 dev
[0].set_cred(id, "required_roaming_consortium", "112233")
772 dev
[0].set_cred(id, "required_roaming_consortium", "112233445566778899aabbccddeeff")
774 for val
in [ "", "1", "11", "1122", "1122334", "112233445566778899aabbccddeeff00" ]:
775 if "FAIL" not in dev
[0].request('SET_CRED {} required_roaming_consortium {}'.format(id, val
)):
776 raise Exception("Invalid roaming consortium value accepted: " + val
)
778 def test_ap_hs20_excluded_ssid(dev
, apdev
):
779 """Hotspot 2.0 exclusion based on SSID"""
780 params
= hs20_ap_params()
781 hostapd
.add_ap(apdev
[0]['ifname'], params
)
783 params
= hs20_ap_params()
784 params
['ssid'] = "test-hs20-other"
785 params
['roaming_consortium'] = [ "223344" ]
786 hostapd
.add_ap(apdev
[1]['ifname'], params
)
788 values
= default_cred()
789 values
['excluded_ssid'] = "test-hs20"
790 events
= policy_test(dev
[0], apdev
[1], values
)
791 ev
= [e
for e
in events
if "INTERWORKING-BLACKLISTED " + apdev
[0]['bssid'] in e
]
793 raise Exception("Excluded network not reported")
794 values
['excluded_ssid'] = "test-hs20-other"
795 events
= policy_test(dev
[0], apdev
[0], values
)
796 ev
= [e
for e
in events
if "INTERWORKING-BLACKLISTED " + apdev
[1]['bssid'] in e
]
798 raise Exception("Excluded network not reported")
800 def test_ap_hs20_roam_to_higher_prio(dev
, apdev
):
801 """Hotspot 2.0 and roaming from current to higher priority network"""
802 bssid
= apdev
[0]['bssid']
803 params
= hs20_ap_params(ssid
="test-hs20-visited")
804 params
['domain_name'] = "visited.example.org"
805 hostapd
.add_ap(apdev
[0]['ifname'], params
)
808 id = dev
[0].add_cred_values({ 'realm': "example.com",
809 'username': "hs20-test",
810 'password': "password",
811 'domain': "example.com" })
812 logger
.info("Connect to the only network option")
813 interworking_select(dev
[0], bssid
, "roaming", freq
="2412")
814 dev
[0].dump_monitor()
815 interworking_connect(dev
[0], bssid
, "TTLS")
817 logger
.info("Start another AP (home operator) and reconnect")
818 bssid2
= apdev
[1]['bssid']
819 params
= hs20_ap_params(ssid
="test-hs20-home")
820 params
['domain_name'] = "example.com"
821 hostapd
.add_ap(apdev
[1]['ifname'], params
)
823 dev
[0].request("INTERWORKING_SELECT auto freq=2412")
824 ev
= dev
[0].wait_event(["INTERWORKING-NO-MATCH",
825 "INTERWORKING-ALREADY-CONNECTED",
826 "CTRL-EVENT-CONNECTED"], timeout
=15)
828 raise Exception("Connection timed out")
829 if "INTERWORKING-NO-MATCH" in ev
:
830 raise Exception("Matching AP not found")
831 if "INTERWORKING-ALREADY-CONNECTED" in ev
:
832 raise Exception("Unexpected AP selected")
834 raise Exception("Unexpected BSSID after reconnection")
836 def test_ap_hs20_domain_suffix_match(dev
, apdev
):
837 """Hotspot 2.0 and domain_suffix_match"""
838 bssid
= apdev
[0]['bssid']
839 params
= hs20_ap_params()
840 hostapd
.add_ap(apdev
[0]['ifname'], params
)
843 id = dev
[0].add_cred_values({ 'realm': "example.com",
844 'username': "hs20-test",
845 'password': "password",
846 'domain': "example.com",
847 'domain_suffix_match': "w1.fi" })
848 interworking_select(dev
[0], bssid
, "home", freq
="2412")
849 dev
[0].dump_monitor()
850 interworking_connect(dev
[0], bssid
, "TTLS")
851 dev
[0].request("REMOVE_NETWORK all")
852 dev
[0].dump_monitor()
854 dev
[0].set_cred_quoted(id, "domain_suffix_match", "no-match.example.com")
855 interworking_select(dev
[0], bssid
, "home", freq
="2412")
856 dev
[0].dump_monitor()
857 dev
[0].request("INTERWORKING_CONNECT " + bssid
)
858 ev
= dev
[0].wait_event(["CTRL-EVENT-EAP-TLS-CERT-ERROR"])
860 raise Exception("TLS certificate error not reported")
861 if "Domain suffix mismatch" not in ev
:
862 raise Exception("Domain suffix mismatch not reported")
864 def test_ap_hs20_roaming_partner_preference(dev
, apdev
):
865 """Hotspot 2.0 and roaming partner preference"""
866 params
= hs20_ap_params()
867 params
['domain_name'] = "roaming.example.org"
868 hostapd
.add_ap(apdev
[0]['ifname'], params
)
870 params
= hs20_ap_params()
871 params
['ssid'] = "test-hs20-other"
872 params
['domain_name'] = "roaming.example.net"
873 hostapd
.add_ap(apdev
[1]['ifname'], params
)
875 logger
.info("Verify default vs. specified preference")
876 values
= default_cred()
877 values
['roaming_partner'] = "roaming.example.net,1,127,*"
878 policy_test(dev
[0], apdev
[1], values
, only_one
=False)
879 values
['roaming_partner'] = "roaming.example.net,1,129,*"
880 policy_test(dev
[0], apdev
[0], values
, only_one
=False)
882 logger
.info("Verify partial FQDN match")
883 values
['roaming_partner'] = "example.net,0,0,*"
884 policy_test(dev
[0], apdev
[1], values
, only_one
=False)
885 values
['roaming_partner'] = "example.net,0,255,*"
886 policy_test(dev
[0], apdev
[0], values
, only_one
=False)
888 def test_ap_hs20_max_bss_load(dev
, apdev
):
889 """Hotspot 2.0 and maximum BSS load"""
890 params
= hs20_ap_params()
891 params
['bss_load_test'] = "12:200:20000"
892 hostapd
.add_ap(apdev
[0]['ifname'], params
)
894 params
= hs20_ap_params()
895 params
['ssid'] = "test-hs20-other"
896 params
['bss_load_test'] = "5:20:10000"
897 hostapd
.add_ap(apdev
[1]['ifname'], params
)
899 logger
.info("Verify maximum BSS load constraint")
900 values
= default_cred()
901 values
['domain'] = "example.com"
902 values
['max_bss_load'] = "100"
903 events
= policy_test(dev
[0], apdev
[1], values
, only_one
=False)
905 ev
= [e
for e
in events
if "INTERWORKING-AP " + apdev
[0]['bssid'] in e
]
906 if len(ev
) != 1 or "over_max_bss_load=1" not in ev
[0]:
907 raise Exception("Maximum BSS Load case not noticed")
908 ev
= [e
for e
in events
if "INTERWORKING-AP " + apdev
[1]['bssid'] in e
]
909 if len(ev
) != 1 or "over_max_bss_load=1" in ev
[0]:
910 raise Exception("Maximum BSS Load case reported incorrectly")
912 logger
.info("Verify maximum BSS load does not prevent connection")
913 values
['max_bss_load'] = "1"
914 events
= policy_test(dev
[0], None, values
)
916 ev
= [e
for e
in events
if "INTERWORKING-AP " + apdev
[0]['bssid'] in e
]
917 if len(ev
) != 1 or "over_max_bss_load=1" not in ev
[0]:
918 raise Exception("Maximum BSS Load case not noticed")
919 ev
= [e
for e
in events
if "INTERWORKING-AP " + apdev
[1]['bssid'] in e
]
920 if len(ev
) != 1 or "over_max_bss_load=1" not in ev
[0]:
921 raise Exception("Maximum BSS Load case not noticed")
923 def test_ap_hs20_max_bss_load2(dev
, apdev
):
924 """Hotspot 2.0 and maximum BSS load with one AP not advertising"""
925 params
= hs20_ap_params()
926 params
['bss_load_test'] = "12:200:20000"
927 hostapd
.add_ap(apdev
[0]['ifname'], params
)
929 params
= hs20_ap_params()
930 params
['ssid'] = "test-hs20-other"
931 hostapd
.add_ap(apdev
[1]['ifname'], params
)
933 logger
.info("Verify maximum BSS load constraint with AP advertisement")
934 values
= default_cred()
935 values
['domain'] = "example.com"
936 values
['max_bss_load'] = "100"
937 events
= policy_test(dev
[0], apdev
[1], values
, only_one
=False)
939 ev
= [e
for e
in events
if "INTERWORKING-AP " + apdev
[0]['bssid'] in e
]
940 if len(ev
) != 1 or "over_max_bss_load=1" not in ev
[0]:
941 raise Exception("Maximum BSS Load case not noticed")
942 ev
= [e
for e
in events
if "INTERWORKING-AP " + apdev
[1]['bssid'] in e
]
943 if len(ev
) != 1 or "over_max_bss_load=1" in ev
[0]:
944 raise Exception("Maximum BSS Load case reported incorrectly")
946 def test_ap_hs20_multi_cred_sp_prio(dev
, apdev
):
947 """Hotspot 2.0 multi-cred sp_priority"""
948 if not hlr_auc_gw_available():
950 bssid
= apdev
[0]['bssid']
951 params
= hs20_ap_params()
952 params
['hessid'] = bssid
953 del params
['domain_name']
954 params
['anqp_3gpp_cell_net'] = "232,01"
955 hostapd
.add_ap(apdev
[0]['ifname'], params
)
958 dev
[0].request("SET external_sim 1")
959 id1
= dev
[0].add_cred_values({ 'imsi': "23201-0000000000", 'eap': "SIM",
960 'provisioning_sp': "example.com",
961 'sp_priority' :"1" })
962 id2
= dev
[0].add_cred_values({ 'realm': "example.com",
963 'username': "hs20-test",
964 'password': "password",
965 'domain': "example.com",
966 'provisioning_sp': "example.com",
967 'sp_priority': "2" })
968 dev
[0].dump_monitor()
969 dev
[0].request("INTERWORKING_SELECT auto")
970 interworking_ext_sim_auth(dev
[0], "SIM")
971 check_sp_type(dev
[0], "unknown")
972 dev
[0].request("REMOVE_NETWORK all")
974 dev
[0].set_cred(id1
, "sp_priority", "2")
975 dev
[0].set_cred(id2
, "sp_priority", "1")
976 dev
[0].dump_monitor()
977 dev
[0].request("INTERWORKING_SELECT auto")
978 interworking_auth(dev
[0], "TTLS")
979 check_sp_type(dev
[0], "unknown")
981 def test_ap_hs20_multi_cred_sp_prio2(dev
, apdev
):
982 """Hotspot 2.0 multi-cred sp_priority with two BSSes"""
983 if not hlr_auc_gw_available():
985 bssid
= apdev
[0]['bssid']
986 params
= hs20_ap_params()
987 params
['hessid'] = bssid
988 del params
['nai_realm']
989 del params
['domain_name']
990 params
['anqp_3gpp_cell_net'] = "232,01"
991 hostapd
.add_ap(apdev
[0]['ifname'], params
)
993 bssid2
= apdev
[1]['bssid']
994 params
= hs20_ap_params()
995 params
['ssid'] = "test-hs20-other"
996 params
['hessid'] = bssid2
997 del params
['domain_name']
998 del params
['anqp_3gpp_cell_net']
999 hostapd
.add_ap(apdev
[1]['ifname'], params
)
1001 dev
[0].hs20_enable()
1002 dev
[0].request("SET external_sim 1")
1003 id1
= dev
[0].add_cred_values({ 'imsi': "23201-0000000000", 'eap': "SIM",
1004 'provisioning_sp': "example.com",
1005 'sp_priority': "1" })
1006 id2
= dev
[0].add_cred_values({ 'realm': "example.com",
1007 'username': "hs20-test",
1008 'password': "password",
1009 'domain': "example.com",
1010 'provisioning_sp': "example.com",
1011 'sp_priority': "2" })
1012 dev
[0].dump_monitor()
1013 dev
[0].request("INTERWORKING_SELECT auto")
1014 interworking_ext_sim_auth(dev
[0], "SIM")
1015 check_sp_type(dev
[0], "unknown")
1016 conn_bssid
= dev
[0].get_status_field("bssid")
1017 if conn_bssid
!= bssid
:
1018 raise Exception("Connected to incorrect BSS")
1019 dev
[0].request("REMOVE_NETWORK all")
1021 dev
[0].set_cred(id1
, "sp_priority", "2")
1022 dev
[0].set_cred(id2
, "sp_priority", "1")
1023 dev
[0].dump_monitor()
1024 dev
[0].request("INTERWORKING_SELECT auto")
1025 interworking_auth(dev
[0], "TTLS")
1026 check_sp_type(dev
[0], "unknown")
1027 conn_bssid
= dev
[0].get_status_field("bssid")
1028 if conn_bssid
!= bssid2
:
1029 raise Exception("Connected to incorrect BSS")
1031 def test_ap_hs20_req_conn_capab(dev
, apdev
):
1032 """Hotspot 2.0 network selection with req_conn_capab"""
1033 bssid
= apdev
[0]['bssid']
1034 params
= hs20_ap_params()
1035 hostapd
.add_ap(apdev
[0]['ifname'], params
)
1037 dev
[0].hs20_enable()
1038 logger
.info("Not used in home network")
1039 id = dev
[0].add_cred_values({ 'realm': "example.com",
1040 'username': "hs20-test",
1041 'password': "password",
1042 'domain': "example.com",
1043 'req_conn_capab': "6:1234" })
1044 dev
[0].request("INTERWORKING_SELECT freq=2412")
1045 ev
= dev
[0].wait_event(["INTERWORKING-AP"])
1047 raise Exception("Network selection timed out");
1048 if "type=home" not in ev
:
1049 raise Exception("Unexpected network type")
1050 if "conn_capab_missing=1" in ev
:
1051 raise Exception("req_conn_capab used in home network")
1053 logger
.info("Used in roaming network")
1054 dev
[0].remove_cred(id)
1055 id = dev
[0].add_cred_values({ 'realm': "example.com",
1056 'username': "hs20-test",
1057 'password': "password",
1058 'domain': "example.org",
1059 'req_conn_capab': "6:1234" })
1060 dev
[0].request("INTERWORKING_SELECT freq=2412")
1061 ev
= dev
[0].wait_event(["INTERWORKING-AP"])
1063 raise Exception("Network selection timed out");
1064 if "type=roaming" not in ev
:
1065 raise Exception("Unexpected network type")
1066 if "conn_capab_missing=1" not in ev
:
1067 raise Exception("Missing conn_capab not reported")
1069 logger
.info("Verify that req_conn_capab does not prevent connection if no other network is available")
1070 dev
[0].request("INTERWORKING_SELECT auto freq=2412")
1071 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=15)
1073 raise Exception("Connection timed out")
1075 def test_ap_hs20_deauth_req_ess(dev
, apdev
):
1076 """Hotspot 2.0 connection and deauthentication request for ESS"""
1077 dev
[0].request("SET pmf 2")
1078 eap_test(dev
[0], apdev
[0], "21[3:26]", "TTLS", "user")
1079 dev
[0].dump_monitor()
1080 addr
= dev
[0].p2p_interface_addr()
1081 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
1082 hapd
.request("HS20_DEAUTH_REQ " + addr
+ " 1 120 http://example.com/")
1083 ev
= dev
[0].wait_event(["HS20-DEAUTH-IMMINENT-NOTICE"])
1085 raise Exception("Timeout on deauth imminent notice")
1086 if "1 120 http://example.com/" not in ev
:
1087 raise Exception("Unexpected deauth imminent notice: " + ev
)
1088 hapd
.request("DEAUTHENTICATE " + addr
)
1089 ev
= dev
[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
1091 raise Exception("Timeout on disconnection")
1092 ev
= dev
[0].wait_event(["SME: Trying to authenticate",
1093 "Trying to associate",
1094 "CTRL-EVENT-CONNECTED"], timeout
=5)
1096 raise Exception("Unexpected connection attempt")
1098 def test_ap_hs20_deauth_req_bss(dev
, apdev
):
1099 """Hotspot 2.0 connection and deauthentication request for BSS"""
1100 dev
[0].request("SET pmf 2")
1101 eap_test(dev
[0], apdev
[0], "21[3:26]", "TTLS", "user")
1102 dev
[0].dump_monitor()
1103 addr
= dev
[0].p2p_interface_addr()
1104 hapd
= hostapd
.Hostapd(apdev
[0]['ifname'])
1105 hapd
.request("HS20_DEAUTH_REQ " + addr
+ " 0 120 http://example.com/")
1106 ev
= dev
[0].wait_event(["HS20-DEAUTH-IMMINENT-NOTICE"])
1108 raise Exception("Timeout on deauth imminent notice")
1109 if "0 120 http://example.com/" not in ev
:
1110 raise Exception("Unexpected deauth imminent notice: " + ev
)
1111 hapd
.request("DEAUTHENTICATE " + addr
+ " reason=4")
1112 ev
= dev
[0].wait_event(["CTRL-EVENT-DISCONNECTED"])
1114 raise Exception("Timeout on disconnection")
1115 if "reason=4" not in ev
:
1116 raise Exception("Unexpected disconnection reason")
1117 ev
= dev
[0].wait_event(["SME: Trying to authenticate",
1118 "Trying to associate",
1119 "CTRL-EVENT-CONNECTED"], timeout
=5)
1121 raise Exception("Unexpected connection attempt")
1123 def test_ap_hs20_osen(dev
, apdev
):
1124 """Hotspot 2.0 OSEN connection"""
1125 params
= { 'ssid': "osen",
1127 'auth_server_addr': "127.0.0.1",
1128 'auth_server_port': "1812",
1129 'auth_server_shared_secret': "radius" }
1130 hostapd
.add_ap(apdev
[0]['ifname'], params
)
1132 dev
[0].connect("osen", proto
="OSEN", key_mgmt
="OSEN", pairwise
="CCMP",
1133 group
="GTK_NOT_USED",
1134 eap
="WFA-UNAUTH-TLS", identity
="osen@example.com",
1135 ca_cert
="auth_serv/ca.pem",
1138 def test_ap_hs20_network_preference(dev
, apdev
):
1139 """Hotspot 2.0 network selection with preferred home network"""
1140 bssid
= apdev
[0]['bssid']
1141 params
= hs20_ap_params()
1142 hostapd
.add_ap(apdev
[0]['ifname'], params
)
1144 dev
[0].hs20_enable()
1145 values
= { 'realm': "example.com",
1146 'username': "hs20-test",
1147 'password': "password",
1148 'domain': "example.com" }
1149 dev
[0].add_cred_values(values
)
1151 id = dev
[0].add_network()
1152 dev
[0].set_network_quoted(id, "ssid", "home")
1153 dev
[0].set_network_quoted(id, "psk", "12345678")
1154 dev
[0].set_network(id, "priority", "1")
1155 dev
[0].request("ENABLE_NETWORK %s no-connect" % id)
1157 dev
[0].request("INTERWORKING_SELECT auto freq=2412")
1158 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=15)
1160 raise Exception("Connection timed out")
1162 raise Exception("Unexpected network selected")
1164 bssid2
= apdev
[1]['bssid']
1165 params
= hostapd
.wpa2_params(ssid
="home", passphrase
="12345678")
1166 hostapd
.add_ap(apdev
[1]['ifname'], params
)
1168 dev
[0].request("INTERWORKING_SELECT auto freq=2412")
1169 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED",
1170 "INTERWORKING-ALREADY-CONNECTED" ], timeout
=15)
1172 raise Exception("Connection timed out")
1173 if "INTERWORKING-ALREADY-CONNECTED" in ev
:
1174 raise Exception("No roam to higher priority network")
1175 if bssid2
not in ev
:
1176 raise Exception("Unexpected network selected")
1178 def test_ap_hs20_network_preference2(dev
, apdev
):
1179 """Hotspot 2.0 network selection with preferred credential"""
1180 bssid2
= apdev
[1]['bssid']
1181 params
= hostapd
.wpa2_params(ssid
="home", passphrase
="12345678")
1182 hostapd
.add_ap(apdev
[1]['ifname'], params
)
1184 dev
[0].hs20_enable()
1185 values
= { 'realm': "example.com",
1186 'username': "hs20-test",
1187 'password': "password",
1188 'domain': "example.com",
1190 dev
[0].add_cred_values(values
)
1192 id = dev
[0].add_network()
1193 dev
[0].set_network_quoted(id, "ssid", "home")
1194 dev
[0].set_network_quoted(id, "psk", "12345678")
1195 dev
[0].request("ENABLE_NETWORK %s no-connect" % id)
1197 dev
[0].request("INTERWORKING_SELECT auto freq=2412")
1198 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=15)
1200 raise Exception("Connection timed out")
1201 if bssid2
not in ev
:
1202 raise Exception("Unexpected network selected")
1204 bssid
= apdev
[0]['bssid']
1205 params
= hs20_ap_params()
1206 hostapd
.add_ap(apdev
[0]['ifname'], params
)
1208 dev
[0].request("INTERWORKING_SELECT auto freq=2412")
1209 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED",
1210 "INTERWORKING-ALREADY-CONNECTED" ], timeout
=15)
1212 raise Exception("Connection timed out")
1213 if "INTERWORKING-ALREADY-CONNECTED" in ev
:
1214 raise Exception("No roam to higher priority network")
1216 raise Exception("Unexpected network selected")