]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add tests for exec
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 25 Nov 2016 22:35:38 +0000 (17:35 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 25 Nov 2016 22:35:38 +0000 (17:35 -0500)
src/tests/modules/exec/all.mk [new file with mode: 0644]
src/tests/modules/exec/async.attrs [new file with mode: 0644]
src/tests/modules/exec/async.unlang [new file with mode: 0644]
src/tests/modules/exec/backticks_list.attrs [new file with mode: 0644]
src/tests/modules/exec/backticks_list.unlang [new file with mode: 0644]
src/tests/modules/exec/module.conf [new file with mode: 0644]
src/tests/modules/exec/sync.attrs [new file with mode: 0644]
src/tests/modules/exec/sync.unlang [new file with mode: 0644]

diff --git a/src/tests/modules/exec/all.mk b/src/tests/modules/exec/all.mk
new file mode 100644 (file)
index 0000000..07449db
--- /dev/null
@@ -0,0 +1,3 @@
+#
+#  Test the "files" module
+#
diff --git a/src/tests/modules/exec/async.attrs b/src/tests/modules/exec/async.attrs
new file mode 100644 (file)
index 0000000..a6ad21a
--- /dev/null
@@ -0,0 +1,10 @@
+#
+#  Input packet
+#
+User-Name = "fivel"
+User-Password = "mousekewitz"
+
+#
+#  Expected answer
+#
+Response-Packet-Type == Access-Accept
\ No newline at end of file
diff --git a/src/tests/modules/exec/async.unlang b/src/tests/modules/exec/async.unlang
new file mode 100644 (file)
index 0000000..9e021dc
--- /dev/null
@@ -0,0 +1,25 @@
+#
+#  Async calls should always return a zero length string
+#  because we don't wait for the response.
+#
+update request {
+       Tmp-String-0 := "%{exec_async:/bin/bash -c 'echo hello'}"
+}
+if (&Tmp-String-0 != '') {
+       test_fail
+} else {
+       test_pass
+}
+
+#
+#  Async calls should not have their output added to the request
+#
+update request {
+       Tmp-String-0 := "%{exec_async:/bin/bash -c \"echo 'reply:Reply-Message = \'hello\''\"}"
+}
+
+if (&reply:Reply-Message == 'hello') {
+       test_fail
+} else {
+       test_pass
+}
\ No newline at end of file
diff --git a/src/tests/modules/exec/backticks_list.attrs b/src/tests/modules/exec/backticks_list.attrs
new file mode 100644 (file)
index 0000000..8003796
--- /dev/null
@@ -0,0 +1,10 @@
+#
+#  Input packet
+#
+User-Name = "tony"
+User-Password = "taponi"
+
+#
+#  Expected answer
+#
+Response-Packet-Type == Access-Accept
\ No newline at end of file
diff --git a/src/tests/modules/exec/backticks_list.unlang b/src/tests/modules/exec/backticks_list.unlang
new file mode 100644 (file)
index 0000000..8e83699
--- /dev/null
@@ -0,0 +1,25 @@
+#
+#  Sync calls should always return a zero length string
+#  because we don't wait for the response.
+#
+update request {
+       &Tmp-String-0 := `/bin/bash -c 'echo hello'`
+}
+if (&Tmp-String-0 != 'hello') {
+       test_fail
+} else {
+       test_pass
+}
+
+#
+#  Test default list override
+#
+#update request {
+#      control: += `/bin/bash -c "echo reply:Reply-Message = \'hello\'"`
+#}
+
+#if (&reply:Reply-Message != 'hello') {
+#      test_fail
+#} else {
+#      test_pass
+#}
diff --git a/src/tests/modules/exec/module.conf b/src/tests/modules/exec/module.conf
new file mode 100644 (file)
index 0000000..56a255c
--- /dev/null
@@ -0,0 +1,14 @@
+exec exec_async {
+       wait = no
+       input_pairs = request
+       shell_escape = yes
+       timeout = 10
+}
+
+exec exec_sync {
+       wait = yes
+       input_pairs = control
+       shell_escape = yes
+       timeout = 10
+}
+
diff --git a/src/tests/modules/exec/sync.attrs b/src/tests/modules/exec/sync.attrs
new file mode 100644 (file)
index 0000000..8003796
--- /dev/null
@@ -0,0 +1,10 @@
+#
+#  Input packet
+#
+User-Name = "tony"
+User-Password = "taponi"
+
+#
+#  Expected answer
+#
+Response-Packet-Type == Access-Accept
\ No newline at end of file
diff --git a/src/tests/modules/exec/sync.unlang b/src/tests/modules/exec/sync.unlang
new file mode 100644 (file)
index 0000000..55bbfcc
--- /dev/null
@@ -0,0 +1,25 @@
+#
+#  Sync calls should always return a zero length string
+#  because we don't wait for the response.
+#
+update request {
+       &Tmp-String-0 := "%{exec_sync:/bin/bash -c 'echo hello'}"
+}
+if (&Tmp-String-0 != 'hello') {
+       test_fail
+} else {
+       test_pass
+}
+
+#
+#  Sync calls should have their output added to the request
+#
+update request {
+       &Tmp-String-0 := "%{exec_sync:/bin/bash -c 'echo \"reply:Reply-Message = \'hello\'\"'}"
+}
+
+if (&reply:Reply-Message != 'hello') {
+       test_fail
+} else {
+       test_pass
+}