mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-17 05:48:43 +02:00
Compare commits
31 Commits
MOODLE_32_
...
1.0.10
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e94d9c94ea | ||
|
|
030fec75e1 | ||
|
|
cf85a04ddc | ||
|
|
c820bb1c0b | ||
|
|
e1b6279437 | ||
|
|
846879d2d6 | ||
|
|
38f838d84e | ||
|
|
df649c8133 | ||
|
|
8f5e5dbb50 | ||
|
|
f4962f22a8 | ||
|
|
1ec50dadb2 | ||
|
|
54045d5ce1 | ||
|
|
e84534f7b6 | ||
|
|
ceb9e065b9 | ||
|
|
3639883d30 | ||
|
|
6c69d46ebe | ||
|
|
6cea3f52c2 | ||
|
|
49bdb687c3 | ||
|
|
c175333f88 | ||
|
|
3e5446d8d1 | ||
|
|
6c489ad20e | ||
|
|
a33e80b4aa | ||
|
|
fa0641ec47 | ||
|
|
20df09d3e9 | ||
|
|
ff59dac023 | ||
|
|
5aaf0ddeda | ||
|
|
b3917b7b63 | ||
|
|
882f6a1afc | ||
|
|
07e26e312c | ||
|
|
92f7ec0541 | ||
|
|
84b35f01fa |
20
.github/workflows/moodle-release.yml
vendored
20
.github/workflows/moodle-release.yml
vendored
@@ -1,20 +0,0 @@
|
||||
#
|
||||
# Whenever version.php is changed, add the latest version
|
||||
# to the Moodle Plugins directory at https://moodle.org/plugins
|
||||
#
|
||||
name: Releasing in the Plugins directory
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- MOODLE_32_STABLE
|
||||
paths:
|
||||
- 'version.php'
|
||||
|
||||
jobs:
|
||||
workflow_group_27_to_32_release:
|
||||
uses: catalyst/catalyst-moodle-workflows/.github/workflows/group-27-to-32-release.yml@main
|
||||
with:
|
||||
plugin_name: auth_outage
|
||||
secrets:
|
||||
moodle_org_token: ${{ secrets.MOODLE_ORG_TOKEN }}
|
||||
60
.travis.yml
Normal file
60
.travis.yml
Normal file
@@ -0,0 +1,60 @@
|
||||
language: php
|
||||
|
||||
sudo: true
|
||||
|
||||
addons:
|
||||
firefox: "47.0.1"
|
||||
postgresql: "9.4"
|
||||
apt:
|
||||
packages:
|
||||
- oracle-java8-installer
|
||||
- oracle-java8-set-default
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache
|
||||
- $HOME/.npm
|
||||
|
||||
php:
|
||||
- 7.0
|
||||
|
||||
env:
|
||||
- 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: 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
|
||||
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
|
||||
|
||||
install:
|
||||
- moodle-plugin-ci install
|
||||
|
||||
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
|
||||
13
README.md
13
README.md
@@ -1,7 +1,9 @@
|
||||
(https://github.com/catalyst/moodle-auth_outage/actions)
|
||||
<a href="https://travis-ci.org/catalyst/moodle-auth_outage">
|
||||
<img src="https://travis-ci.org/catalyst/moodle-auth_outage.svg?branch=master">
|
||||
</a>
|
||||
|
||||
# Moodle Outage manager plugin
|
||||
|
||||
* [Version Support](#version-support)
|
||||
* [What is this?](#what-is-this)
|
||||
* [Moodle Requirements](#moodle-requirements)
|
||||
* [Screenshots](#screenshots)
|
||||
@@ -11,6 +13,11 @@
|
||||
* [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?
|
||||
-------------
|
||||
|
||||
@@ -97,7 +104,7 @@ Creates a new outage.
|
||||
-c, --clone clone another outage except for the start time.
|
||||
-a, --autostart must be Y or N, sets if the outage automatically triggers maintenance mode.
|
||||
-w, --warn how many seconds before it starts to display a warning.
|
||||
-s, --start in how many seconds should this outage start or unix time to start outage. Required.
|
||||
-s, --start in how many seconds should this outage start. Required.
|
||||
-d, --duration how many seconds should the outage last.
|
||||
-t, --title the title of the outage.
|
||||
-e, --description the description of the outage.
|
||||
|
||||
@@ -170,9 +170,7 @@ class create extends clibase {
|
||||
$this->become_admin_user();
|
||||
|
||||
// Create the outage.
|
||||
// If time is above 1500000000 then it must be a unix time timestamp, otherwise they are trying to create
|
||||
// an outage 47 years in advance.
|
||||
$start = $options['start'] > 1500000000 ? $options['start'] : $this->time + $options['start'];
|
||||
$start = $this->time + $options['start'];
|
||||
$outage = new outage([
|
||||
'autostart' => $options['autostart'],
|
||||
'warntime' => $start - $options['warn'],
|
||||
|
||||
@@ -57,7 +57,7 @@ class maintenance_static_page {
|
||||
|
||||
if (is_null($outage)) {
|
||||
$html = null;
|
||||
} else if (PHPUNIT_TEST) {
|
||||
} else if (PHPUNIT_TEST || defined('BEHAT_SITE_RUNNING')) {
|
||||
$html = '<html></html>';
|
||||
} else {
|
||||
$data = maintenance_static_page_io::file_get_data(
|
||||
|
||||
@@ -30,6 +30,7 @@ use coding_exception;
|
||||
use DOMDocument;
|
||||
use DOMElement;
|
||||
use invalid_state_exception;
|
||||
use moodle_url;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -179,10 +180,12 @@ class maintenance_static_page_generator {
|
||||
foreach ($links as $link) {
|
||||
$rel = $link->getAttribute("rel");
|
||||
$href = $link->getAttribute("href");
|
||||
if (($rel != 'shortcut icon') || ($href == '')) {
|
||||
continue;
|
||||
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.
|
||||
}
|
||||
$link->setAttribute('href', $this->io->generate_file_url($href)); // Works for most image formats.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,10 +197,12 @@ class maintenance_static_page_generator {
|
||||
|
||||
foreach ($links as $link) {
|
||||
$src = $link->getAttribute("src");
|
||||
if ($src == '') {
|
||||
continue;
|
||||
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.
|
||||
}
|
||||
$link->setAttribute('src', $this->io->generate_file_url($src)); // Works for most image formats.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -326,11 +326,11 @@ EOT;
|
||||
* @internal bootstrap_renderer $OUTPUT
|
||||
*/
|
||||
public static function generate_plugin_configuration_warning() {
|
||||
global $CFG, $OUTPUT;
|
||||
global $CFG, $OUTPUT, $PAGE;
|
||||
|
||||
$message = [];
|
||||
|
||||
if (!isset($CFG->auth_outage_bootstrap_loaded) || !$CFG->auth_outage_bootstrap_loaded) {
|
||||
if (trim(self::get_config()->allowedips) != '' && (!isset($CFG->auth_outage_bootstrap_loaded) || !$CFG->auth_outage_bootstrap_loaded)) {
|
||||
$message[] = get_string('configurationwarning', 'auth_outage');
|
||||
}
|
||||
|
||||
@@ -338,8 +338,10 @@ EOT;
|
||||
$message[] = get_string('configurationdisabled', 'auth_outage');
|
||||
}
|
||||
|
||||
if (!self::check_wwwroot_accessible()) {
|
||||
$message[] = get_string('configurationinaccessiblewwwroot', 'auth_outage', ['wwwroot' => $CFG->wwwroot]);
|
||||
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 (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->pix_url('t/preview'),
|
||||
'src' => $OUTPUT->image_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->pix_url('t/edit'),
|
||||
'src' => $OUTPUT->image_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->pix_url('t/copy'),
|
||||
'src' => $OUTPUT->image_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->pix_url('t/check'),
|
||||
'src' => $OUTPUT->image_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->pix_url('t/delete'),
|
||||
'src' => $OUTPUT->image_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->pix_url('t/edit'), 'alt' => get_string('edit'), 'class' => 'iconsmall']
|
||||
['src' => $OUTPUT->image_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->pix_url('t/delete'), 'alt' => get_string('delete'), 'class' => 'iconsmall']
|
||||
['src' => $OUTPUT->image_url('t/delete'), 'alt' => get_string('delete'), 'class' => 'iconsmall']
|
||||
);
|
||||
$linkdelete = html_writer::link($url, $img, ['title' => get_string('delete')]);
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ $string['clicreateparamdescription'] = 'the description of the outage.';
|
||||
$string['clicreateparamduration'] = 'how many seconds should the outage last.';
|
||||
$string['clicreateparamhelp'] = 'shows parameters help.';
|
||||
$string['clicreateparamonlyid'] = 'only outputs the new outage id, useful for scripts.';
|
||||
$string['clicreateparamstart'] = 'in how many seconds should this outage start or unix time to start outage. Required.';
|
||||
$string['clicreateparamstart'] = 'in how many seconds should this outage start. Required.';
|
||||
$string['clicreateparamtitle'] = 'the title of the outage.';
|
||||
$string['clicreateparamwarn'] = 'how many seconds before it starts to display a warning.';
|
||||
$string['clifinishhelp'] = 'Finishes an ongoing outage.';
|
||||
@@ -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';
|
||||
$string['menumanage'] = 'Manage outages';
|
||||
$string['messageoutagebackonline'] = 'We are back online!';
|
||||
$string['messageoutagebackonlinedescription'] = 'You may resume browsing safely.';
|
||||
$string['messageoutageongoing'] = 'Back online at {$a->stop}.';
|
||||
|
||||
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) {
|
||||
if ($basename !== $file && $file !== 'preview/' . $basename) {
|
||||
// @codingStandardsIgnoreStart
|
||||
if (!PHPUNIT_TEST) {
|
||||
error_log('Possible attempt for Path Traversal Attack (only filename expected): '.$file);
|
||||
@@ -87,3 +87,14 @@ 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,9 +11,8 @@ 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 "Settings" node in "Site administration > Plugins > Authentication > Outage manager"
|
||||
When I navigate to "Plugins > Authentication > Outage manager > Settings" in site administration
|
||||
And I set the following fields to these values:
|
||||
| s_auth_outage_default_autostart | <autostart> |
|
||||
| s_auth_outage_default_warning_duration[v] | <warning> |
|
||||
|
||||
@@ -8,14 +8,11 @@ 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
|
||||
And I am on homepage
|
||||
When I navigate to "Settings" node in "Site administration > Plugins > Authentication > Outage manager"
|
||||
When I navigate to "Plugins > Authentication > Outage manager > Settings" in site administration
|
||||
Then I should see "Allowed IP list"
|
||||
And I should see an empty settings text area "allowedips"
|
||||
|
||||
@@ -11,22 +11,19 @@ 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 "Manage" node in "Site administration > Plugins > Authentication > Outage manager"
|
||||
When I navigate to "Plugins > Authentication > Outage manager > Manage outages" in site administration
|
||||
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
|
||||
@@ -40,7 +37,6 @@ 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
|
||||
@@ -59,14 +55,12 @@ 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
|
||||
@@ -75,29 +69,26 @@ 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: 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: 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
|
||||
@@ -109,7 +100,6 @@ 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,46 +11,45 @@ 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 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
|
||||
# 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
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
# When I am on homepage
|
||||
# Then I should not see the warning bar
|
||||
#
|
||||
# Examples:
|
||||
# | type |
|
||||
# | waiting |
|
||||
# | finished |
|
||||
# | stopped |
|
||||
|
||||
@@ -69,9 +69,5 @@ 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('http://www.example.com/moodle/auth/outage/file.php?file=', $generated);
|
||||
self::assertContains('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('http://www.example.com/moodle/auth/outage/file.php?file=', $generated);
|
||||
self::assertContains('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('http://www.example.com/moodle/auth/outage/file.php?file=', $generated);
|
||||
self::assertContains('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('http://www.example.com/moodle/auth/outage/file.php?file=preview%2F', $generated);
|
||||
self::assertContains('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::assertSame('http://www.example.com/moodle/auth/outage/file.php?file=img.png', $io->get_url_for_file('img.png'));
|
||||
self::assertContains('www.example.com/moodle/auth/outage/file.php?file=img.png', $io->get_url_for_file('img.png'));
|
||||
}
|
||||
|
||||
public function test_is_url() {
|
||||
|
||||
@@ -105,8 +105,6 @@ 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+.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,8 +140,6 @@ 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+.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -503,8 +499,6 @@ EOT;
|
||||
outagelib::reinject();
|
||||
|
||||
self::assertNotEmpty($CFG->additionalhtmltopofbody);
|
||||
|
||||
$this->resetDebugging(); // Function pix_url deprecated in Moodle 33+.
|
||||
}
|
||||
|
||||
private function create_outage() {
|
||||
|
||||
@@ -28,8 +28,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->component = "auth_outage";
|
||||
$plugin->version = 2018062502; // 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->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->maturity = MATURITY_STABLE; // Suitable for PRODUCTION environments!
|
||||
$plugin->supported = [27, 32]; // A range of branch numbers of supported moodle versions.
|
||||
|
||||
@@ -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: 90px;
|
||||
height: 100px;
|
||||
left: 0;
|
||||
padding: 0;
|
||||
position: fixed;
|
||||
@@ -19,47 +19,51 @@ 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,
|
||||
#ee0000,
|
||||
#ee0000 10px,
|
||||
#cc0000 10px,
|
||||
#cc0000 20px
|
||||
);
|
||||
background-color: #ee0000;
|
||||
#e00,
|
||||
#e00 10px,
|
||||
#c00 10px,
|
||||
#c00 20px
|
||||
);
|
||||
background-color: #e00;
|
||||
}
|
||||
|
||||
#auth_outage_warningbar_box.auth_outage_finished_period {
|
||||
background: repeating-linear-gradient(
|
||||
background:
|
||||
repeating-linear-gradient(
|
||||
-45deg,
|
||||
#00aa00,
|
||||
#00aa00 10px,
|
||||
#009900 10px,
|
||||
#009900 20px
|
||||
);
|
||||
background-color: #009900;
|
||||
#0a0,
|
||||
#0a0 10px,
|
||||
#090 10px,
|
||||
#090 20px
|
||||
);
|
||||
background-color: #090;
|
||||
}
|
||||
|
||||
.auth_outage_warningbar_center {
|
||||
@@ -95,10 +99,14 @@ 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,8 +114,10 @@ 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;
|
||||
@@ -123,6 +125,15 @@ var authOutageWarningBar = {
|
||||
if (seconds < 10) {
|
||||
seconds = "0" + seconds;
|
||||
}
|
||||
return hours + ':' + minutes + ':' + seconds;
|
||||
if (days > 0) {
|
||||
if (days > 1) {
|
||||
days = days + ' days ';
|
||||
} else {
|
||||
days = days + ' day ';
|
||||
}
|
||||
} else {
|
||||
days = '';
|
||||
}
|
||||
return days + 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->pix_url('t/check'),
|
||||
'src' => $OUTPUT->image_url('t/check'),
|
||||
'alt' => get_string('finish', 'auth_outage'),
|
||||
'class' => 'iconsmall',
|
||||
]).' '.get_string('finish', 'auth_outage');
|
||||
|
||||
Reference in New Issue
Block a user