mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-17 05:48:43 +02:00
Compare commits
1 Commits
master-fai
...
moodle34_b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
490029cb65 |
57
.travis.yml
57
.travis.yml
@@ -1,60 +1,55 @@
|
||||
language: php
|
||||
|
||||
sudo: true
|
||||
|
||||
addons:
|
||||
firefox: "47.0.1"
|
||||
postgresql: "9.4"
|
||||
apt:
|
||||
packages:
|
||||
- oracle-java8-installer
|
||||
- oracle-java8-set-default
|
||||
notifications:
|
||||
email:
|
||||
recipients:
|
||||
- daniel.roperto@catalyst-au.net
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache
|
||||
- $HOME/.npm
|
||||
- $HOME/.composer/cache
|
||||
|
||||
addons:
|
||||
postgresql: "9.3"
|
||||
|
||||
php:
|
||||
- 7.0
|
||||
|
||||
env:
|
||||
- DB=pgsql MOODLE_BRANCH=MOODLE_30_STABLE
|
||||
- DB=pgsql MOODLE_BRANCH=MOODLE_31_STABLE
|
||||
- DB=pgsql MOODLE_BRANCH=MOODLE_32_STABLE
|
||||
- DB=pgsql MOODLE_BRANCH=MOODLE_33_STABLE
|
||||
- DB=pgsql MOODLE_BRANCH=MOODLE_34_STABLE
|
||||
- DB=pgsql MOODLE_BRANCH=MOODLE_35_STABLE
|
||||
- DB=pgsql MOODLE_BRANCH=master
|
||||
- DB=mysqli MOODLE_BRANCH=master
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.6
|
||||
env: DB=pgsql MOODLE_BRANCH=MOODLE_33_STABLE
|
||||
- php: 5.6
|
||||
env: DB=mysqli MOODLE_BRANCH=MOODLE_33_STABLE
|
||||
- php: 5.5
|
||||
env: DB=pgsql MOODLE_BRANCH=MOODLE_30_STABLE
|
||||
- php: 5.5
|
||||
env: DB=mysqli MOODLE_BRANCH=MOODLE_30_STABLE
|
||||
- php: 7.1
|
||||
env: DB=pgsql MOODLE_BRANCH=master
|
||||
|
||||
|
||||
before_install:
|
||||
- phpenv config-rm xdebug.ini
|
||||
- nvm install 8.9
|
||||
- nvm use 8.9
|
||||
- cd ../..
|
||||
- composer selfupdate
|
||||
- composer create-project -n --no-dev --prefer-dist blackboard-open-source/moodle-plugin-ci ci ^2
|
||||
- composer create-project -n --no-dev moodlerooms/moodle-plugin-ci ci ^1
|
||||
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
|
||||
|
||||
install:
|
||||
- moodle-plugin-ci install
|
||||
- moodle-plugin-ci install -vvv
|
||||
|
||||
script:
|
||||
- moodle-plugin-ci phplint
|
||||
- moodle-plugin-ci phpcpd
|
||||
- moodle-plugin-ci phpmd
|
||||
- moodle-plugin-ci codechecker
|
||||
- moodle-plugin-ci validate
|
||||
- moodle-plugin-ci savepoints
|
||||
- moodle-plugin-ci mustache
|
||||
- moodle-plugin-ci grunt
|
||||
- moodle-plugin-ci phpunit
|
||||
- moodle-plugin-ci behat
|
||||
- moodle-plugin-ci validate
|
||||
- moodle-plugin-ci phplint
|
||||
- moodle-plugin-ci phpcpd
|
||||
- moodle-plugin-ci phpmd
|
||||
- moodle-plugin-ci codechecker
|
||||
- moodle-plugin-ci csslint
|
||||
- moodle-plugin-ci shifter
|
||||
- moodle-plugin-ci jshint
|
||||
- moodle-plugin-ci phpunit
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
</a>
|
||||
|
||||
# Moodle Outage manager plugin
|
||||
* [Version Support](#version-support)
|
||||
|
||||
* [What is this?](#what-is-this)
|
||||
* [Moodle Requirements](#moodle-requirements)
|
||||
* [Screenshots](#screenshots)
|
||||
@@ -13,11 +13,6 @@
|
||||
* [Why is it an auth plugin?](#why-it-is-an-auth-plugin)
|
||||
* [Feedback and issues](#feedback-and-issues)
|
||||
|
||||
Version Support
|
||||
-------------
|
||||
The master branch supports Moodle 3.3 and higher.
|
||||
The MOODLE_32_STABLE branch supports Moodle 2.7 -> Moodle 3.2
|
||||
|
||||
What is this?
|
||||
-------------
|
||||
|
||||
|
||||
@@ -40,10 +40,13 @@ if (!isset($CFG->dataroot)) {
|
||||
// 1) Make sure we replace the configurations for behat as we have not ran 'lib/setup.php' yet.
|
||||
if (!empty($CFG->behat_wwwroot) or !empty($CFG->behat_dataroot) or !empty($CFG->behat_prefix)) {
|
||||
require_once(__DIR__.'/../../lib/behat/lib.php');
|
||||
|
||||
// The function call below will change $CFG so let's save it and restore later if access is granted.
|
||||
$beforebehatcfg = $CFG;
|
||||
$CFG = clone($CFG);
|
||||
behat_update_vars_for_process();
|
||||
|
||||
if (behat_is_test_site()) {
|
||||
$beforebehatcfg = $CFG;
|
||||
$CFG = clone($CFG);
|
||||
clearstatcache();
|
||||
behat_check_config_vars();
|
||||
behat_clean_init_config();
|
||||
@@ -82,4 +85,5 @@ $CFG->auth_outage_bootstrap_loaded = true;
|
||||
// 5) Restore behat config as needed (let setup.php execute which is more complex than our quick-check).
|
||||
if (isset($beforebehatcfg)) {
|
||||
$CFG = $beforebehatcfg;
|
||||
unset($beforebehatcfg);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class maintenance_static_page {
|
||||
|
||||
if (is_null($outage)) {
|
||||
$html = null;
|
||||
} else if (PHPUNIT_TEST || defined('BEHAT_SITE_RUNNING')) {
|
||||
} else if (PHPUNIT_TEST) {
|
||||
$html = '<html></html>';
|
||||
} else {
|
||||
$data = maintenance_static_page_io::file_get_data(
|
||||
|
||||
@@ -30,7 +30,6 @@ use coding_exception;
|
||||
use DOMDocument;
|
||||
use DOMElement;
|
||||
use invalid_state_exception;
|
||||
use moodle_url;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -180,12 +179,10 @@ class maintenance_static_page_generator {
|
||||
foreach ($links as $link) {
|
||||
$rel = $link->getAttribute("rel");
|
||||
$href = $link->getAttribute("href");
|
||||
if (($rel == 'shortcut icon') && ($href != '')) {
|
||||
if (!maintenance_static_page_io::is_url($href)) {
|
||||
$href = (string) new moodle_url($href);
|
||||
}
|
||||
$link->setAttribute('href', $this->io->generate_file_url($href)); // Works for most image formats.
|
||||
if (($rel != 'shortcut icon') || ($href == '')) {
|
||||
continue;
|
||||
}
|
||||
$link->setAttribute('href', $this->io->generate_file_url($href)); // Works for most image formats.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,12 +194,10 @@ class maintenance_static_page_generator {
|
||||
|
||||
foreach ($links as $link) {
|
||||
$src = $link->getAttribute("src");
|
||||
if ($src != '') {
|
||||
if (!maintenance_static_page_io::is_url($src)) {
|
||||
$src = (string) new moodle_url($src);
|
||||
}
|
||||
$link->setAttribute('src', $this->io->generate_file_url($src)); // Works for most image formats.
|
||||
if ($src == '') {
|
||||
continue;
|
||||
}
|
||||
$link->setAttribute('src', $this->io->generate_file_url($src)); // Works for most image formats.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,8 +58,8 @@ class outagelib {
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5); // It is localhost, time to connect is enough.
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, 15); // It is localhost, time to fetch index is enough.
|
||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 1); // It is localhost, time to connect is enough.
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, 5); // It is localhost, time to fetch index is enough.
|
||||
$contents = curl_exec($curl);
|
||||
$mime = curl_getinfo($curl, CURLINFO_CONTENT_TYPE);
|
||||
curl_close($curl);
|
||||
@@ -246,7 +246,7 @@ class outagelib {
|
||||
}
|
||||
// I know Moodle validation would clean up this field, but just in case, let's ensure no
|
||||
// single-quotes (and double for the sake of it) are present otherwise it would break the code.
|
||||
$allowedips = addslashes($allowedips);
|
||||
$allowedips = str_replace('\'"', '', $allowedips);
|
||||
|
||||
$code = <<<'EOT'
|
||||
<?php
|
||||
@@ -326,11 +326,11 @@ EOT;
|
||||
* @internal bootstrap_renderer $OUTPUT
|
||||
*/
|
||||
public static function generate_plugin_configuration_warning() {
|
||||
global $CFG, $OUTPUT, $PAGE;
|
||||
global $CFG, $OUTPUT;
|
||||
|
||||
$message = [];
|
||||
|
||||
if (trim(self::get_config()->allowedips) != '' && (!isset($CFG->auth_outage_bootstrap_loaded) || !$CFG->auth_outage_bootstrap_loaded)) {
|
||||
if (!isset($CFG->auth_outage_bootstrap_loaded) || !$CFG->auth_outage_bootstrap_loaded) {
|
||||
$message[] = get_string('configurationwarning', 'auth_outage');
|
||||
}
|
||||
|
||||
@@ -338,10 +338,8 @@ EOT;
|
||||
$message[] = get_string('configurationdisabled', 'auth_outage');
|
||||
}
|
||||
|
||||
if ($PAGE->pagetype == "admin-setting-auth_outage" || $PAGE->pagetype == "admin-setting-authsettingoutage") {
|
||||
if (!self::check_wwwroot_accessible()) {
|
||||
$message[] = get_string('configurationinaccessiblewwwroot', 'auth_outage', ['wwwroot' => $CFG->wwwroot]);
|
||||
}
|
||||
if (!self::check_wwwroot_accessible()) {
|
||||
$message[] = get_string('configurationinaccessiblewwwroot', 'auth_outage', ['wwwroot' => $CFG->wwwroot]);
|
||||
}
|
||||
|
||||
if (count($message) == 0) {
|
||||
|
||||
@@ -84,7 +84,7 @@ class base_table extends flexible_table {
|
||||
$buttons .= html_writer::link(
|
||||
new moodle_url('/auth/outage/info.php', ['id' => $outage->id]),
|
||||
html_writer::empty_tag('img', [
|
||||
'src' => $OUTPUT->image_url('t/preview'),
|
||||
'src' => $OUTPUT->pix_url('t/preview'),
|
||||
'alt' => get_string('view'),
|
||||
'class' => 'iconsmall',
|
||||
|
||||
@@ -100,7 +100,7 @@ class base_table extends flexible_table {
|
||||
$buttons .= html_writer::link(
|
||||
new moodle_url('/auth/outage/edit.php', ['edit' => $outage->id]),
|
||||
html_writer::empty_tag('img', [
|
||||
'src' => $OUTPUT->image_url('t/edit'),
|
||||
'src' => $OUTPUT->pix_url('t/edit'),
|
||||
'alt' => get_string('edit'),
|
||||
'class' => 'iconsmall',
|
||||
]),
|
||||
@@ -112,7 +112,7 @@ class base_table extends flexible_table {
|
||||
$buttons .= html_writer::link(
|
||||
new moodle_url('/auth/outage/edit.php', ['clone' => $outage->id]),
|
||||
html_writer::empty_tag('img', [
|
||||
'src' => $OUTPUT->image_url('t/copy'),
|
||||
'src' => $OUTPUT->pix_url('t/copy'),
|
||||
'alt' => get_string('clone', 'auth_outage'),
|
||||
'class' => 'iconsmall',
|
||||
|
||||
@@ -125,7 +125,7 @@ class base_table extends flexible_table {
|
||||
$buttons .= html_writer::link(
|
||||
new moodle_url('/auth/outage/finish.php', ['id' => $outage->id]),
|
||||
html_writer::empty_tag('img', [
|
||||
'src' => $OUTPUT->image_url('t/check'),
|
||||
'src' => $OUTPUT->pix_url('t/check'),
|
||||
'alt' => get_string('finish', 'auth_outage'),
|
||||
'class' => 'iconsmall',
|
||||
]),
|
||||
@@ -138,7 +138,7 @@ class base_table extends flexible_table {
|
||||
$buttons .= html_writer::link(
|
||||
new moodle_url('/auth/outage/delete.php', ['id' => $outage->id]),
|
||||
html_writer::empty_tag('img', [
|
||||
'src' => $OUTPUT->image_url('t/delete'),
|
||||
'src' => $OUTPUT->pix_url('t/delete'),
|
||||
'alt' => get_string('delete'),
|
||||
'class' => 'iconsmall',
|
||||
]),
|
||||
|
||||
@@ -178,14 +178,14 @@ class renderer extends plugin_renderer_base {
|
||||
$url = new moodle_url('/auth/outage/edit.php', ['edit' => $outage->id]);
|
||||
$img = html_writer::empty_tag(
|
||||
'img',
|
||||
['src' => $OUTPUT->image_url('t/edit'), 'alt' => get_string('edit'), 'class' => 'iconsmall']
|
||||
['src' => $OUTPUT->pix_url('t/edit'), 'alt' => get_string('edit'), 'class' => 'iconsmall']
|
||||
);
|
||||
$linkedit = html_writer::link($url, $img, ['title' => get_string('edit')]);
|
||||
|
||||
$url = new moodle_url('/auth/outage/delete.php', ['id' => $outage->id]);
|
||||
$img = html_writer::empty_tag(
|
||||
'img',
|
||||
['src' => $OUTPUT->image_url('t/delete'), 'alt' => get_string('delete'), 'class' => 'iconsmall']
|
||||
['src' => $OUTPUT->pix_url('t/delete'), 'alt' => get_string('delete'), 'class' => 'iconsmall']
|
||||
);
|
||||
$linkdelete = html_writer::link($url, $img, ['title' => get_string('delete')]);
|
||||
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
/**
|
||||
* Privacy Subsystem implementation for auth_outage.
|
||||
*
|
||||
* @package auth_outage
|
||||
* @copyright 2018 Olivier SECRET <olivier.secret@catalyst-au.net>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace auth_outage\privacy;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use core_privacy\local\legacy_polyfill;
|
||||
|
||||
/**
|
||||
* Privacy provider for the authentication manual.
|
||||
*
|
||||
* @copyright 2018 Carlos Escobedo <carlos@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class provider implements
|
||||
\core_privacy\local\metadata\null_provider {
|
||||
|
||||
use legacy_polyfill;
|
||||
|
||||
/**
|
||||
* Get the language string identifier with the component's language
|
||||
* file to explain why this plugin stores no data.
|
||||
*
|
||||
* This function is compatible with old php version. (Diff is the underscore '_' in the beginning)
|
||||
* But the get_reason is still available because of the trait legacy_polyfill.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function _get_reason() {
|
||||
return 'privacy:no_data_reason';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,10 +36,10 @@ $PAGE->set_url(new moodle_url('/auth/outage/manage.php'));
|
||||
|
||||
$mform = new delete();
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect(new moodle_url('/auth/outage/manage.php'));
|
||||
redirect('/auth/outage/manage.php');
|
||||
} else if ($fromform = $mform->get_data()) {
|
||||
outagedb::delete($fromform->id);
|
||||
redirect(new moodle_url('/auth/outage/manage.php'));
|
||||
redirect('/auth/outage/manage.php');
|
||||
}
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
|
||||
4
edit.php
4
edit.php
@@ -39,10 +39,10 @@ $PAGE->set_url(new moodle_url('/auth/outage/manage.php'));
|
||||
$mform = new edit();
|
||||
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect(new moodle_url('/auth/outage/manage.php'));
|
||||
redirect('/auth/outage/manage.php');
|
||||
} else if ($outage = $mform->get_data()) {
|
||||
$id = outagedb::save($outage);
|
||||
redirect($CFG->wwwroot. '/auth/outage/manage.php#auth_outage_id_'.$id);
|
||||
redirect('/auth/outage/manage.php#auth_outage_id_'.$id);
|
||||
}
|
||||
|
||||
$clone = optional_param('clone', 0, PARAM_INT);
|
||||
|
||||
@@ -36,10 +36,10 @@ $PAGE->set_url(new moodle_url('/auth/outage/manage.php'));
|
||||
|
||||
$mform = new finish();
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect(new moodle_url('/auth/outage/manage.php'));
|
||||
redirect('/auth/outage/manage.php');
|
||||
} else if ($fromform = $mform->get_data()) {
|
||||
outagedb::finish($fromform->id);
|
||||
redirect(new moodle_url('/auth/outage/manage.php'));
|
||||
redirect('/auth/outage/manage.php');
|
||||
}
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
|
||||
@@ -94,7 +94,7 @@ $string['allowedipshasmyip'] = 'Your IP (<i>{$a->ip}</i>) is in the list and you
|
||||
$string['allowedipshasntmyip'] = 'Your IP (<i>{$a->ip}</i>) is not in the list and you will be blocked out during an outage.';
|
||||
$string['allowedipsnoconfig'] = 'Your config.php does not have the extra setup to allow blocking via IP.<br />Please refer to our <a href="https://github.com/catalyst/moodle-auth_outage#installation" target="_blank">README.md</a> file for more information.';
|
||||
$string['menusettings'] = 'Settings';
|
||||
$string['menumanage'] = 'Manage outages';
|
||||
$string['menumanage'] = 'Manage';
|
||||
$string['messageoutagebackonline'] = 'We are back online!';
|
||||
$string['messageoutagebackonlinedescription'] = 'You may resume browsing safely.';
|
||||
$string['messageoutageongoing'] = 'Back online at {$a->stop}.';
|
||||
@@ -143,8 +143,3 @@ $string['title_help'] = 'A short title to for this outage. It will be displayed
|
||||
$string['warningdurationerrorinvalid'] = 'Warning duration must be positive.';
|
||||
$string['warningduration'] = 'Warning duration';
|
||||
$string['warningduration_help'] = 'How long before the start of the outage should the warning be displayed.';
|
||||
|
||||
/*
|
||||
* Privacy provider (GDPR)
|
||||
*/
|
||||
$string["privacy:no_data_reason"] = "The Outage authentication plugin does not store any personal data.";
|
||||
|
||||
13
lib.php
13
lib.php
@@ -75,7 +75,7 @@ function auth_outage_get_climaintenance_resource_file($file) {
|
||||
|
||||
// Protect against path traversal attacks.
|
||||
$basename = basename($file);
|
||||
if ($basename !== $file && $file !== 'preview/' . $basename) {
|
||||
if ($basename !== $file) {
|
||||
// @codingStandardsIgnoreStart
|
||||
if (!PHPUNIT_TEST) {
|
||||
error_log('Possible attempt for Path Traversal Attack (only filename expected): '.$file);
|
||||
@@ -87,14 +87,3 @@ function auth_outage_get_climaintenance_resource_file($file) {
|
||||
$realpath = realpath($resourcedir.'/'.$file);
|
||||
return ($realpath == false) ? null : $realpath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display required icon for the calendar events.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function auth_outage_get_fontawesome_icon_map() {
|
||||
return [
|
||||
'core:i/auth_outageevent' => 'fa-power-off',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -11,8 +11,9 @@ Feature: Change the default settings
|
||||
Given the authentication plugin "outage" is enabled
|
||||
And I am an administrator
|
||||
|
||||
|
||||
Scenario Outline: Check if I can save the default settings.
|
||||
When I navigate to "Plugins > Authentication > Outage manager > Settings" in site administration
|
||||
When I navigate to "Settings" node in "Site administration > Plugins > Authentication > Outage manager"
|
||||
And I set the following fields to these values:
|
||||
| s_auth_outage_default_autostart | <autostart> |
|
||||
| s_auth_outage_default_warning_duration[v] | <warning> |
|
||||
|
||||
@@ -8,11 +8,14 @@ Feature: IP Blocker
|
||||
- An ongoing outage does not block Moodle execution, although it can trigger maintenance mode.
|
||||
- Maintenance mode completely blocks Moodle and can only be deactivated using the CLI.
|
||||
|
||||
|
||||
Background:
|
||||
Given the authentication plugin "outage" is enabled
|
||||
|
||||
|
||||
Scenario: Default IP Whitelist Settings
|
||||
Given I am an administrator
|
||||
When I navigate to "Plugins > Authentication > Outage manager > Settings" in site administration
|
||||
And I am on homepage
|
||||
When I navigate to "Settings" node in "Site administration > Plugins > Authentication > Outage manager"
|
||||
Then I should see "Allowed IP list"
|
||||
And I should see an empty settings text area "allowedips"
|
||||
|
||||
@@ -11,19 +11,22 @@ Feature: Manage outages
|
||||
- finished is an outage that has explicitly been marked as finished.
|
||||
- stopped is an outage that has already ended but not explicitly marked as finished.
|
||||
|
||||
|
||||
Background: Always login as admin, enable the auth_outage plugin and go to the outage management page.
|
||||
Given the authentication plugin "outage" is enabled
|
||||
And I log in as "admin"
|
||||
And I wait "1" seconds
|
||||
|
||||
|
||||
Scenario: Check if I can navigate to management page.
|
||||
Given I am on homepage
|
||||
When I navigate to "Plugins > Authentication > Outage manager > Manage outages" in site administration
|
||||
When I navigate to "Manage" node in "Site administration > Plugins > Authentication > Outage manager"
|
||||
Then I should see "Planned outages"
|
||||
And I should see "No outages found." in the "#section_planned_outages" "css_element"
|
||||
And I should see "Outage history"
|
||||
And I should see "No outages found." in the "#section_outage_history" "css_element"
|
||||
|
||||
|
||||
Scenario Outline: Planned outages should include all outages not finished or stopped.
|
||||
Given there is a "<type>" outage
|
||||
When I am on Outage Management Page
|
||||
@@ -37,6 +40,7 @@ Feature: Manage outages
|
||||
| finished | outage_history |
|
||||
| stopped | outage_history |
|
||||
|
||||
|
||||
Scenario Outline: Planned and history outages have different actions.
|
||||
Given there is a "<type>" outage
|
||||
When I am on Outage Management Page
|
||||
@@ -55,12 +59,14 @@ Feature: Manage outages
|
||||
| finished | see | see | not see | not see | not see |
|
||||
| stopped | see | see | not see | not see | not see |
|
||||
|
||||
Scenario: Create an outage using defaults.
|
||||
Given I am on Outage Management Page
|
||||
When I press "Create outage"
|
||||
And I press "Save changes"
|
||||
And I should not see "No outages found." in the "#section_planned_outages" "css_element"
|
||||
And I should see "No outages found." in the "#section_outage_history" "css_element"
|
||||
|
||||
# Scenario: Create an outage using defaults.
|
||||
# Given I am on Outage Management Page
|
||||
# When I press "Create outage"
|
||||
# And I press "Save changes"
|
||||
# And I should not see "No outages found." in the "#section_planned_outages" "css_element"
|
||||
# And I should see "No outages found." in the "#section_outage_history" "css_element"
|
||||
|
||||
|
||||
Scenario: View an outage which should open in a new window or tab.
|
||||
Given there is a "waiting" outage
|
||||
@@ -69,26 +75,29 @@ Feature: Manage outages
|
||||
Then I should be in a new window
|
||||
And I should see "Example of waiting outage"
|
||||
|
||||
Scenario: Clone an outage.
|
||||
Given there is a "waiting" outage
|
||||
And I am on Outage Management Page
|
||||
When I click on the "Clone" action button
|
||||
Then I should see "Clone outage"
|
||||
And I set the field "title" to "My cloned outage"
|
||||
And I press "Save changes"
|
||||
Then I should see "Example of waiting outage"
|
||||
And I should see "My cloned outage"
|
||||
|
||||
Scenario: Edit an outage.
|
||||
Given there is a "warning" outage
|
||||
And I am on Outage Management Page
|
||||
And I should see "Example of warning outage"
|
||||
When I click on the "Edit" action button
|
||||
Then I should see "Edit outage"
|
||||
And I set the field "title" to "My previous warning outage"
|
||||
And I press "Save changes"
|
||||
Then I should not see "Example of warning outage"
|
||||
And I should see "My previous warning outage"
|
||||
# Scenario: Clone an outage.
|
||||
# Given there is a "waiting" outage
|
||||
# And I am on Outage Management Page
|
||||
# When I click on the "Clone" action button
|
||||
# Then I should see "Clone outage"
|
||||
# And I set the field "title" to "My cloned outage"
|
||||
# And I press "Save changes"
|
||||
# Then I should see "Example of waiting outage"
|
||||
# And I should see "My cloned outage"
|
||||
|
||||
|
||||
# Scenario: Edit an outage.
|
||||
# Given there is a "warning" outage
|
||||
# And I am on Outage Management Page
|
||||
# And I should see "Example of warning outage"
|
||||
# When I click on the "Edit" action button
|
||||
# Then I should see "Edit outage"
|
||||
# And I set the field "title" to "My previous warning outage"
|
||||
# And I press "Save changes"
|
||||
# Then I should not see "Example of warning outage"
|
||||
# And I should see "My previous warning outage"
|
||||
|
||||
|
||||
Scenario: Delete an outage
|
||||
Given there is a "warning" outage
|
||||
@@ -100,6 +109,7 @@ Feature: Manage outages
|
||||
Then I press "Delete"
|
||||
And I should not see "Example of warning outage"
|
||||
|
||||
|
||||
Scenario: Finish an outage
|
||||
Given there is a "ongoing" outage
|
||||
And I am on Outage Management Page
|
||||
|
||||
@@ -11,45 +11,46 @@ Feature: Warning bar
|
||||
- finished is an outage that has explicitly been marked as finished.
|
||||
- stopped is an outage that has already ended but not explicitly marked as finished.
|
||||
|
||||
|
||||
Background:
|
||||
Given the authentication plugin "outage" is enabled
|
||||
|
||||
Scenario: This is how an outage should happen without maintenance mode and manual finish.
|
||||
Given there is the following outage:
|
||||
| warnbefore | startsin | stopsafter |
|
||||
| 10 | 20 | 10 |
|
||||
When I am on homepage
|
||||
Then I should not see the warning bar
|
||||
When I wait until the outage warns
|
||||
And I reload the page
|
||||
Then I should see "Shutting down in" in the warning bar
|
||||
When I wait until the outage starts
|
||||
And I reload the page
|
||||
Then I should see "Back online at" in the warning bar
|
||||
When I wait until the outage stops
|
||||
Then I should see "We are back online!" in the warning bar
|
||||
When I reload the page
|
||||
Then I should not see the warning bar
|
||||
#
|
||||
#
|
||||
# Scenario Outline: Some stages should show its own warning message.
|
||||
# Given there is a "<type>" outage
|
||||
# When I am on homepage
|
||||
# Then I should see "<see>" in the warning bar
|
||||
#
|
||||
# Examples:
|
||||
# | type | see |
|
||||
# | warning | Shutting down in |
|
||||
# | ongoing | Back online at |
|
||||
#
|
||||
#
|
||||
# Scenario Outline: Some stages should not have a warning bar.
|
||||
# Given there is a "<type>" outage
|
||||
|
||||
# Scenario: This is how an outage should happend without maintenance mode and manual finish.
|
||||
# Given there is the following outage:
|
||||
# | warnbefore | startsin | stopsafter |
|
||||
# | 10 | 20 | 10 |
|
||||
# When I am on homepage
|
||||
# Then I should not see the warning bar
|
||||
#
|
||||
# Examples:
|
||||
# | type |
|
||||
# | waiting |
|
||||
# | finished |
|
||||
# | stopped |
|
||||
# When I wait until the outage warns
|
||||
# And I reload the page
|
||||
# Then I should see "Shutting down in" in the warning bar
|
||||
# When I wait until the outage starts
|
||||
# Then I should see "Back online at" in the warning bar
|
||||
# When I wait until the outage stops
|
||||
# Then I should see "We are back online!" in the warning bar
|
||||
# When I reload the page
|
||||
# Then I should not see the warning bar
|
||||
|
||||
|
||||
Scenario Outline: Some stages should show its own warning message.
|
||||
Given there is a "<type>" outage
|
||||
When I am on homepage
|
||||
Then I should see "<see>" in the warning bar
|
||||
|
||||
Examples:
|
||||
| type | see |
|
||||
| warning | Shutting down in |
|
||||
| ongoing | Back online at |
|
||||
|
||||
|
||||
Scenario Outline: Some stages should not have a warning bar.
|
||||
Given there is a "<type>" outage
|
||||
When I am on homepage
|
||||
Then I should not see the warning bar
|
||||
|
||||
Examples:
|
||||
| type |
|
||||
| waiting |
|
||||
| finished |
|
||||
| stopped |
|
||||
|
||||
@@ -69,5 +69,9 @@ abstract class auth_outage_base_testcase extends advanced_testcase {
|
||||
|
||||
parent::setUp();
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
// Do not use https.
|
||||
$CFG->wwwroot = 'http://www.example.com/moodle';
|
||||
$CFG->httpswwwroot = $CFG->wwwroot;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
'<body>Content<link rel="stylesheet" href="'.$externalcsslink.'"></body></html>';
|
||||
$generated = $this->generated_page_html($html);
|
||||
|
||||
self::assertContains('www.example.com/moodle/auth/outage/file.php?file=', $generated);
|
||||
self::assertContains('http://www.example.com/moodle/auth/outage/file.php?file=', $generated);
|
||||
self::assertNotContains($localcsslink, $generated);
|
||||
self::assertContains($externalcsslink, $generated);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
'<body><img src="'.$localimglink.'">Content<img src="'.$externalimglink.'" /></body></html>';
|
||||
$generated = $this->generated_page_html($html);
|
||||
|
||||
self::assertContains('www.example.com/moodle/auth/outage/file.php?file=', $generated);
|
||||
self::assertContains('http://www.example.com/moodle/auth/outage/file.php?file=', $generated);
|
||||
self::assertNotContains($localimglink, $generated);
|
||||
self::assertContains($externalimglink, $generated);
|
||||
}
|
||||
@@ -158,7 +158,7 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
$generated = $this->generated_page_html($html);
|
||||
|
||||
self::assertNotContains($link, $generated);
|
||||
self::assertContains('www.example.com/moodle/auth/outage/file.php?file=', $generated);
|
||||
self::assertContains('http://www.example.com/moodle/auth/outage/file.php?file=', $generated);
|
||||
}
|
||||
|
||||
public function test_previewpath() {
|
||||
@@ -172,7 +172,7 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
$generated = trim(file_get_contents($page->get_io()->get_template_file()));
|
||||
|
||||
self::assertNotContains($link, $generated);
|
||||
self::assertContains('www.example.com/moodle/auth/outage/file.php?file=preview%2F', $generated);
|
||||
self::assertContains('http://www.example.com/moodle/auth/outage/file.php?file=preview%2F', $generated);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,7 +256,7 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
|
||||
public function test_get_url_for_file() {
|
||||
$io = new maintenance_static_page_io();
|
||||
self::assertContains('www.example.com/moodle/auth/outage/file.php?file=img.png', $io->get_url_for_file('img.png'));
|
||||
self::assertSame('http://www.example.com/moodle/auth/outage/file.php?file=img.png', $io->get_url_for_file('img.png'));
|
||||
}
|
||||
|
||||
public function test_is_url() {
|
||||
|
||||
@@ -105,6 +105,8 @@ class outagelib_test extends advanced_testcase {
|
||||
$size = strlen($CFG->additionalhtmltopofbody);
|
||||
outagelib::inject();
|
||||
self::assertSame($size, strlen($CFG->additionalhtmltopofbody));
|
||||
|
||||
$this->resetDebugging(); // Function pix_url deprecated in Moodle 33+.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,6 +142,8 @@ class outagelib_test extends advanced_testcase {
|
||||
outagelib::reinject();
|
||||
self::assertContains('<style>', $CFG->additionalhtmltopofbody);
|
||||
self::assertContains('<script>', $CFG->additionalhtmltopofbody);
|
||||
|
||||
$this->resetDebugging(); // Function pix_url deprecated in Moodle 33+.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,7 +293,7 @@ class outagelib_test extends advanced_testcase {
|
||||
if ((time() >= 123) && (time() < 456)) {
|
||||
define('MOODLE_INTERNAL', true);
|
||||
require_once($CFG->dirroot.'/lib/moodlelib.php');
|
||||
if (!remoteip_in_list('hey\'\"you
|
||||
if (!remoteip_in_list('heyyou
|
||||
a.b.c.d
|
||||
e.e.e.e/20')) {
|
||||
header($_SERVER['SERVER_PROTOCOL'] . ' 503 Moodle under maintenance');
|
||||
@@ -499,6 +503,8 @@ EOT;
|
||||
outagelib::reinject();
|
||||
|
||||
self::assertNotEmpty($CFG->additionalhtmltopofbody);
|
||||
|
||||
$this->resetDebugging(); // Function pix_url deprecated in Moodle 33+.
|
||||
}
|
||||
|
||||
private function create_outage() {
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->component = "auth_outage";
|
||||
$plugin->version = 2019022200; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->release = '1.0.10'; // Human-readable release information.
|
||||
$plugin->requires = 2017051500; // Requires 3.3 and higher.
|
||||
$plugin->version = 2017071300; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->release = '1.0.9'; // Human-readable release information.
|
||||
$plugin->requires = 2014051200; // Requires Moodle 2.7 or later. Moodle 3.0 or later recommended.
|
||||
$plugin->maturity = MATURITY_STABLE; // Suitable for PRODUCTION environments!
|
||||
|
||||
@@ -7,7 +7,7 @@ If you need to make changes here, remember to update your settings inside Moodle
|
||||
background-color: red;
|
||||
box-sizing: content-box;
|
||||
color: white;
|
||||
height: 100px;
|
||||
height: 90px;
|
||||
left: 0;
|
||||
padding: 0;
|
||||
position: fixed;
|
||||
@@ -19,51 +19,47 @@ If you need to make changes here, remember to update your settings inside Moodle
|
||||
}
|
||||
|
||||
#auth_outage_warningbar_box.auth_outage_warning_period {
|
||||
background:
|
||||
repeating-linear-gradient(
|
||||
background: repeating-linear-gradient(
|
||||
-45deg,
|
||||
#ff7c00,
|
||||
#ff7c00 10px,
|
||||
#ff6c00 10px,
|
||||
#ff6c00 20px
|
||||
);
|
||||
);
|
||||
background-color: #ff7c00;
|
||||
}
|
||||
|
||||
#auth_outage_warningbar_box.auth_outage_imminent_period {
|
||||
background:
|
||||
repeating-linear-gradient(
|
||||
background: repeating-linear-gradient(
|
||||
-45deg,
|
||||
#a000a0,
|
||||
#a000a0 10px,
|
||||
#800080 10px,
|
||||
#800080 20px
|
||||
);
|
||||
);
|
||||
background-color: #800080;
|
||||
}
|
||||
|
||||
#auth_outage_warningbar_box.auth_outage_ongoing_period {
|
||||
background:
|
||||
repeating-linear-gradient(
|
||||
background: repeating-linear-gradient(
|
||||
-45deg,
|
||||
#e00,
|
||||
#e00 10px,
|
||||
#c00 10px,
|
||||
#c00 20px
|
||||
);
|
||||
background-color: #e00;
|
||||
#ee0000,
|
||||
#ee0000 10px,
|
||||
#cc0000 10px,
|
||||
#cc0000 20px
|
||||
);
|
||||
background-color: #ee0000;
|
||||
}
|
||||
|
||||
#auth_outage_warningbar_box.auth_outage_finished_period {
|
||||
background:
|
||||
repeating-linear-gradient(
|
||||
background: repeating-linear-gradient(
|
||||
-45deg,
|
||||
#0a0,
|
||||
#0a0 10px,
|
||||
#090 10px,
|
||||
#090 20px
|
||||
);
|
||||
background-color: #090;
|
||||
#00aa00,
|
||||
#00aa00 10px,
|
||||
#009900 10px,
|
||||
#009900 20px
|
||||
);
|
||||
background-color: #009900;
|
||||
}
|
||||
|
||||
.auth_outage_warningbar_center {
|
||||
@@ -99,14 +95,10 @@ a.auth_outage_warningbar_box_finish:hover {
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
.navbar.navbar-fixed-top {
|
||||
top: 90px;
|
||||
}
|
||||
|
||||
.auth_outage_warningbar_spacer {
|
||||
height: 80px;
|
||||
}
|
||||
|
||||
body.auth_outage #nav-drawer {
|
||||
top: 150px;
|
||||
}
|
||||
|
||||
body.auth_outage nav.fixed-top.navbar {
|
||||
top: 100px;
|
||||
}
|
||||
@@ -114,10 +114,8 @@ var authOutageWarningBar = {
|
||||
seconds2hms: function(seconds) {
|
||||
var minutes = Math.floor(seconds / 60);
|
||||
var hours = Math.floor(minutes / 60);
|
||||
var days = Math.floor(hours / 24);
|
||||
seconds %= 60;
|
||||
minutes %= 60;
|
||||
hours %= 24;
|
||||
// Cross-browser simple solution for padding zeroes.
|
||||
if (minutes < 10) {
|
||||
minutes = "0" + minutes;
|
||||
@@ -125,15 +123,6 @@ var authOutageWarningBar = {
|
||||
if (seconds < 10) {
|
||||
seconds = "0" + seconds;
|
||||
}
|
||||
if (days > 0) {
|
||||
if (days > 1) {
|
||||
days = days + ' days ';
|
||||
} else {
|
||||
days = days + ' day ';
|
||||
}
|
||||
} else {
|
||||
days = '';
|
||||
}
|
||||
return days + hours + ':' + minutes + ':' + seconds;
|
||||
return hours + ':' + minutes + ':' + seconds;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ if (!$viewbag['static']) {
|
||||
if (is_siteadmin()) {
|
||||
$url = new moodle_url('/auth/outage/finish.php', ['id' => $viewbag['outage']->id]);
|
||||
$text = html_writer::empty_tag('img', [
|
||||
'src' => $OUTPUT->image_url('t/check'),
|
||||
'src' => $OUTPUT->pix_url('t/check'),
|
||||
'alt' => get_string('finish', 'auth_outage'),
|
||||
'class' => 'iconsmall',
|
||||
]).' '.get_string('finish', 'auth_outage');
|
||||
|
||||
Reference in New Issue
Block a user