From: Terry Burton Date: Fri, 27 Mar 2020 16:46:47 +0000 (+0000) Subject: Extend module tests for rlm_files (#3341) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13674fcfda940f18825bfc13967d8d0cf0429c8f;p=thirdparty%2Ffreeradius-server.git Extend module tests for rlm_files (#3341) Test control and reply list modification operations. --- diff --git a/src/tests/modules/files/addcontrol.attrs b/src/tests/modules/files/addcontrol.attrs new file mode 100644 index 00000000000..632ce4f5a98 --- /dev/null +++ b/src/tests/modules/files/addcontrol.attrs @@ -0,0 +1,13 @@ +# +# Input packet +# +User-Name = "addcontrol" +User-Password = "testing123" + +# +# Expected answer +# +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..aa99cf5d321 --- /dev/null +++ b/src/tests/modules/files/addreply.attrs @@ -0,0 +1,12 @@ +# +# Input packet +# +User-Name = "addreply" +User-Password = "testing123" + +# +# Expected answer +# +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 543e5cac94f..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" - Reply-Message := "success" -doug Cleartext-Password := "goodbye" - Reply-Message := "success" - -famous Cleartext-Password := "bradpitt" - Fall-Through = yes -unused Cleartext-Password := "jabberwocky" - Filter-Id := "fail" - -famous - Reply-Message := "success" +# +# Basic syntax tests with comments. Parsing only. +# -user Cleartext-Password := "hello" # comment! +user Cleartext-Password := "hello" # comment! user2 # comment! - Filter-Id := "24" + Reply-Message := "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/files.attrs b/src/tests/modules/files/bob.attrs similarity index 67% rename from src/tests/modules/files/files.attrs rename to src/tests/modules/files/bob.attrs index 72439204238..7b5164b61a1 100644 --- a/src/tests/modules/files/files.attrs +++ b/src/tests/modules/files/bob.attrs @@ -1,12 +1,11 @@ # # Input packet # -User-Name = "famous" -User-Password = "bradpitt" +User-Name = "doug" +User-Password = "goodbye" # # Expected answer # 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/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..a45f94d0e6f --- /dev/null +++ b/src/tests/modules/files/filterreply.attrs @@ -0,0 +1,10 @@ +# +# Input packet +# +User-Name = "filterreply" +User-Password = "testing123" + +# +# Expected answer +# +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..409ea9c8b96 --- /dev/null +++ b/src/tests/modules/files/subreply.attrs @@ -0,0 +1,12 @@ +# +# Input packet +# +User-Name = "subreply" +User-Password = "testing123" + +# +# Expected answer +# +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