summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorjvoisin2017-10-27 17:22:35 +0200
committerjvoisin2017-10-27 17:22:35 +0200
commit9a0400bdbc7d4decb32fe8fa3960e9e77f9fe898 (patch)
treea27a8b5569226a4586b60876b123edc91054e9e4 /src/tests
parent70498a7cce831049b47051813b850665c5547927 (diff)
Bump the coverage
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/config/config_disabled_functions_ret_right_hash.ini2
-rw-r--r--src/tests/config/config_encrypted_cookies_empty_env.ini2
-rw-r--r--src/tests/disabled_functions_param_array.phpt16
-rw-r--r--src/tests/disabled_functions_param_array_deref.phpt25
-rw-r--r--src/tests/disabled_functions_param_array_no_value.phpt22
-rw-r--r--src/tests/disabled_functions_param_array_several_levels.phpt20
-rw-r--r--src/tests/disabled_functions_ret_right_hash.phpt1
-rw-r--r--src/tests/encrypt_cookies_empty_env.phpt19
8 files changed, 103 insertions, 4 deletions
diff --git a/src/tests/config/config_disabled_functions_ret_right_hash.ini b/src/tests/config/config_disabled_functions_ret_right_hash.ini
index 8ec8f83..af4fdd4 100644
--- a/src/tests/config/config_disabled_functions_ret_right_hash.ini
+++ b/src/tests/config/config_disabled_functions_ret_right_hash.ini
@@ -1,4 +1,4 @@
1sp.disable_function.function("system").ret("1").drop(); 1sp.disable_function.function("system").ret("1").drop();
2sp.disable_function.function("system").ret("1337").hash("123456789597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop(); 2sp.disable_function.function("system").ret("1337").hash("123456789597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop();
3sp.disable_function.function("system").ret("1338").hash("522a976fa597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop(); 3sp.disable_function.function("system").ret("1338").hash("522a976fa597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop();
4sp.disable_function.function("system").ret("1337").hash("522a976fa597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop(); 4sp.disable_function.function("system").ret("1337").hash("d259c3ad8cf096272cd0e78768af3b11325f498de5c2c36f40adc43643af378a").drop();
diff --git a/src/tests/config/config_encrypted_cookies_empty_env.ini b/src/tests/config/config_encrypted_cookies_empty_env.ini
new file mode 100644
index 0000000..ac1f840
--- /dev/null
+++ b/src/tests/config/config_encrypted_cookies_empty_env.ini
@@ -0,0 +1,2 @@
1sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR");
2sp.cookie_encryption.cookie("super_cookie");
diff --git a/src/tests/disabled_functions_param_array.phpt b/src/tests/disabled_functions_param_array.phpt
index 4738745..8fb75e1 100644
--- a/src/tests/disabled_functions_param_array.phpt
+++ b/src/tests/disabled_functions_param_array.phpt
@@ -11,21 +11,31 @@ function foo($arr) {
11} 11}
12$a=Array("a"=>"test1"); 12$a=Array("a"=>"test1");
13foo($a); 13foo($a);
14$a=Array("a"=>"abcd"); 14
15foo($a);
16$a=Array("a"=>"abcde"); 15$a=Array("a"=>"abcde");
17foo($a); 16foo($a);
17
18$a=Array("a"=>"abcd");
19foo($a);
20/*
21
18$a=Array("bla"=>"abcdef"); 22$a=Array("bla"=>"abcdef");
19foo($a); 23foo($a);
24
20$a=Array("bla"=>"aaa", "a"=>"eee" ); 25$a=Array("bla"=>"aaa", "a"=>"eee" );
21foo($a); 26foo($a);
27
22$a=Array("test"=>"aaa", "a"=>"fff" ); 28$a=Array("test"=>"aaa", "a"=>"fff" );
23foo($a); 29foo($a);
30
24$a=Array("test2"=>Array("foo"=>Array("lol"=>"bbb")), "a"=>"cccc"); 31$a=Array("test2"=>Array("foo"=>Array("lol"=>"bbb")), "a"=>"cccc");
25foo($a); 32foo($a);
33
26$a=Array("test2"=>Array("foo"=>Array("lol"=>"aaa")), "a"=>"dddd"); 34$a=Array("test2"=>Array("foo"=>Array("lol"=>"aaa")), "a"=>"dddd");
27foo($a); 35foo($a);
36 */
28?> 37?>
29--EXPECTF-- 38--EXPECTF--
30test1 39test1
31[snuffleupagus][0.0.0.0][disabled_function][drop] The call to the function 'foo' in %a/disabled_functions_param_array.php:3 has been disabled, because its argument 'arr' content (Array) matched the rule '1'. \ No newline at end of file 40abcde
41[snuffleupagus][0.0.0.0][disabled_function][drop] The call to the function 'foo' in %a/disabled_functions_param_array.php:3 has been disabled, because its argument 'arr' content (Array) matched the rule '1'.
diff --git a/src/tests/disabled_functions_param_array_deref.phpt b/src/tests/disabled_functions_param_array_deref.phpt
new file mode 100644
index 0000000..556cb06
--- /dev/null
+++ b/src/tests/disabled_functions_param_array_deref.phpt
@@ -0,0 +1,25 @@
1--TEST--
2Disable functions
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini
7--FILE--
8<?php
9function foo($arr) {
10 echo $arr["a"]."\n";
11}
12
13$a=Array("bla"=>"aaa", "a"=>"eee" );
14foo($a);
15
16$a=Array("bla"=>"aaa", "a"=>"abcdef" );
17foo($a);
18
19$a=Array("bla"=>"abcdef", "not_bla"=>"134");
20foo($a);
21?>
22--EXPECTF--
23eee
24abcdef
25[snuffleupagus][0.0.0.0][disabled_function][drop] The call to the function 'foo' in %a/tests/disabled_functions_param_array_deref.php:3 has been disabled, because its argument 'arr' content (Array) matched the rule '2'.
diff --git a/src/tests/disabled_functions_param_array_no_value.phpt b/src/tests/disabled_functions_param_array_no_value.phpt
new file mode 100644
index 0000000..06b9839
--- /dev/null
+++ b/src/tests/disabled_functions_param_array_no_value.phpt
@@ -0,0 +1,22 @@
1--TEST--
2Disable functions - matching on an array's variable only
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini
7--FILE--
8<?php
9function foo($arr) {
10 echo $arr["a"]."\n";
11}
12
13$a=Array("test2"=>Array("foo"=>Array("lol"=>"bbb")), "a"=>"cccc");
14foo($a);
15
16$a=Array("test"=>"aaa", "a"=>"fff" );
17foo($a);
18
19?>
20--EXPECTF--
21cccc
22[snuffleupagus][0.0.0.0][disabled_function][drop] The call to the function 'foo' in %a/tests/disabled_functions_param_array_no_value.php:3 has been disabled, because its argument 'arr' content (Array) matched the rule '3'.
diff --git a/src/tests/disabled_functions_param_array_several_levels.phpt b/src/tests/disabled_functions_param_array_several_levels.phpt
new file mode 100644
index 0000000..cef6ded
--- /dev/null
+++ b/src/tests/disabled_functions_param_array_several_levels.phpt
@@ -0,0 +1,20 @@
1--TEST--
2Disable functions - match on an array value buried in several levels
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini
7--FILE--
8<?php
9function foo($arr) {
10 echo $arr["a"]."\n";
11}
12$a=Array("test2"=>Array("pof"=>"pif", "foo"=>Array("lol"=>"bbb")), "a"=>"cccc");
13foo($a);
14
15$a=Array("test2"=>Array("foo"=>Array("lol"=>"aaa")), "a"=>"dddd");
16foo($a);
17?>
18--EXPECTF--
19cccc
20[snuffleupagus][0.0.0.0][disabled_function][drop] The call to the function 'foo' in %a/tests/disabled_functions_param_array_several_levels.php:3 has been disabled, because its argument 'arr' content (Array) matched the rule '4'.
diff --git a/src/tests/disabled_functions_ret_right_hash.phpt b/src/tests/disabled_functions_ret_right_hash.phpt
index e0d8b5b..ff683e1 100644
--- a/src/tests/disabled_functions_ret_right_hash.phpt
+++ b/src/tests/disabled_functions_ret_right_hash.phpt
@@ -10,3 +10,4 @@ system("echo $((1 + 1336))");
10?> 10?>
11--EXPECTF-- 11--EXPECTF--
121337 121337
13[snuffleupagus][0.0.0.0][disabled_function][drop] The execution has been aborted in %a/tests/disabled_functions_ret_right_hash.php:2, because the return value (1337) of the function 'system' matched a rule.
diff --git a/src/tests/encrypt_cookies_empty_env.phpt b/src/tests/encrypt_cookies_empty_env.phpt
new file mode 100644
index 0000000..1136d4d
--- /dev/null
+++ b/src/tests/encrypt_cookies_empty_env.phpt
@@ -0,0 +1,19 @@
1--TEST--
2Cookie encryption - empty environment variable specified
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_encrypted_cookies_empty_env.ini
7display_errors=1
8display_startup_errors=1
9error_reporting=E_ALL
10--COOKIE--
11super_cookie=1337;awful_cookie=awful_cookie_value;
12--ENV--
13return <<<EOF
14NOT_REMOTE_ADDR=127.0.0.1
15EOF;
16--FILE--
17<?php echo "1\n\n\n\n\n"; ?>
18--EXPECT--
191