From 5ff53fd6dd3743b60f64a25412029222f1a6fe29 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 1 Mar 2015 18:38:47 +0200 Subject: [PATCH] tests: RADIUS failover and failed attempt to return to primary server Signed-off-by: Jouni Malinen --- tests/hwsim/test_radius.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/hwsim/test_radius.py b/tests/hwsim/test_radius.py index 63b15c71e..d55fe0618 100644 --- a/tests/hwsim/test_radius.py +++ b/tests/hwsim/test_radius.py @@ -1,5 +1,5 @@ # RADIUS tests -# Copyright (c) 2013-2014, Jouni Malinen +# Copyright (c) 2013-2015, Jouni Malinen # # This software may be distributed under the terms of the BSD license. # See README for more details. @@ -8,6 +8,7 @@ import hashlib import hmac import logging logger = logging.getLogger() +import os import select import struct import subprocess @@ -692,6 +693,7 @@ def test_radius_failover(dev, apdev): params['acct_server_addr'] = "192.168.213.17" params['acct_server_port'] = "1813" params['acct_server_shared_secret'] = "testing" + params['radius_retry_primary_interval'] = "20" hapd = hostapd.add_ap(apdev[0]['ifname'], params, no_enable=True) hapd.set("auth_server_addr", "127.0.0.1") hapd.set("auth_server_port", "1812") @@ -705,12 +707,13 @@ def test_radius_failover(dev, apdev): raise Exception("AP startup timed out") if "AP-ENABLED" not in ev: raise Exception("AP startup failed") + start = os.times()[4] try: subprocess.call(['ip', 'ro', 'replace', 'prohibit', '192.168.213.17']) dev[0].request("SET EAPOL::authPeriod 5") connect(dev[0], "radius-failover", wait_connect=False) - dev[0].wait_connected(timeout=60) + dev[0].wait_connected(timeout=20) finally: dev[0].request("SET EAPOL::authPeriod 30") subprocess.call(['ip', 'ro', 'del', '192.168.213.17']) @@ -721,6 +724,18 @@ def test_radius_failover(dev, apdev): if req_e <= req_s: raise Exception("Unexpected RADIUS server acct MIB value") + end = os.times()[4] + try: + subprocess.call(['ip', 'ro', 'replace', 'prohibit', '192.168.213.17']) + dev[1].request("SET EAPOL::authPeriod 5") + if end - start < 21: + time.sleep(21 - (end - start)) + connect(dev[1], "radius-failover", wait_connect=False) + dev[1].wait_connected(timeout=20) + finally: + dev[1].request("SET EAPOL::authPeriod 30") + subprocess.call(['ip', 'ro', 'del', '192.168.213.17']) + def run_pyrad_server(srv, t_events): srv.RunWithStop(t_events)