diff options
| author | jvoisin | 2017-10-27 17:22:35 +0200 |
|---|---|---|
| committer | jvoisin | 2017-10-27 17:22:35 +0200 |
| commit | 9a0400bdbc7d4decb32fe8fa3960e9e77f9fe898 (patch) | |
| tree | a27a8b5569226a4586b60876b123edc91054e9e4 /src/tests | |
| parent | 70498a7cce831049b47051813b850665c5547927 (diff) | |
Bump the coverage
Diffstat (limited to 'src/tests')
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 @@ | |||
| 1 | sp.disable_function.function("system").ret("1").drop(); | 1 | sp.disable_function.function("system").ret("1").drop(); |
| 2 | sp.disable_function.function("system").ret("1337").hash("123456789597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop(); | 2 | sp.disable_function.function("system").ret("1337").hash("123456789597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop(); |
| 3 | sp.disable_function.function("system").ret("1338").hash("522a976fa597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop(); | 3 | sp.disable_function.function("system").ret("1338").hash("522a976fa597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop(); |
| 4 | sp.disable_function.function("system").ret("1337").hash("522a976fa597a81a2b862cdb49920e2cba2e5979a3fc374c58c803e8f5c99a10").drop(); | 4 | sp.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 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | ||
| 2 | sp.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"); |
| 13 | foo($a); | 13 | foo($a); |
| 14 | $a=Array("a"=>"abcd"); | 14 | |
| 15 | foo($a); | ||
| 16 | $a=Array("a"=>"abcde"); | 15 | $a=Array("a"=>"abcde"); |
| 17 | foo($a); | 16 | foo($a); |
| 17 | |||
| 18 | $a=Array("a"=>"abcd"); | ||
| 19 | foo($a); | ||
| 20 | /* | ||
| 21 | |||
| 18 | $a=Array("bla"=>"abcdef"); | 22 | $a=Array("bla"=>"abcdef"); |
| 19 | foo($a); | 23 | foo($a); |
| 24 | |||
| 20 | $a=Array("bla"=>"aaa", "a"=>"eee" ); | 25 | $a=Array("bla"=>"aaa", "a"=>"eee" ); |
| 21 | foo($a); | 26 | foo($a); |
| 27 | |||
| 22 | $a=Array("test"=>"aaa", "a"=>"fff" ); | 28 | $a=Array("test"=>"aaa", "a"=>"fff" ); |
| 23 | foo($a); | 29 | foo($a); |
| 30 | |||
| 24 | $a=Array("test2"=>Array("foo"=>Array("lol"=>"bbb")), "a"=>"cccc"); | 31 | $a=Array("test2"=>Array("foo"=>Array("lol"=>"bbb")), "a"=>"cccc"); |
| 25 | foo($a); | 32 | foo($a); |
| 33 | |||
| 26 | $a=Array("test2"=>Array("foo"=>Array("lol"=>"aaa")), "a"=>"dddd"); | 34 | $a=Array("test2"=>Array("foo"=>Array("lol"=>"aaa")), "a"=>"dddd"); |
| 27 | foo($a); | 35 | foo($a); |
| 36 | */ | ||
| 28 | ?> | 37 | ?> |
| 29 | --EXPECTF-- | 38 | --EXPECTF-- |
| 30 | test1 | 39 | test1 |
| 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 | 40 | abcde |
| 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-- | ||
| 2 | Disable functions | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo($arr) { | ||
| 10 | echo $arr["a"]."\n"; | ||
| 11 | } | ||
| 12 | |||
| 13 | $a=Array("bla"=>"aaa", "a"=>"eee" ); | ||
| 14 | foo($a); | ||
| 15 | |||
| 16 | $a=Array("bla"=>"aaa", "a"=>"abcdef" ); | ||
| 17 | foo($a); | ||
| 18 | |||
| 19 | $a=Array("bla"=>"abcdef", "not_bla"=>"134"); | ||
| 20 | foo($a); | ||
| 21 | ?> | ||
| 22 | --EXPECTF-- | ||
| 23 | eee | ||
| 24 | abcdef | ||
| 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-- | ||
| 2 | Disable functions - matching on an array's variable only | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo($arr) { | ||
| 10 | echo $arr["a"]."\n"; | ||
| 11 | } | ||
| 12 | |||
| 13 | $a=Array("test2"=>Array("foo"=>Array("lol"=>"bbb")), "a"=>"cccc"); | ||
| 14 | foo($a); | ||
| 15 | |||
| 16 | $a=Array("test"=>"aaa", "a"=>"fff" ); | ||
| 17 | foo($a); | ||
| 18 | |||
| 19 | ?> | ||
| 20 | --EXPECTF-- | ||
| 21 | cccc | ||
| 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-- | ||
| 2 | Disable functions - match on an array value buried in several levels | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_disabled_functions_param_array.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo($arr) { | ||
| 10 | echo $arr["a"]."\n"; | ||
| 11 | } | ||
| 12 | $a=Array("test2"=>Array("pof"=>"pif", "foo"=>Array("lol"=>"bbb")), "a"=>"cccc"); | ||
| 13 | foo($a); | ||
| 14 | |||
| 15 | $a=Array("test2"=>Array("foo"=>Array("lol"=>"aaa")), "a"=>"dddd"); | ||
| 16 | foo($a); | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | cccc | ||
| 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-- |
| 12 | 1337 | 12 | 1337 |
| 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-- | ||
| 2 | Cookie encryption - empty environment variable specified | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_cookies_empty_env.ini | ||
| 7 | display_errors=1 | ||
| 8 | display_startup_errors=1 | ||
| 9 | error_reporting=E_ALL | ||
| 10 | --COOKIE-- | ||
| 11 | super_cookie=1337;awful_cookie=awful_cookie_value; | ||
| 12 | --ENV-- | ||
| 13 | return <<<EOF | ||
| 14 | NOT_REMOTE_ADDR=127.0.0.1 | ||
| 15 | EOF; | ||
| 16 | --FILE-- | ||
| 17 | <?php echo "1\n\n\n\n\n"; ?> | ||
| 18 | --EXPECT-- | ||
| 19 | 1 | ||
