From: Terry Burton Date: Fri, 27 Mar 2020 16:46:31 +0000 (+0000) Subject: Extend module tests for rlm_files (#3342) X-Git-Tag: release_3_0_22~628 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c954db8ecb2c864523bbfa6eb47475f78cb64167;p=thirdparty%2Ffreeradius-server.git Extend module tests for rlm_files (#3342) Test control and reply list modification operations. Align with v4 by using Reply-Message rather than Filter-Id. --- diff --git a/src/tests/modules/files/addcontrol.attrs b/src/tests/modules/files/addcontrol.attrs new file mode 100644 index 00000000000..7588b9c7e27 --- /dev/null +++ b/src/tests/modules/files/addcontrol.attrs @@ -0,0 +1,13 @@ +# +# Input packet +# +User-Name = "addcontrol" +User-Password = "testing123" + +# +# Expected answer +# +Response-Packet-Type == Access-Accept +Cleartext-Password == 'testing123' +Reply-Message == "success1" +Reply-Message == "success2" diff --git a/src/tests/modules/files/addcontrol.unlang b/src/tests/modules/files/addcontrol.unlang new file mode 100644 index 00000000000..8d8620d9351 --- /dev/null +++ b/src/tests/modules/files/addcontrol.unlang @@ -0,0 +1,8 @@ +# +# PRE: files +# +files + +update { + &reply: += &control:[*] +} diff --git a/src/tests/modules/files/addreply.attrs b/src/tests/modules/files/addreply.attrs new file mode 100644 index 00000000000..69e1a19b021 --- /dev/null +++ b/src/tests/modules/files/addreply.attrs @@ -0,0 +1,12 @@ +# +# Input packet +# +User-Name = "addreply" +User-Password = "testing123" + +# +# Expected answer +# +Response-Packet-Type == Access-Accept +Reply-Message == 'success1' +Reply-Message == 'success2' diff --git a/src/tests/modules/files/addreply.unlang b/src/tests/modules/files/addreply.unlang new file mode 100644 index 00000000000..7ddaaf5e26f --- /dev/null +++ b/src/tests/modules/files/addreply.unlang @@ -0,0 +1,4 @@ +# +# PRE: files +# +files diff --git a/src/tests/modules/files/authorize b/src/tests/modules/files/authorize index 51dbdd73aac..b85f6a2a49a 100644 --- a/src/tests/modules/files/authorize +++ b/src/tests/modules/files/authorize @@ -1,23 +1,92 @@ # # Test if the "users" file works # -bob Cleartext-Password := "hello" - Filter-Id := "success" -doug Cleartext-Password := "goodbye" - Filter-Id := "success" -famous Cleartext-Password := "bradpitt" - Fall-Through = yes +# +# Basic syntax tests with comments. Parsing only. +# -unused Cleartext-Password := "jabberwocky" - Filter-Id := "fail" +user Cleartext-Password := "hello" # comment! -famous - Filter-Id := "success" -user Cleartext-Password := "hello" # comment! +user2 # comment! + Reply-Message := "24" -user2 # comment! - Filter-Id := "24" +# +# Setting ":=" of reply and control items +# + +bob Cleartext-Password := "hello" + Reply-Message := "success" + + +# +# Detect erroneous Fall-Through +# + +doug Cleartext-Password := "goodbye" + Reply-Message := "success" + +doug + Reply-Message := "unreachable" + + +# +# Fall-Through across a non-matching entry +# + +famous Cleartext-Password := "bradpitt" + Fall-Through = yes + +unused Cleartext-Password := "jabberwocky" + Reply-Message := "fail" + +famous + Reply-Message := "success" + + +# +# Modification of the reply list +# + +addreply Cleartext-Password := "testing123" + Reply-Message := "success1", + Fall-Through = yes + +addreply + Reply-Message += "success2" + + +subreply Cleartext-Password := "testing123" + Reply-Message := "success1", + Reply-Message += "success2", + Reply-Message += "success3", + Fall-Through = yes + +subreply Cleartext-Password := "testing123" + Reply-Message -= "success2" + + +filterreply Cleartext-Password := "testing123" + Reply-Message := "success1", + Reply-Message += "success2", + Fall-Through = yes + +filterreply Cleartext-Password := "testing123" + Reply-Message !* ANY + + +# +# Addition "+=" to the control list +# +# Note: Set ":=" of control items is already tested with Cleartext-Password +# Note: Filtering "!*" does not apply to control items as this would overload +# the operator syntax since "!*" checks that no such attribute in the +# request. + +addcontrol Cleartext-Password := "testing123", Reply-Message := "success1" + Fall-Through = yes + +addcontrol Reply-Message += "success2" diff --git a/src/tests/modules/files/bob.attrs b/src/tests/modules/files/bob.attrs new file mode 100644 index 00000000000..a4acfab62a1 --- /dev/null +++ b/src/tests/modules/files/bob.attrs @@ -0,0 +1,11 @@ +# +# Input packet +# +User-Name = "doug" +User-Password = "goodbye" + +# +# Expected answer +# +Response-Packet-Type == Access-Accept +Reply-Message == 'success' diff --git a/src/tests/modules/files/bob.unlang b/src/tests/modules/files/bob.unlang new file mode 100644 index 00000000000..7ddaaf5e26f --- /dev/null +++ b/src/tests/modules/files/bob.unlang @@ -0,0 +1,4 @@ +# +# PRE: files +# +files diff --git a/src/tests/modules/files/doug.attrs b/src/tests/modules/files/doug.attrs index 116921cc1ad..a4acfab62a1 100644 --- a/src/tests/modules/files/doug.attrs +++ b/src/tests/modules/files/doug.attrs @@ -8,4 +8,4 @@ User-Password = "goodbye" # Expected answer # Response-Packet-Type == Access-Accept -Filter-Id == 'success' +Reply-Message == 'success' diff --git a/src/tests/modules/files/fall-through.attrs b/src/tests/modules/files/fall-through.attrs index 47881bd6149..899d3d9b213 100644 --- a/src/tests/modules/files/fall-through.attrs +++ b/src/tests/modules/files/fall-through.attrs @@ -8,4 +8,4 @@ User-Password = "bradpitt" # Expected answer # Response-Packet-Type == Access-Accept -Filter-Id == 'success' +Reply-Message == 'success' diff --git a/src/tests/modules/files/files.unlang b/src/tests/modules/files/files.unlang deleted file mode 100644 index 456c666dbc1..00000000000 --- a/src/tests/modules/files/files.unlang +++ /dev/null @@ -1,4 +0,0 @@ -# -# Run the "files" module -# -files diff --git a/src/tests/modules/files/filterreply.attrs b/src/tests/modules/files/filterreply.attrs new file mode 100644 index 00000000000..c1add298623 --- /dev/null +++ b/src/tests/modules/files/filterreply.attrs @@ -0,0 +1,10 @@ +# +# Input packet +# +User-Name = "filterreply" +User-Password = "testing123" + +# +# Expected answer +# +Response-Packet-Type == Access-Accept diff --git a/src/tests/modules/files/filterreply.unlang b/src/tests/modules/files/filterreply.unlang new file mode 100644 index 00000000000..7ddaaf5e26f --- /dev/null +++ b/src/tests/modules/files/filterreply.unlang @@ -0,0 +1,4 @@ +# +# PRE: files +# +files diff --git a/src/tests/modules/files/subreply.attrs b/src/tests/modules/files/subreply.attrs new file mode 100644 index 00000000000..6fe62375009 --- /dev/null +++ b/src/tests/modules/files/subreply.attrs @@ -0,0 +1,12 @@ +# +# Input packet +# +User-Name = "subreply" +User-Password = "testing123" + +# +# Expected answer +# +Response-Packet-Type == Access-Accept +Reply-Message == 'success1' +Reply-Message == 'success3' diff --git a/src/tests/modules/files/subreply.unlang b/src/tests/modules/files/subreply.unlang new file mode 100644 index 00000000000..7ddaaf5e26f --- /dev/null +++ b/src/tests/modules/files/subreply.unlang @@ -0,0 +1,4 @@ +# +# PRE: files +# +files