mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-09-07 08:11:07 +02:00
WR #490867 auth_outage Review changes - avoid mutating svgicons before a redirect and update tests for the access key and svgicons changes
This commit is contained in:
@@ -154,15 +154,23 @@ final class infopage_test extends \auth_outage\base_testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the constructor enables SVG support.
|
||||
* Tests that rendering the page enables SVG support and restores the previous value afterwards.
|
||||
*/
|
||||
public function test_svgicons_is_true(): void {
|
||||
public function test_svgicons_is_restored_after_output(): void {
|
||||
global $CFG;
|
||||
|
||||
$this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance()));
|
||||
|
||||
$outage = $this->get_dummy_outage();
|
||||
$CFG->svgicons = false;
|
||||
new infopage();
|
||||
self::assertTrue($CFG->svgicons);
|
||||
|
||||
$info = new infopage(['outage' => $outage, 'static' => false]);
|
||||
// Constructing the page should not touch $CFG->svgicons.
|
||||
self::assertFalse($CFG->svgicons);
|
||||
|
||||
$info->get_output();
|
||||
|
||||
// Svgicons should be restored to its original value once rendering has finished.
|
||||
self::assertFalse($CFG->svgicons);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ if ((time() >= 123) && (time() < 456)) {
|
||||
require_once($CFG->dirroot.'/lib/classes/ip_utils.php');
|
||||
}
|
||||
// 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);
|
||||
$urlaccesskey = optional_param('accesskey', null, PARAM_ALPHANUM);
|
||||
$isphpunit = defined('PHPUNIT_TEST');
|
||||
|
||||
if (!empty($urlaccesskey) && !$isphpunit) {
|
||||
@@ -318,7 +318,7 @@ e.e.e.e/20');
|
||||
}
|
||||
|
||||
if (true && $accesskeyblocked) {
|
||||
echo '<!-- auth_outage blocked by missing or incorrect access key, access key given: '. $useraccesskey .' -->';
|
||||
echo '<!-- auth_outage blocked by missing or incorrect access key, access key given: ' . htmlspecialchars($useraccesskey ?? '', ENT_QUOTES | ENT_HTML5, 'UTF-8') . ' -->';
|
||||
}
|
||||
|
||||
if (!$isphpunit) {
|
||||
@@ -358,7 +358,7 @@ if ((time() >= 123) && (time() < 456)) {
|
||||
require_once($CFG->dirroot.'/lib/classes/ip_utils.php');
|
||||
}
|
||||
// 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);
|
||||
$urlaccesskey = optional_param('accesskey', null, PARAM_ALPHANUM);
|
||||
$isphpunit = defined('PHPUNIT_TEST');
|
||||
|
||||
if (!empty($urlaccesskey) && !$isphpunit) {
|
||||
@@ -402,7 +402,7 @@ if ((time() >= 123) && (time() < 456)) {
|
||||
}
|
||||
|
||||
if (true && $accesskeyblocked) {
|
||||
echo '<!-- auth_outage blocked by missing or incorrect access key, access key given: '. $useraccesskey .' -->';
|
||||
echo '<!-- auth_outage blocked by missing or incorrect access key, access key given: ' . htmlspecialchars($useraccesskey ?? '', ENT_QUOTES | ENT_HTML5, 'UTF-8') . ' -->';
|
||||
}
|
||||
|
||||
if (!$isphpunit) {
|
||||
|
||||
Reference in New Issue
Block a user