summaryrefslogtreecommitdiff
path: root/src/tests/session_encryption
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/session_encryption')
-rw-r--r--src/tests/session_encryption/crypt_session_corrupted_session.phpt2
-rw-r--r--src/tests/session_encryption/crypt_session_invalid_simul.phpt15
-rw-r--r--src/tests/session_encryption/crypt_session_invalid_simul_php73.phpt33
-rw-r--r--src/tests/session_encryption/crypt_session_read_uncrypt.phpt16
-rw-r--r--src/tests/session_encryption/set_custom_session_handler.phpt2
-rw-r--r--src/tests/session_encryption/set_custom_session_handler2.phpt2
6 files changed, 57 insertions, 13 deletions
diff --git a/src/tests/session_encryption/crypt_session_corrupted_session.phpt b/src/tests/session_encryption/crypt_session_corrupted_session.phpt
index 6f9c287..db3f949 100644
--- a/src/tests/session_encryption/crypt_session_corrupted_session.phpt
+++ b/src/tests/session_encryption/crypt_session_corrupted_session.phpt
@@ -6,7 +6,7 @@ Set a custom session handler
6<?php if (PHP_VERSION_ID >= 70400) print "skip"; ?> 6<?php if (PHP_VERSION_ID >= 70400) print "skip"; ?>
7--INI-- 7--INI--
8sp.configuration_file={PWD}/config/config_crypt_session.ini 8sp.configuration_file={PWD}/config/config_crypt_session.ini
9session.save_path = "/tmp" 9session.save_path="/tmp"
10--ENV-- 10--ENV--
11return <<<EOF 11return <<<EOF
12REMOTE_ADDR=127.0.0.1 12REMOTE_ADDR=127.0.0.1
diff --git a/src/tests/session_encryption/crypt_session_invalid_simul.phpt b/src/tests/session_encryption/crypt_session_invalid_simul.phpt
index cbb80dc..80edb8a 100644
--- a/src/tests/session_encryption/crypt_session_invalid_simul.phpt
+++ b/src/tests/session_encryption/crypt_session_invalid_simul.phpt
@@ -1,9 +1,12 @@
1--TEST-- 1--TEST--
2SESSION crypt and bad decrypt 2SESSION crypt and bad decrypt
3--SKIPIF-- 3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> 4<?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 70400) print "skip"; ?>
5--INI-- 5--INI--
6sp.configuration_file={PWD}/config/config_crypt_session_simul.ini 6sp.configuration_file={PWD}/config/config_crypt_session_simul.ini
7display_errors=0
8log_errors=1
9error_log="{PWD}"/crypt_session_invalid_simul.tmp
7--ENV-- 10--ENV--
8return <<<EOF 11return <<<EOF
9REMOTE_ADDR=127.0.0.1 12REMOTE_ADDR=127.0.0.1
@@ -19,9 +22,13 @@ putenv("REMOTE_ADDR=127.0.0.2");
19session_id($id); // Recover the session with the previous session_id 22session_id($id); // Recover the session with the previous session_id
20session_start(); // Re start the session, It will read and decrypt the non empty session 23session_start(); // Re start the session, It will read and decrypt the non empty session
21var_dump($_SESSION); // Dump the session 24var_dump($_SESSION); // Dump the session
25
26echo file_get_contents(dirname(__FILE__) . "/crypt_session_invalid_simul.tmp");
27unlink(dirname(__FILE__) . "/crypt_session_invalid_simul.tmp");
28
22?> 29?>
23--EXPECTF-- 30--EXPECTF--
24array(1) { 31array(0) {
25 ["toto"]=>
26 string(4) "tata"
27} 32}
33%aPHP Warning: [snuffleupagus][127.0.0.2][cookie_encryption][simulation] Something went wrong with the decryption of the session. Using the cookie 'as is' instead of decrypting it in %a/crypt_session_invalid_simul.php on line 9
34%aPHP Warning: session_start(): Failed to decode session object. Session has been destroyed in %a/crypt_session_invalid_simul.php on line 9
diff --git a/src/tests/session_encryption/crypt_session_invalid_simul_php73.phpt b/src/tests/session_encryption/crypt_session_invalid_simul_php73.phpt
new file mode 100644
index 0000000..4d1f747
--- /dev/null
+++ b/src/tests/session_encryption/crypt_session_invalid_simul_php73.phpt
@@ -0,0 +1,33 @@
1--TEST--
2SESSION crypt and bad decrypt
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID >= 70400) print "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_crypt_session_simul.ini
7display_errors=0
8log_errors=1
9error_log="{PWD}"/crypt_session_invalid_simul.tmp
10--ENV--
11return <<<EOF
12REMOTE_ADDR=127.0.0.1
13EOF;
14--FILE--
15<?php
16// Do it like that to write (encrypt) the session and then to read (decrypt) the session
17session_start(); // Start new_session , it will read an empty session
18$_SESSION["toto"] = "tata"; // Encrypt and write the session
19$id = session_id(); // Get the session_id to use it later
20session_write_close(); // Close the session
21putenv("REMOTE_ADDR=127.0.0.2");
22session_id($id); // Recover the session with the previous session_id
23session_start(); // Re start the session, It will read and decrypt the non empty session
24var_dump($_SESSION); // Dump the session
25
26echo file_get_contents(dirname(__FILE__) . "/crypt_session_invalid_simul.tmp");
27unlink(dirname(__FILE__) . "/crypt_session_invalid_simul.tmp");
28
29?>
30--EXPECTF--
31array(0) {
32}
33%aPHP Warning: [snuffleupagus][127.0.0.2][cookie_encryption][simulation] Something went wrong with the decryption of the session. Using the cookie 'as is' instead of decrypting it in %a/crypt_session_invalid_simul%a.php on line 9
diff --git a/src/tests/session_encryption/crypt_session_read_uncrypt.phpt b/src/tests/session_encryption/crypt_session_read_uncrypt.phpt
index 5e81b52..e2e1737 100644
--- a/src/tests/session_encryption/crypt_session_read_uncrypt.phpt
+++ b/src/tests/session_encryption/crypt_session_read_uncrypt.phpt
@@ -4,25 +4,28 @@ SESSION crypt/decrypt valid
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> 4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI-- 5--INI--
6sp.configuration_file={PWD}/config/config_crypt_session_simul.ini 6sp.configuration_file={PWD}/config/config_crypt_session_simul.ini
7session.save_path="{PWD}"
8display_errors=0
9log_errors=1
10error_log="{PWD}"/crypt_session_read_uncrypt.tmp
7--ENV-- 11--ENV--
8return <<<EOF 12return <<<EOF
9REMOTE_ADDR=127.0.0.1 13REMOTE_ADDR=127.0.0.1
10EOF; 14EOF;
11--FILE-- 15--FILE--
12<?php 16<?php
13$current_path = dirname(getcwd()) . "/src/tests/" ;
14ini_set("session.save_path", $current_path);
15
16session_start(); 17session_start();
17$id = session_id(); // Get the session_id to use it later 18$id = session_id(); // Get the session_id to use it later
18$filename_sess = $current_path . "sess_" . $id; 19$filename_sess = dirname(__FILE__) . "/sess_" . $id;
19file_put_contents($filename_sess, "toto|s:4:\"tata\";"); // Write a unencrypted session 20file_put_contents($filename_sess, "toto|s:4:\"tata\";"); // Write unencrypted session
20session_write_close(); // Close the session 21session_write_close(); // Close the session
21 22
22session_id($id); 23session_id($id);
23session_start(); // Try to read the unencrypted session, it will fail to decrypt but it must return the session 24session_start(); // Try to read the unencrypted session, it will fail to decrypt but it must return the session
24var_dump($_SESSION); 25var_dump($_SESSION);
25echo "OK"; 26echo "OK\n";
27echo file_get_contents(dirname(__FILE__) . "/crypt_session_read_uncrypt.tmp");
28unlink(dirname(__FILE__) . "/crypt_session_read_uncrypt.tmp");
26unlink($filename_sess); 29unlink($filename_sess);
27?> 30?>
28--EXPECTF-- 31--EXPECTF--
@@ -31,3 +34,4 @@ array(1) {
31 string(4) "tata" 34 string(4) "tata"
32} 35}
33OK 36OK
37%aPHP Warning: [snuffleupagus][127.0.0.1][cookie_encryption][simulation] Buffer underflow tentative detected in cookie encryption handling for the session. Using the cookie 'as is' instead of decrypting it in %a/crypt_session_read_uncrypt.php on line 9
diff --git a/src/tests/session_encryption/set_custom_session_handler.phpt b/src/tests/session_encryption/set_custom_session_handler.phpt
index 725ee43..1b81a04 100644
--- a/src/tests/session_encryption/set_custom_session_handler.phpt
+++ b/src/tests/session_encryption/set_custom_session_handler.phpt
@@ -4,7 +4,7 @@ Set a custom session handler
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> 4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI-- 5--INI--
6sp.configuration_file={PWD}/config/config_crypt_session.ini 6sp.configuration_file={PWD}/config/config_crypt_session.ini
7session.save_path = "/tmp" 7session.save_path="/tmp"
8--ENV-- 8--ENV--
9return <<<EOF 9return <<<EOF
10REMOTE_ADDR=127.0.0.1 10REMOTE_ADDR=127.0.0.1
diff --git a/src/tests/session_encryption/set_custom_session_handler2.phpt b/src/tests/session_encryption/set_custom_session_handler2.phpt
index 8cc6786..58b6595 100644
--- a/src/tests/session_encryption/set_custom_session_handler2.phpt
+++ b/src/tests/session_encryption/set_custom_session_handler2.phpt
@@ -4,7 +4,7 @@ Set a custom session handler, twice
4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> 4<?php if (!extension_loaded("snuffleupagus")) print "skip"; ?>
5--INI-- 5--INI--
6sp.configuration_file={PWD}/config/config_crypt_session.ini 6sp.configuration_file={PWD}/config/config_crypt_session.ini
7session.save_path = "/tmp" 7session.save_path="/tmp"
8--ENV-- 8--ENV--
9return <<<EOF 9return <<<EOF
10REMOTE_ADDR=127.0.0.1 10REMOTE_ADDR=127.0.0.1