]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: RADIUS Accounting local failure cases
authorJouni Malinen <j@w1.fi>
Sun, 5 Feb 2017 15:11:29 +0000 (17:11 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 5 Feb 2017 15:19:44 +0000 (17:19 +0200)
Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/test_radius.py

index e47e3e0fd382db67398aaac7e06f4b4b1c6a8488..d62851077b6d734182307fd5614281212c7f3e68 100644 (file)
@@ -18,7 +18,7 @@ import threading
 import time
 
 import hostapd
-from utils import HwsimSkip, require_under_vm, skip_with_fips, fail_test
+from utils import HwsimSkip, require_under_vm, skip_with_fips, alloc_fail, fail_test, wait_fail_trigger
 from test_ap_hs20 import build_dhcp_ack
 from test_ap_ft import ft_params1
 
@@ -1421,3 +1421,50 @@ def test_radius_mppe_failure(dev, apdev):
                        wait_connect=False, scan_freq="2412")
         dev[0].wait_disconnected()
         dev[0].request("REMOVE_NETWORK all")
+
+def test_radius_acct_failure(dev, apdev):
+    """RADIUS Accounting and failure to add attributes"""
+    # Connection goes through, but Accounting-Request cannot be sent out due to
+    # NAS-Identifier being too long to fit into a RADIUS attribute.
+    params = { "ssid": "radius-acct-open",
+               'acct_server_addr': "127.0.0.1",
+               'acct_server_port': "1813",
+               'acct_server_shared_secret': "radius",
+               'nas_identifier': 255*'A' }
+    hapd = hostapd.add_ap(apdev[0], params)
+    dev[0].connect("radius-acct-open", key_mgmt="NONE", scan_freq="2412")
+
+def test_radius_acct_failure_oom(dev, apdev):
+    """RADIUS Accounting and failure to add attributes due to OOM"""
+    params = { "ssid": "radius-acct-open",
+               'acct_server_addr': "127.0.0.1",
+               'acct_server_port': "1813",
+               'acct_server_shared_secret': "radius",
+               'radius_acct_interim_interval': "1",
+               'nas_identifier': 250*'A',
+               'radius_acct_req_attr': [ "126:s:" + 250*'B',
+                                         "77:s:" + 250*'C',
+                                         "127:s:" + 250*'D',
+                                         "181:s:" + 250*'E' ] }
+    hapd = hostapd.add_ap(apdev[0], params)
+
+    with alloc_fail(hapd, 1, "radius_msg_add_attr;=accounting_msg"):
+        dev[0].connect("radius-acct-open", key_mgmt="NONE", scan_freq="2412")
+        wait_fail_trigger(hapd, "GET_ALLOC_FAIL")
+
+    with alloc_fail(hapd, 1, "accounting_sta_report"):
+        dev[1].connect("radius-acct-open", key_mgmt="NONE", scan_freq="2412")
+        wait_fail_trigger(hapd, "GET_ALLOC_FAIL")
+
+def test_radius_acct_failure_sta_data(dev, apdev):
+    """RADIUS Accounting and failure to get STA data"""
+    params = { "ssid": "radius-acct-open",
+               'acct_server_addr': "127.0.0.1",
+               'acct_server_port': "1813",
+               'acct_server_shared_secret': "radius" }
+    hapd = hostapd.add_ap(apdev[0], params)
+
+    with fail_test(hapd, 1, "accounting_sta_update_stats"):
+        dev[0].connect("radius-acct-open", key_mgmt="NONE", scan_freq="2412")
+        dev[0].request("DISCONNECT")
+        dev[0].wait_disconnected()