summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorjvoisin2017-10-09 11:54:11 +0200
committerGitHub2017-10-09 11:54:11 +0200
commit7234fdbb0cb0dd45ed1d6e7814c91e596126ee25 (patch)
tree1b29ad0e25f37b55390d309fd0b7f4cd406cbb7a /src/tests
parent50bb0ed72d5c221d40f16690d980db5e7ccee46a (diff)
Implement matching on the calltrace (#17)
* Implement matching on the calltrace
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/config/config_disabled_functions_chain.ini1
-rw-r--r--src/tests/disabled_functions_chain.phpt28
-rw-r--r--src/tests/disabled_functions_chain_not_matching.phpt28
3 files changed, 57 insertions, 0 deletions
diff --git a/src/tests/config/config_disabled_functions_chain.ini b/src/tests/config/config_disabled_functions_chain.ini
new file mode 100644
index 0000000..f47af34
--- /dev/null
+++ b/src/tests/config/config_disabled_functions_chain.ini
@@ -0,0 +1 @@
sp.disable_functions.function("outer>inner").drop();
diff --git a/src/tests/disabled_functions_chain.phpt b/src/tests/disabled_functions_chain.phpt
new file mode 100644
index 0000000..b25f800
--- /dev/null
+++ b/src/tests/disabled_functions_chain.phpt
@@ -0,0 +1,28 @@
1--TEST--
2Disable functions by matching the calltrace
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_chain.ini
7--FILE--
8<?php
9
10function outer() {
11 function inner() {
12 echo "I'm in the inner function!\n";
13 }
14 echo "I'm in the outer function, before the call!\n";
15 inner();
16 echo "I'm in the outer function, after the call!\n";
17}
18
19echo "I'm before the call to outer\n";
20outer();
21echo "I'm after the call to outer\n";
22?>
23--EXPECTF--
24I'm before the call to outer
25I'm in the outer function, before the call!
26[snuffleupagus][0.0.0.0][disabled_function][drop] The call to the function 'outer>inner' in %a/disabled_functions_chain.php:%d has been disabled.
27I'm in the outer function, after the call!
28I'm after the call to outer
diff --git a/src/tests/disabled_functions_chain_not_matching.phpt b/src/tests/disabled_functions_chain_not_matching.phpt
new file mode 100644
index 0000000..3a0400a
--- /dev/null
+++ b/src/tests/disabled_functions_chain_not_matching.phpt
@@ -0,0 +1,28 @@
1--TEST--
2Disable functions by matching the calltrace
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_chain.ini
7--FILE--
8<?php
9
10function outer() {
11 function inner_() {
12 echo "I'm in the inner function!\n";
13 }
14 echo "I'm in the outer function, before the call!\n";
15 inner_();
16 echo "I'm in the outer function, after the call!\n";
17}
18
19echo "I'm before the call to outer\n";
20outer();
21echo "I'm after the call to outer\n";
22?>
23--EXPECTF--
24I'm before the call to outer
25I'm in the outer function, before the call!
26I'm in the inner function!
27I'm in the outer function, after the call!
28I'm after the call to outer