From: Arran Cudbard-Bell Date: Fri, 25 Nov 2016 22:35:38 +0000 (-0500) Subject: Add tests for exec X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef61fbaef4087d39bc53af0b2c331de5f04080e9;p=thirdparty%2Ffreeradius-server.git Add tests for exec --- diff --git a/src/tests/modules/exec/all.mk b/src/tests/modules/exec/all.mk new file mode 100644 index 00000000000..07449dba654 --- /dev/null +++ b/src/tests/modules/exec/all.mk @@ -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 index 00000000000..a6ad21a9425 --- /dev/null +++ b/src/tests/modules/exec/async.attrs @@ -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 index 00000000000..9e021dc5947 --- /dev/null +++ b/src/tests/modules/exec/async.unlang @@ -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 index 00000000000..80037968e14 --- /dev/null +++ b/src/tests/modules/exec/backticks_list.attrs @@ -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 index 00000000000..8e8369940a0 --- /dev/null +++ b/src/tests/modules/exec/backticks_list.unlang @@ -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 index 00000000000..56a255cac71 --- /dev/null +++ b/src/tests/modules/exec/module.conf @@ -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 index 00000000000..80037968e14 --- /dev/null +++ b/src/tests/modules/exec/sync.attrs @@ -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 index 00000000000..55bbfcc709a --- /dev/null +++ b/src/tests/modules/exec/sync.unlang @@ -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 +}