]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Extend module tests for rlm_files (#3341)
authorTerry Burton <tez@terryburton.co.uk>
Fri, 27 Mar 2020 16:46:47 +0000 (16:46 +0000)
committerGitHub <noreply@github.com>
Fri, 27 Mar 2020 16:46:47 +0000 (10:46 -0600)
Test control and reply list modification operations.

12 files changed:
src/tests/modules/files/addcontrol.attrs [new file with mode: 0644]
src/tests/modules/files/addcontrol.unlang [new file with mode: 0644]
src/tests/modules/files/addreply.attrs [new file with mode: 0644]
src/tests/modules/files/addreply.unlang [new file with mode: 0644]
src/tests/modules/files/authorize
src/tests/modules/files/bob.attrs [moved from src/tests/modules/files/files.attrs with 67% similarity]
src/tests/modules/files/bob.unlang [new file with mode: 0644]
src/tests/modules/files/files.unlang [deleted file]
src/tests/modules/files/filterreply.attrs [new file with mode: 0644]
src/tests/modules/files/filterreply.unlang [new file with mode: 0644]
src/tests/modules/files/subreply.attrs [new file with mode: 0644]
src/tests/modules/files/subreply.unlang [new file with mode: 0644]

diff --git a/src/tests/modules/files/addcontrol.attrs b/src/tests/modules/files/addcontrol.attrs
new file mode 100644 (file)
index 0000000..632ce4f
--- /dev/null
@@ -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 (file)
index 0000000..8d8620d
--- /dev/null
@@ -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 (file)
index 0000000..aa99cf5
--- /dev/null
@@ -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 (file)
index 0000000..7ddaaf5
--- /dev/null
@@ -0,0 +1,4 @@
+#
+#  PRE: files
+#
+files
index 543e5cac94f48e298cfdda47cb91456c4168da3d..b85f6a2a49a34ab56b0f0c42b75b1a9e7aec5579 100644 (file)
@@ -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"
similarity index 67%
rename from src/tests/modules/files/files.attrs
rename to src/tests/modules/files/bob.attrs
index 72439204238071a7ce8f9c5f56a46edf7bada5d1..7b5164b61a102dd15a5eab91a21681a670dcfa5f 100644 (file)
@@ -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 (file)
index 0000000..7ddaaf5
--- /dev/null
@@ -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 (file)
index 456c666..0000000
+++ /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 (file)
index 0000000..a45f94d
--- /dev/null
@@ -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 (file)
index 0000000..7ddaaf5
--- /dev/null
@@ -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 (file)
index 0000000..409ea9c
--- /dev/null
@@ -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 (file)
index 0000000..7ddaaf5
--- /dev/null
@@ -0,0 +1,4 @@
+#
+#  PRE: files
+#
+files