Skip to content

Commit f14bbef

Browse files
committed
every switchUser has a fresh session by default
1 parent 8eb8a0e commit f14bbef

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

test/phpunit-bootstrap.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
require_once __DIR__ . "/../resources/lib/UnityRedis.php";
1616
require_once __DIR__ . "/../resources/lib/UnityGithub.php";
1717

18-
session_save_path(exec("mktemp -d"));
19-
error_log(session_save_path());
20-
2118
global $HTTP_HEADER_TEST_INPUTS;
2219
$HTTP_HEADER_TEST_INPUTS = [
2320
'',
@@ -45,11 +42,20 @@
4542
mb_convert_encoding("Hello, World!", "UTF-16")
4643
];
4744

48-
function switchUser(string $eppn, string $given_name, string $sn, string $mail): void
49-
{
45+
function switchUser(
46+
string $eppn,
47+
string $given_name,
48+
string $sn,
49+
string $mail,
50+
string|null $session_id = null
51+
): void {
5052
global $CONFIG, $REDIS, $LDAP, $SQL, $MAILER, $WEBHOOK, $GITHUB, $SITE, $SSO, $OPERATOR, $USER, $SEND_PIMESG_TO_ADMINS, $LOC_HEADER, $LOC_FOOTER;
5153
session_write_close();
52-
session_id(str_replace(["_", "@", "."], "-", $eppn));
54+
if (is_null($session_id)) {
55+
session_id(str_replace(["_", "@", "."], "-", uniqid($eppn . "_")));
56+
} else {
57+
session_id($session_id);
58+
}
5359
// session_start will be called on the first post()
5460
$_SERVER["REMOTE_USER"] = $eppn;
5561
$_SERVER["REMOTE_ADDR"] = "127.0.0.1";

0 commit comments

Comments
 (0)