diff options
Diffstat (limited to 'src/tests')
3 files changed, 54 insertions, 0 deletions
diff --git a/src/tests/config/config_encrypted_cookies_simulation.ini b/src/tests/config/config_encrypted_cookies_simulation.ini new file mode 100644 index 0000000..32e24a1 --- /dev/null +++ b/src/tests/config/config_encrypted_cookies_simulation.ini | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | ||
| 2 | sp.cookie.name("super_cookie").encrypt().simulation(); | ||
| 3 | sp.auto_cookie_secure.enable(); | ||
diff --git a/src/tests/encrypt_cookies_invalid_decryption_short_cookie.phpt b/src/tests/encrypt_cookies_invalid_decryption_short_cookie.phpt new file mode 100644 index 0000000..e5b6bfc --- /dev/null +++ b/src/tests/encrypt_cookies_invalid_decryption_short_cookie.phpt | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie encryption - invalid decryption in simulation mode with a short cookie | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_cookies_simulation.ini | ||
| 7 | display_errors=1 | ||
| 8 | display_startup_errors=1 | ||
| 9 | error_reporting=E_ALL | ||
| 10 | --COOKIE-- | ||
| 11 | super_cookie=AAA;awful_cookie=awful_cookie_value; | ||
| 12 | --ENV-- | ||
| 13 | return <<<EOF | ||
| 14 | REMOTE_ADDR=127.0.0.1 | ||
| 15 | EOF; | ||
| 16 | --FILE-- | ||
| 17 | <?php var_dump($_COOKIE); ?> | ||
| 18 | --EXPECT-- | ||
| 19 | array(2) { | ||
| 20 | ["super_cookie"]=> | ||
| 21 | string(3) "AAA" | ||
| 22 | ["awful_cookie"]=> | ||
| 23 | string(18) "awful_cookie_value" | ||
| 24 | } | ||
diff --git a/src/tests/encrypt_cookies_invalid_decryption_simulation.phpt b/src/tests/encrypt_cookies_invalid_decryption_simulation.phpt new file mode 100644 index 0000000..0bd1dc8 --- /dev/null +++ b/src/tests/encrypt_cookies_invalid_decryption_simulation.phpt | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie encryption - invalid decryption in simulation mode | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_cookies_simulation.ini | ||
| 7 | display_errors=1 | ||
| 8 | display_startup_errors=1 | ||
| 9 | error_reporting=E_ALL | ||
| 10 | --COOKIE-- | ||
| 11 | super_cookie=Wk9NR1RISVNJU05PVEVOQ1JZUFRFREFUQUxMV0hBVFRIRUhFTExJU0hIRUxMQVJFWU9VRE9JTkdaT01Hb2htYXliZXRoaXNpc2Fub2xkc2Vzc2lvbmNvb2tpZQo=;awfulcookie=awfulcookievalue; | ||
| 12 | --ENV-- | ||
| 13 | return <<<EOF | ||
| 14 | REMOTE_ADDR=127.0.0.1 | ||
| 15 | EOF; | ||
| 16 | --FILE-- | ||
| 17 | <?php | ||
| 18 | echo "1337\n"; | ||
| 19 | var_dump($_COOKIE); ?> | ||
| 20 | --EXPECT-- | ||
| 21 | 1337 | ||
| 22 | array(2) { | ||
| 23 | ["super_cookie"]=> | ||
| 24 | string(124) "Wk9NR1RISVNJU05PVEVOQ1JZUFRFREFUQUxMV0hBVFRIRUhFTExJU0hIRUxMQVJFWU9VRE9JTkdaT01Hb2htYXliZXRoaXNpc2Fub2xkc2Vzc2lvbmNvb2tpZQo=" | ||
| 25 | ["awfulcookie"]=> | ||
| 26 | string(16) "awfulcookievalue" | ||
| 27 | } | ||
