diff options
| author | jvoisin | 2019-01-14 19:29:25 +0000 |
|---|---|---|
| committer | GitHub | 2019-01-14 19:29:25 +0000 |
| commit | e79f7e3bd992c7f0915ef9afe7afb6d79740527a (patch) | |
| tree | f881c25694eb00da2331a9ab280ec1c24a5662ab /src/tests/cookies_encryption | |
| parent | c943db586ac46b686b49bdf61d8473e39dd93000 (diff) | |
Reorganize the testsuite
Splitting the testsuite in several components makes it easier to manage and comprehend.
This was also needed some some tests aren't passing on Alpine Linux, but we still want to run
as many of them as we can on this platform.
Diffstat (limited to 'src/tests/cookies_encryption')
26 files changed, 468 insertions, 0 deletions
diff --git a/src/tests/cookies_encryption/config/config_encrypted_cookies.ini b/src/tests/cookies_encryption/config/config_encrypted_cookies.ini new file mode 100644 index 0000000..4b50440 --- /dev/null +++ b/src/tests/cookies_encryption/config/config_encrypted_cookies.ini | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | ||
| 2 | sp.cookie.name("super_cookie").encrypt(); | ||
| 3 | sp.auto_cookie_secure.enable(); | ||
diff --git a/src/tests/cookies_encryption/config/config_encrypted_cookies_empty_env.ini b/src/tests/cookies_encryption/config/config_encrypted_cookies_empty_env.ini new file mode 100644 index 0000000..8368d65 --- /dev/null +++ b/src/tests/cookies_encryption/config/config_encrypted_cookies_empty_env.ini | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("SUPER_ENV_VAR"); | ||
| 2 | sp.cookie.name("super_cookie").encrypt(); | ||
diff --git a/src/tests/cookies_encryption/config/config_encrypted_cookies_simulation.ini b/src/tests/cookies_encryption/config/config_encrypted_cookies_simulation.ini new file mode 100644 index 0000000..32e24a1 --- /dev/null +++ b/src/tests/cookies_encryption/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/cookies_encryption/config/config_encrypted_regexp_cookies.ini b/src/tests/cookies_encryption/config/config_encrypted_regexp_cookies.ini new file mode 100644 index 0000000..8ea77f7 --- /dev/null +++ b/src/tests/cookies_encryption/config/config_encrypted_regexp_cookies.ini | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | ||
| 2 | sp.cookie.name_r("^super_co[a-z]+$").encrypt(); | ||
| 3 | sp.auto_cookie_secure.enable(); | ||
diff --git a/src/tests/cookies_encryption/config/config_encrypted_regexp_cookies_empty_env.ini b/src/tests/cookies_encryption/config/config_encrypted_regexp_cookies_empty_env.ini new file mode 100644 index 0000000..da84df7 --- /dev/null +++ b/src/tests/cookies_encryption/config/config_encrypted_regexp_cookies_empty_env.ini | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | ||
| 2 | sp.cookie.name_r("^super_coo[a-z]+$").encrypt(); | ||
diff --git a/src/tests/cookies_encryption/config/encryption_key_only.ini b/src/tests/cookies_encryption/config/encryption_key_only.ini new file mode 100644 index 0000000..7de4438 --- /dev/null +++ b/src/tests/cookies_encryption/config/encryption_key_only.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.global.secret_key("abcdef"); | |||
diff --git a/src/tests/cookies_encryption/encrypt_cookies.phpt b/src/tests/cookies_encryption/encrypt_cookies.phpt new file mode 100644 index 0000000..d581dbc --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_cookies.phpt | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie decryption in ipv4 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_cookies.ini | ||
| 7 | --COOKIE-- | ||
| 8 | super_cookie=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP3gV9YJZL/pUeNAjCKFW0U2ywmf1CwHzwd2pWM=;awful_cookie=awful_cookie_value; | ||
| 9 | --ENV-- | ||
| 10 | return <<<EOF | ||
| 11 | REMOTE_ADDR=127.0.0.1 | ||
| 12 | HTTP_USER_AGENT=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/59.0.3071.109 Chrome/59.0.3071.109 Safari/537.36 | ||
| 13 | EOF; | ||
| 14 | --FILE-- | ||
| 15 | <?php var_dump($_COOKIE); ?> | ||
| 16 | --EXPECT-- | ||
| 17 | array(2) { | ||
| 18 | ["super_cookie"]=> | ||
| 19 | string(11) "super_value" | ||
| 20 | ["awful_cookie"]=> | ||
| 21 | string(18) "awful_cookie_value" | ||
| 22 | } | ||
diff --git a/src/tests/cookies_encryption/encrypt_cookies2.phpt b/src/tests/cookies_encryption/encrypt_cookies2.phpt new file mode 100644 index 0000000..195cb24 --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_cookies2.phpt | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie encryption in ipv4 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies.ini | ||
| 7 | --COOKIE-- | ||
| 8 | --ENV-- | ||
| 9 | return <<<EOF | ||
| 10 | REMOTE_ADDR=127.0.0.1 | ||
| 11 | HTTP_USER_AGENT=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/59.0.3071.109 Chrome/59.0.3071.109 Safari/537.36 | ||
| 12 | HTTPS=1 | ||
| 13 | EOF; | ||
| 14 | --FILE-- | ||
| 15 | <?php | ||
| 16 | setcookie("super_cookie", "super_value"); | ||
| 17 | setcookie("awful_cookie", "awful_value"); | ||
| 18 | setcookie("nice_cookie", "nice_value", 1, "1", "1", true, true); | ||
| 19 | var_dump($_COOKIE); | ||
| 20 | ?> | ||
| 21 | --EXPECT-- | ||
| 22 | array(0) { | ||
| 23 | } | ||
diff --git a/src/tests/cookies_encryption/encrypt_cookies3.phpt b/src/tests/cookies_encryption/encrypt_cookies3.phpt new file mode 100644 index 0000000..ceb364c --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_cookies3.phpt | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie decryption with ipv6 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies.ini | ||
| 7 | --COOKIE-- | ||
| 8 | super_cookie=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABM84SCotZTpP6b27Lr5lavORPMvqaKpcUahvxw=;awful_cookie=awful_cookie_value; | ||
| 9 | --ENV-- | ||
| 10 | return <<<EOF | ||
| 11 | REMOTE_ADDR=2001:0db8:0000:0000:0000:fe00:0042:8329 | ||
| 12 | HTTP_USER_AGENT=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/59.0.3071.109 Chrome/59.0.3071.109 Safari/537.36 | ||
| 13 | HTTPS=1 | ||
| 14 | EOF; | ||
| 15 | --FILE-- | ||
| 16 | <?php var_dump($_COOKIE); ?> | ||
| 17 | --EXPECT-- | ||
| 18 | array(2) { | ||
| 19 | ["super_cookie"]=> | ||
| 20 | string(11) "super_value" | ||
| 21 | ["awful_cookie"]=> | ||
| 22 | string(18) "awful_cookie_value" | ||
| 23 | } | ||
diff --git a/src/tests/cookies_encryption/encrypt_cookies4.phpt b/src/tests/cookies_encryption/encrypt_cookies4.phpt new file mode 100644 index 0000000..b644680 --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_cookies4.phpt | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie encryption in ipv6 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_cookies.ini | ||
| 7 | --COOKIE-- | ||
| 8 | --ENV-- | ||
| 9 | return <<<EOF | ||
| 10 | REMOTE_ADDR=2001:0db8:0000:0000:0000:fe00:0042:8329 | ||
| 11 | HTTP_USER_AGENT=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/59.0.3071.109 Chrome/59.0.3071.109 Safari/537.36 | ||
| 12 | HTTPS=1 | ||
| 13 | EOF; | ||
| 14 | --FILE-- | ||
| 15 | <?php | ||
| 16 | setcookie("super_cookie", "super_value"); | ||
| 17 | setcookie("awful_cookie", "awful_value"); | ||
| 18 | setcookie("nice_cookie", "nice_value", 1, "1", "1", true, true); | ||
| 19 | $ret = setcookie("", "Cookie with no name", 1, "1", "1", true, true); | ||
| 20 | if ($ret == TRUE) { | ||
| 21 | echo "fail :/"; | ||
| 22 | } | ||
| 23 | var_dump($_COOKIE); | ||
| 24 | ?> | ||
| 25 | --EXPECTF-- | ||
| 26 | Warning: Cookie names must not be empty in %a/encrypt_cookies4.php on line %d | ||
| 27 | array(0) { | ||
| 28 | } | ||
diff --git a/src/tests/cookies_encryption/encrypt_cookies_empty_env.phpt b/src/tests/cookies_encryption/encrypt_cookies_empty_env.phpt new file mode 100644 index 0000000..23f1759 --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_cookies_empty_env.phpt | |||
| @@ -0,0 +1,18 @@ | |||
| 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=cGFkZGluZ3BhZGRpbmdwYWRkaW5ncGFkZGluZ3BhZGRpbmdwYWRkaW5ncGFkZGluZ3BhZGRpbmdwYWRkaW5ncGFkZGluZwo= | ||
| 12 | --FILE-- | ||
| 13 | <?php echo "1\n\n\n\n\n"; ?> | ||
| 14 | --EXPECT-- | ||
| 15 | Warning: [snuffleupagus][cookie_encryption] The environment variable 'SUPER_ENV_VAR' is empty, cookies are weakly encrypted in Unknown on line 0 | ||
| 16 | |||
| 17 | Warning: [snuffleupagus][cookie_encryption] Something went wrong with the decryption of super_cookie in Unknown on line 0 | ||
| 18 | 1 | ||
diff --git a/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption.phpt b/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption.phpt new file mode 100644 index 0000000..d4a0b0f --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption.phpt | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie encryption - invalid decryption | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_cookies.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 | Warning: [snuffleupagus][cookie_encryption] Something went wrong with the decryption of super_cookie in Unknown on line 0 | ||
| 22 | 1337 | ||
| 23 | array(1) { | ||
| 24 | ["awfulcookie"]=> | ||
| 25 | string(16) "awfulcookievalue" | ||
| 26 | } | ||
diff --git a/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption2.phpt b/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption2.phpt new file mode 100644 index 0000000..b3a55dd --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption2.phpt | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie encryption | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_cookies.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 | REMOTE_ADDR=127.0.0.1 | ||
| 15 | EOF; | ||
| 16 | --FILE-- | ||
| 17 | <?php var_dump($_COOKIE); ?> | ||
| 18 | --EXPECT-- | ||
| 19 | Fatal error: [snuffleupagus][cookie_encryption] Buffer underflow tentative detected in cookie encryption handling in Unknown on line 0 \ No newline at end of file | ||
diff --git a/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption3.phpt b/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption3.phpt new file mode 100644 index 0000000..f4afc32 --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption3.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie encryption | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_cookies.ini | ||
| 7 | --COOKIE-- | ||
| 8 | super_cookie=;awful_cookie=awful_cookie_value; | ||
| 9 | --ENV-- | ||
| 10 | return <<<EOF | ||
| 11 | REMOTE_ADDR=127.0.0.1 | ||
| 12 | EOF; | ||
| 13 | --FILE-- | ||
| 14 | <?php var_dump($_COOKIE); ?> | ||
| 15 | --EXPECT-- | ||
| 16 | array(2) { | ||
| 17 | ["super_cookie"]=> | ||
| 18 | string(0) "" | ||
| 19 | ["awful_cookie"]=> | ||
| 20 | string(18) "awful_cookie_value" | ||
| 21 | } | ||
diff --git a/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption_short_cookie.phpt b/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption_short_cookie.phpt new file mode 100644 index 0000000..39f189c --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption_short_cookie.phpt | |||
| @@ -0,0 +1,25 @@ | |||
| 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 | Warning: [snuffleupagus][cookie_encryption] Buffer underflow tentative detected in cookie encryption handling for super_cookie. Using the cookie 'as it' instead of decrypting it in Unknown on line 0 | ||
| 20 | array(2) { | ||
| 21 | ["super_cookie"]=> | ||
| 22 | string(3) "AAA" | ||
| 23 | ["awful_cookie"]=> | ||
| 24 | string(18) "awful_cookie_value" | ||
| 25 | } \ No newline at end of file | ||
diff --git a/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption_simulation.phpt b/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption_simulation.phpt new file mode 100644 index 0000000..d2004b9 --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption_simulation.phpt | |||
| @@ -0,0 +1,28 @@ | |||
| 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 | Warning: [snuffleupagus][cookie_encryption] Something went wrong with the decryption of super_cookie. Using the cookie 'as it' instead of decrypting it in Unknown on line 0 | ||
| 22 | 1337 | ||
| 23 | array(2) { | ||
| 24 | ["super_cookie"]=> | ||
| 25 | string(124) "Wk9NR1RISVNJU05PVEVOQ1JZUFRFREFUQUxMV0hBVFRIRUhFTExJU0hIRUxMQVJFWU9VRE9JTkdaT01Hb2htYXliZXRoaXNpc2Fub2xkc2Vzc2lvbmNvb2tpZQo=" | ||
| 26 | ["awfulcookie"]=> | ||
| 27 | string(16) "awfulcookievalue" | ||
| 28 | } \ No newline at end of file | ||
diff --git a/src/tests/cookies_encryption/encrypt_regexp_cookies.phpt b/src/tests/cookies_encryption/encrypt_regexp_cookies.phpt new file mode 100644 index 0000000..6bc187a --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_regexp_cookies.phpt | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie decryption in ipv4 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies.ini | ||
| 7 | --COOKIE-- | ||
| 8 | super_cookie=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP3gV9YJZL/pUeNAjCKFW0U2ywmf1CwHzwd2pWM=;awful_cookie=awful_cookie_value; | ||
| 9 | --ENV-- | ||
| 10 | return <<<EOF | ||
| 11 | REMOTE_ADDR=127.0.0.1 | ||
| 12 | HTTP_USER_AGENT=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/59.0.3071.109 Chrome/59.0.3071.109 Safari/537.36 | ||
| 13 | EOF; | ||
| 14 | --FILE-- | ||
| 15 | <?php var_dump($_COOKIE); ?> | ||
| 16 | --EXPECT-- | ||
| 17 | array(2) { | ||
| 18 | ["super_cookie"]=> | ||
| 19 | string(11) "super_value" | ||
| 20 | ["awful_cookie"]=> | ||
| 21 | string(18) "awful_cookie_value" | ||
| 22 | } | ||
diff --git a/src/tests/cookies_encryption/encrypt_regexp_cookies2.phpt b/src/tests/cookies_encryption/encrypt_regexp_cookies2.phpt new file mode 100644 index 0000000..195cb24 --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_regexp_cookies2.phpt | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie encryption in ipv4 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies.ini | ||
| 7 | --COOKIE-- | ||
| 8 | --ENV-- | ||
| 9 | return <<<EOF | ||
| 10 | REMOTE_ADDR=127.0.0.1 | ||
| 11 | HTTP_USER_AGENT=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/59.0.3071.109 Chrome/59.0.3071.109 Safari/537.36 | ||
| 12 | HTTPS=1 | ||
| 13 | EOF; | ||
| 14 | --FILE-- | ||
| 15 | <?php | ||
| 16 | setcookie("super_cookie", "super_value"); | ||
| 17 | setcookie("awful_cookie", "awful_value"); | ||
| 18 | setcookie("nice_cookie", "nice_value", 1, "1", "1", true, true); | ||
| 19 | var_dump($_COOKIE); | ||
| 20 | ?> | ||
| 21 | --EXPECT-- | ||
| 22 | array(0) { | ||
| 23 | } | ||
diff --git a/src/tests/cookies_encryption/encrypt_regexp_cookies3.phpt b/src/tests/cookies_encryption/encrypt_regexp_cookies3.phpt new file mode 100644 index 0000000..ceb364c --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_regexp_cookies3.phpt | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie decryption with ipv6 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies.ini | ||
| 7 | --COOKIE-- | ||
| 8 | super_cookie=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABM84SCotZTpP6b27Lr5lavORPMvqaKpcUahvxw=;awful_cookie=awful_cookie_value; | ||
| 9 | --ENV-- | ||
| 10 | return <<<EOF | ||
| 11 | REMOTE_ADDR=2001:0db8:0000:0000:0000:fe00:0042:8329 | ||
| 12 | HTTP_USER_AGENT=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/59.0.3071.109 Chrome/59.0.3071.109 Safari/537.36 | ||
| 13 | HTTPS=1 | ||
| 14 | EOF; | ||
| 15 | --FILE-- | ||
| 16 | <?php var_dump($_COOKIE); ?> | ||
| 17 | --EXPECT-- | ||
| 18 | array(2) { | ||
| 19 | ["super_cookie"]=> | ||
| 20 | string(11) "super_value" | ||
| 21 | ["awful_cookie"]=> | ||
| 22 | string(18) "awful_cookie_value" | ||
| 23 | } | ||
diff --git a/src/tests/cookies_encryption/encrypt_regexp_cookies4.phpt b/src/tests/cookies_encryption/encrypt_regexp_cookies4.phpt new file mode 100644 index 0000000..14d737a --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_regexp_cookies4.phpt | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie encryption in ipv6 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_cookies.ini | ||
| 7 | --COOKIE-- | ||
| 8 | --ENV-- | ||
| 9 | return <<<EOF | ||
| 10 | REMOTE_ADDR=2001:0db8:0000:0000:0000:fe00:0042:8329 | ||
| 11 | HTTP_USER_AGENT=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/59.0.3071.109 Chrome/59.0.3071.109 Safari/537.36 | ||
| 12 | HTTPS=1 | ||
| 13 | EOF; | ||
| 14 | --FILE-- | ||
| 15 | <?php | ||
| 16 | setcookie("super_cookie", "super_value"); | ||
| 17 | setcookie("awful_cookie", "awful_value"); | ||
| 18 | setcookie("nice_cookie", "nice_value", 1, "1", "1", true, true); | ||
| 19 | var_dump($_COOKIE); | ||
| 20 | ?> | ||
| 21 | --EXPECT-- | ||
| 22 | array(0) { | ||
| 23 | } | ||
diff --git a/src/tests/cookies_encryption/encrypt_regexp_cookies_empty_env.phpt b/src/tests/cookies_encryption/encrypt_regexp_cookies_empty_env.phpt new file mode 100644 index 0000000..852c32e --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_regexp_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_regexp_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 | Fatal error: [snuffleupagus][cookie_encryption] Buffer underflow tentative detected in cookie encryption handling in Unknown on line 0 \ No newline at end of file | ||
diff --git a/src/tests/cookies_encryption/encrypt_regexp_cookies_invalid_decryption.phpt b/src/tests/cookies_encryption/encrypt_regexp_cookies_invalid_decryption.phpt new file mode 100644 index 0000000..d2f9e3c --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_regexp_cookies_invalid_decryption.phpt | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie encryption | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies.ini | ||
| 7 | display_errors=1 | ||
| 8 | display_startup_errors=1 | ||
| 9 | error_reporting=E_ALL | ||
| 10 | --COOKIE-- | ||
| 11 | super_cookie=jWjORGsgZyqzk3WA63XZBmUoSknXWnXDfAAAAAAAAAAAAAAAAAAAAAA7LiMDfkpP94jDnMVH%2Fm41GeL0Y00q3mbOFYz%2FS9mQGySu;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 | Warning: [snuffleupagus][cookie_encryption] Something went wrong with the decryption of super_cookie in Unknown on line 0 | ||
| 20 | array(1) { | ||
| 21 | ["awful_cookie"]=> | ||
| 22 | string(18) "awful_cookie_value" | ||
| 23 | } | ||
diff --git a/src/tests/cookies_encryption/encrypt_regexp_cookies_invalid_decryption2.phpt b/src/tests/cookies_encryption/encrypt_regexp_cookies_invalid_decryption2.phpt new file mode 100644 index 0000000..e75e036 --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_regexp_cookies_invalid_decryption2.phpt | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie encryption | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies.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 | REMOTE_ADDR=127.0.0.1 | ||
| 15 | EOF; | ||
| 16 | --FILE-- | ||
| 17 | <?php var_dump($_COOKIE); ?> | ||
| 18 | --EXPECT-- | ||
| 19 | Fatal error: [snuffleupagus][cookie_encryption] Buffer underflow tentative detected in cookie encryption handling in Unknown on line 0 \ No newline at end of file | ||
diff --git a/src/tests/cookies_encryption/encrypt_regexp_cookies_invalid_decryption3.phpt b/src/tests/cookies_encryption/encrypt_regexp_cookies_invalid_decryption3.phpt new file mode 100644 index 0000000..28ffaad --- /dev/null +++ b/src/tests/cookies_encryption/encrypt_regexp_cookies_invalid_decryption3.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie encryption | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies.ini | ||
| 7 | --COOKIE-- | ||
| 8 | super_cookie=;awful_cookie=awful_cookie_value; | ||
| 9 | --ENV-- | ||
| 10 | return <<<EOF | ||
| 11 | REMOTE_ADDR=127.0.0.1 | ||
| 12 | EOF; | ||
| 13 | --FILE-- | ||
| 14 | <?php var_dump($_COOKIE); ?> | ||
| 15 | --EXPECT-- | ||
| 16 | array(2) { | ||
| 17 | ["super_cookie"]=> | ||
| 18 | string(0) "" | ||
| 19 | ["awful_cookie"]=> | ||
| 20 | string(18) "awful_cookie_value" | ||
| 21 | } | ||
diff --git a/src/tests/cookies_encryption/encryption_key_only.phpt b/src/tests/cookies_encryption/encryption_key_only.phpt new file mode 100644 index 0000000..bf5edb5 --- /dev/null +++ b/src/tests/cookies_encryption/encryption_key_only.phpt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | --TEST-- | ||
| 2 | Encryption key only | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/encryption_key_only.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo 1337; | ||
| 10 | ?> | ||
| 11 | --EXPECT-- | ||
| 12 | 1337 | ||
| 13 | |||
diff --git a/src/tests/cookies_encryption/setcookie.phpt b/src/tests/cookies_encryption/setcookie.phpt new file mode 100644 index 0000000..ba1d1c1 --- /dev/null +++ b/src/tests/cookies_encryption/setcookie.phpt | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | --TEST-- | ||
| 2 | Set cookies. | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) die "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_cookies.ini | ||
| 7 | --COOKIE-- | ||
| 8 | --ENV-- | ||
| 9 | return <<<EOF | ||
| 10 | REMOTE_ADDR=127.0.0.1 | ||
| 11 | HTTP_USER_AGENT=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/59.0.3071.109 Chrome/59.0.3071.109 Safari/537.36 | ||
| 12 | HTTPS=1 | ||
| 13 | EOF; | ||
| 14 | --FILE-- | ||
| 15 | <?php | ||
| 16 | setcookie("name"); | ||
| 17 | setcookie("super_cookie"); | ||
| 18 | setcookie("name", "value"); | ||
| 19 | setcookie("name", "value1", 1); | ||
| 20 | setcookie("name", "value2", 0); | ||
| 21 | setcookie("name", "value", 1, "/super/path"); | ||
| 22 | setcookie("name", "value", 1, "/super/path", "super_domain"); | ||
| 23 | setcookie("name", "value", 1, "/super/path", "super_domain1", true); | ||
| 24 | setcookie("name", "value", 1, "/super/path", "super_domain2", false); | ||
| 25 | setcookie("name", "value", 1, "/super/path", "super_domain1", true, true); | ||
| 26 | setcookie("name", "value", 1, "/super/path", "super_domain2", true, false); | ||
| 27 | setcookie("name", "value", 1, "/super/path", "super_domain2", true, false, 1337); | ||
| 28 | setcookie(); | ||
| 29 | echo '1337'; | ||
| 30 | ?> | ||
| 31 | --EXPECTF-- | ||
| 32 | Warning: setcookie() expects at most 7 parameters, 8 given in %a/setcookie.php on line %d | ||
| 33 | |||
| 34 | Warning: setcookie() expects at least 1 parameter, 0 given in %a/setcookie.php on line %d | ||
| 35 | 1337 | ||
