Browse Source

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 <j@w1.fi>
Jouni Malinen 10 years ago
parent
commit
6a188ba3fc
1 changed files with 43 additions and 0 deletions
  1. 43 0
      tests/hwsim/test_radius.py

+ 43 - 0
tests/hwsim/test_radius.py

@@ -6,6 +6,7 @@
 
 
 import logging
 import logging
 logger = logging.getLogger()
 logger = logging.getLogger()
+import subprocess
 import time
 import time
 
 
 import hostapd
 import hostapd
@@ -36,6 +37,28 @@ def test_radius_auth_unreachable(dev, apdev):
     if int(mib["radiusAuthClientPendingRequests"]) < 1:
     if int(mib["radiusAuthClientPendingRequests"]) < 1:
         raise Exception("Missing pending RADIUS Authentication request")
         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):
 def test_radius_acct_unreachable(dev, apdev):
     """RADIUS Accounting server unreachable"""
     """RADIUS Accounting server unreachable"""
     params = hostapd.wpa2_eap_params(ssid="radius-acct")
     params = hostapd.wpa2_eap_params(ssid="radius-acct")
@@ -55,6 +78,26 @@ def test_radius_acct_unreachable(dev, apdev):
     if int(mib["radiusAccClientPendingRequests"]) < 2:
     if int(mib["radiusAccClientPendingRequests"]) < 2:
         raise Exception("Missing pending RADIUS Accounting requests")
         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):
 def test_radius_acct(dev, apdev):
     """RADIUS Accounting"""
     """RADIUS Accounting"""
     as_hapd = hostapd.Hostapd("as")
     as_hapd = hostapd.Hostapd("as")