Skip to content

Commit

Permalink
Fix #350: Do not setcookie during unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
djarran committed Nov 25, 2024
1 parent 386a623 commit 68959e3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions classes/local/outagelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,9 @@ public static function create_climaintenancephp_code($starttime, $stoptime, $all
}
// Put access key as a cookie if given. This stops the need to put it as a url param on every request.
$urlaccesskey = optional_param('accesskey', null, PARAM_TEXT);
$isphpunit = defined('PHPUNIT_TEST');
if (!empty($urlaccesskey)) {
if (!empty($urlaccesskey) && !$isphpunit) {
setcookie('auth_outage_accesskey', $urlaccesskey, time() + 86400, '/', '', {{COOKIESECURE}}, {{COOKIEHTTPONLY}});
}
Expand All @@ -322,7 +323,6 @@ public static function create_climaintenancephp_code($starttime, $stoptime, $all
$ipblocked = !remoteip_in_list('{{ALLOWEDIPS}}');
$accesskeyblocked = $useraccesskey != '{{ACCESSKEY}}';
$allowed = ({{USEACCESSKEY}} && !$accesskeyblocked) || ({{USEALLOWEDIPS}} && !$ipblocked);
$isphpunit = defined('PHPUNIT_TEST');
if (!$allowed) {
if (!$isphpunit) {
Expand Down

0 comments on commit 68959e3

Please sign in to comment.