tests: ERP/FILS with external hostapd process as RADIUS server

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2019-04-06 16:47:38 +03:00
parent 3d93e26e66
commit 78ed42d8a2
3 changed files with 91 additions and 0 deletions

View file

@ -38,6 +38,8 @@
"erp-ttls" TTLS "erp-ttls" TTLS
"erp-ttls" TTLS-PAP "password" [2] "erp-ttls" TTLS-PAP "password" [2]
"erp-ikev2@example.com" IKEV2 "password" "erp-ikev2@example.com" IKEV2 "password"
"psk@erp.example.com" PSK 0123456789abcdef0123456789abcdef
"pwd@erp.example.com" PWD "secret password"
"vlan1" PAX 0123456789abcdef0123456789abcdef "vlan1" PAX 0123456789abcdef0123456789abcdef
radius_accept_attr=64:d:13 radius_accept_attr=64:d:13

View file

@ -156,6 +156,45 @@ def test_erp_radius(dev, apdev):
raise Exception("Did not use ERP") raise Exception("Did not use ERP")
dev[0].wait_connected(timeout=15, error="Reconnection timed out") dev[0].wait_connected(timeout=15, error="Reconnection timed out")
def test_erp_radius_ext(dev, apdev):
"""ERP enabled on a separate RADIUS server and peer"""
as_hapd = hostapd.Hostapd("as")
try:
as_hapd.disable()
as_hapd.set("eap_server_erp", "1")
as_hapd.set("erp_domain", "erp.example.com")
as_hapd.enable()
run_erp_radius_ext(dev, apdev)
finally:
as_hapd.disable()
as_hapd.set("eap_server_erp", "0")
as_hapd.set("erp_domain", "")
as_hapd.enable()
def run_erp_radius_ext(dev, apdev):
check_erp_capa(dev[0])
params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap")
params['erp_send_reauth_start'] = '1'
params['erp_domain'] = 'erp.example.com'
params['disable_pmksa_caching'] = '1'
hapd = hostapd.add_ap(apdev[0], params)
dev[0].request("ERP_FLUSH")
dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP",
eap="PSK", identity="psk@erp.example.com",
password_hex="0123456789abcdef0123456789abcdef",
erp="1", scan_freq="2412")
for i in range(3):
dev[0].request("DISCONNECT")
dev[0].wait_disconnected(timeout=15)
dev[0].request("RECONNECT")
ev = dev[0].wait_event(["CTRL-EVENT-EAP-SUCCESS"], timeout=15)
if ev is None:
raise Exception("EAP success timed out")
if "EAP re-authentication completed successfully" not in ev:
raise Exception("Did not use ERP")
dev[0].wait_connected(timeout=15, error="Reconnection timed out")
def erp_test(dev, hapd, **kwargs): def erp_test(dev, hapd, **kwargs):
res = dev.get_capability("eap") res = dev.get_capability("eap")
if kwargs['eap'] not in res: if kwargs['eap'] not in res:

View file

@ -2100,3 +2100,53 @@ def test_fils_sk_erp_server_flush(dev, apdev, params):
raise Exception("Association failed with new ERP keys") raise Exception("Association failed with new ERP keys")
if "CTRL-EVENT-EAP-STARTED" in ev: if "CTRL-EVENT-EAP-STARTED" in ev:
raise Exception("Unexpected EAP exchange") raise Exception("Unexpected EAP exchange")
def test_fils_sk_erp_radius_ext(dev, apdev, params):
"""FILS SK using ERP and external RADIUS server"""
as_hapd = hostapd.Hostapd("as")
try:
as_hapd.disable()
as_hapd.set("eap_server_erp", "1")
as_hapd.set("erp_domain", "erp.example.com")
as_hapd.enable()
run_fils_sk_erp_radius_ext(dev, apdev, params)
finally:
as_hapd.disable()
as_hapd.set("eap_server_erp", "0")
as_hapd.set("erp_domain", "")
as_hapd.enable()
def run_fils_sk_erp_radius_ext(dev, apdev, params):
check_fils_capa(dev[0])
check_erp_capa(dev[0])
bssid = apdev[0]['bssid']
params = hostapd.wpa2_eap_params(ssid="fils")
params['wpa_key_mgmt'] = "FILS-SHA256"
params['erp_domain'] = 'erp.example.com'
params['fils_realm'] = 'erp.example.com'
params['disable_pmksa_caching'] = '1'
hapd = hostapd.add_ap(apdev[0]['ifname'], params)
dev[0].scan_for_bss(bssid, freq=2412)
dev[0].request("ERP_FLUSH")
id = dev[0].connect("fils", key_mgmt="FILS-SHA256",
eap="PWD", identity="pwd@erp.example.com",
password="secret password",
erp="1", scan_freq="2412")
dev[0].request("DISCONNECT")
dev[0].wait_disconnected()
dev[0].dump_monitor()
dev[0].select_network(id, freq=2412)
ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
"EVENT-ASSOC-REJECT",
"CTRL-EVENT-CONNECTED"], timeout=10)
if ev is None:
raise Exception("Connection using FILS/ERP timed out")
if "CTRL-EVENT-EAP-STARTED" in ev:
raise Exception("Unexpected EAP exchange")
if "EVENT-ASSOC-REJECT" in ev:
raise Exception("Association failed")
hwsim_utils.test_connectivity(dev[0], hapd)