]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add extra tests to rlm_attr_filter to exercise the different operators
authorNick Porter <nick@portercomputing.co.uk>
Thu, 28 Jan 2021 16:28:27 +0000 (16:28 +0000)
committerAlan DeKok <aland@freeradius.org>
Fri, 29 Jan 2021 15:11:25 +0000 (10:11 -0500)
src/tests/modules/attr_filter/filter
src/tests/modules/attr_filter/operators.attrs [new file with mode: 0644]
src/tests/modules/attr_filter/operators.unlang [new file with mode: 0644]

index c6b4c363d4fc1ef942b45384f1e597cb5002890a..443b8f50f0c6d4ad9b60ea43b0806e0f5860d13c 100644 (file)
@@ -1,3 +1,21 @@
+operators
+       EAP-Message =* ANY,
+       State =* ANY,
+       Message-Authenticator =* ANY,
+       Error-Cause =* ANY,
+       Reply-Message =* ANY,
+       Vendor-Specific.Microsoft.CHAP-Error =* ANY,
+       Proxy-State =* ANY,
+       Error-Cause =* ANY,
+       User-Name =* ANY,
+       User-Password =* ANY,
+       NAS-Port < 99,
+       Idle-Timeout < 100,
+       Called-Station-Id == "bar",
+       Service-Type >= 5,
+       Framed-IP-Address > 192.168.0.0,
+       Calling-Station-Id <= "jim"
+
 DEFAULT
        EAP-Message =* ANY,
        State =* ANY,
diff --git a/src/tests/modules/attr_filter/operators.attrs b/src/tests/modules/attr_filter/operators.attrs
new file mode 100644 (file)
index 0000000..89e23a3
--- /dev/null
@@ -0,0 +1,24 @@
+#
+#  Input packet
+#
+Packet-Type = Access-Request
+User-Name = "operators"
+User-Password = "goodbye"
+NAS-Port = 10
+Idle-Timeout = 300
+Called-Station-Id = "foo"
+Called-Station-Id = "bar"
+Service-Type = 5
+Service-Type = 1
+Framed-IP-Address = 10.0.0.20
+Framed-IP-Address = 192.168.10.20
+Reply-Message = 'success'
+Calling-Station-Id = "bob"
+Calling-Station-Id = "jim"
+Calling-Station-Id = "ted"
+
+#
+#  Expected answer
+#
+Packet-Type == Access-Accept
+Reply-Message == 'success'
diff --git a/src/tests/modules/attr_filter/operators.unlang b/src/tests/modules/attr_filter/operators.unlang
new file mode 100644 (file)
index 0000000..cd636c0
--- /dev/null
@@ -0,0 +1,33 @@
+attr_filter
+
+if ((!&NAS-Port) || (&NAS-Port != 10)) {
+        test_fail
+}
+
+if (&Idle-Timeout) {
+        test_fail
+}
+
+if ((&Called-Station-Id != "bar") || (&Called-Station-Id[1])) {
+        test_fail
+}
+
+if ((&Service-Type != 5) || (&Service-Type[1])) {
+        test_fail
+}
+
+if ((&Framed-IP-Address != 192.168.10.20) || (&Framed-IP-Address[1])) {
+        test_fail
+}
+
+if ((&Calling-Station-Id != "bob") || (&Calling-Station-Id[1] != "jim") || (&Calling-Station-Id[2])) {
+        test_fail
+}
+
+update control {
+       &Password.Cleartext := "goodbye"
+}
+
+update reply {
+        &Reply-Message := &request.Reply-Message
+}