From: Nick Porter Date: Thu, 28 Jan 2021 16:28:27 +0000 (+0000) Subject: Add extra tests to rlm_attr_filter to exercise the different operators X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b7919160dd0c8a651a6376b6e134f54136d059e;p=thirdparty%2Ffreeradius-server.git Add extra tests to rlm_attr_filter to exercise the different operators --- diff --git a/src/tests/modules/attr_filter/filter b/src/tests/modules/attr_filter/filter index c6b4c363d4..443b8f50f0 100644 --- a/src/tests/modules/attr_filter/filter +++ b/src/tests/modules/attr_filter/filter @@ -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 index 0000000000..89e23a3bdf --- /dev/null +++ b/src/tests/modules/attr_filter/operators.attrs @@ -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 index 0000000000..cd636c0093 --- /dev/null +++ b/src/tests/modules/attr_filter/operators.unlang @@ -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 +}