From 6a188ba3fc2b0f974419b35ae2f627932fcd8b02 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 30 May 2014 16:38:40 +0300 Subject: [PATCH] tests: RADIUS server unreachable with error handling radius_{auth,acct}_unreachable tested some parts of RADIUS client code error handling. However, they did not test everything since the send() calls for unreachable port on localhost did not return an error (that error was reported on receive side). Extend this with similar test cases using unreachable IP address to get send() error returns covered as well. Signed-off-by: Jouni Malinen --- tests/hwsim/test_radius.py | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/hwsim/test_radius.py b/tests/hwsim/test_radius.py index d13f721a6..8d4194743 100644 --- a/tests/hwsim/test_radius.py +++ b/tests/hwsim/test_radius.py @@ -6,6 +6,7 @@ import logging logger = logging.getLogger() +import subprocess import time import hostapd @@ -36,6 +37,28 @@ def test_radius_auth_unreachable(dev, apdev): if int(mib["radiusAuthClientPendingRequests"]) < 1: raise Exception("Missing pending RADIUS Authentication request") +def test_radius_auth_unreachable2(dev, apdev): + """RADIUS Authentication server unreachable (2)""" + subprocess.call(['sudo', 'ip', 'ro', 'replace', '192.168.213.17', 'dev', + 'lo']) + params = hostapd.wpa2_eap_params(ssid="radius-auth") + params['auth_server_addr'] = "192.168.213.17" + params['auth_server_port'] = "18139" + hostapd.add_ap(apdev[0]['ifname'], params) + hapd = hostapd.Hostapd(apdev[0]['ifname']) + subprocess.call(['sudo', 'ip', 'ro', 'del', '192.168.213.17', 'dev', 'lo']) + connect(dev[0], "radius-auth", wait_connect=False) + ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"]) + if ev is None: + raise Exception("Timeout on EAP start") + logger.info("Checking for RADIUS retries") + time.sleep(4) + mib = hapd.get_mib() + if "radiusAuthClientAccessRequests" not in mib: + raise Exception("Missing MIB fields") + if int(mib["radiusAuthClientAccessRetransmissions"]) < 1: + raise Exception("Missing RADIUS Authentication retransmission") + def test_radius_acct_unreachable(dev, apdev): """RADIUS Accounting server unreachable""" params = hostapd.wpa2_eap_params(ssid="radius-acct") @@ -55,6 +78,26 @@ def test_radius_acct_unreachable(dev, apdev): if int(mib["radiusAccClientPendingRequests"]) < 2: raise Exception("Missing pending RADIUS Accounting requests") +def test_radius_acct_unreachable2(dev, apdev): + """RADIUS Accounting server unreachable(2)""" + subprocess.call(['sudo', 'ip', 'ro', 'replace', '192.168.213.17', 'dev', + 'lo']) + params = hostapd.wpa2_eap_params(ssid="radius-acct") + params['acct_server_addr'] = "192.168.213.17" + params['acct_server_port'] = "18139" + params['acct_server_shared_secret'] = "radius" + hostapd.add_ap(apdev[0]['ifname'], params) + hapd = hostapd.Hostapd(apdev[0]['ifname']) + subprocess.call(['sudo', 'ip', 'ro', 'del', '192.168.213.17', 'dev', 'lo']) + connect(dev[0], "radius-acct") + logger.info("Checking for RADIUS retries") + time.sleep(4) + mib = hapd.get_mib() + if "radiusAccClientRetransmissions" not in mib: + raise Exception("Missing MIB fields") + if int(mib["radiusAccClientRetransmissions"]) < 1 and int(mib["radiusAccClientPendingRequests"]) < 1: + raise Exception("Missing pending or retransmitted RADIUS Accounting requests") + def test_radius_acct(dev, apdev): """RADIUS Accounting""" as_hapd = hostapd.Hostapd("as")