36 Commits

Author SHA1 Message Date
Nathan Nguyen
3f1cfcb908 WR#310007 - Fix failed unit test 2019-04-23 13:21:44 +10:00
Brendan Heywood
dec4c7bf53 Fixed ipwhitelist escaping issue #150 2019-03-28 14:32:20 +11:00
Dmitrii Metelkin
e94d9c94ea Merge pull request #147 from catalyst/issues#146
Add an icon map for calendar events to fix #146
2019-02-22 10:35:57 +11:00
Dmitrii Metelkin
030fec75e1 Add an icon map for calendar events to fix #146 2019-02-22 10:32:19 +11:00
tuanngocnguyen
cf85a04ddc Merge pull request #145 from catalyst/issue#144
user date
2018-12-06 16:53:17 +11:00
Nathan Nguyen
c820bb1c0b Fix day display 2018-12-06 15:42:56 +11:00
Nathan Nguyen
e1b6279437 user date 2018-12-06 15:07:58 +11:00
tuanngocnguyen
846879d2d6 Merge pull request #143 from catalyst/issue#140
#140 Turn off check_wwwroot_accessible
2018-12-03 16:24:54 +11:00
Nathan Nguyen
38f838d84e Turn off check_wwwroot_accessible on admin pages other than outage setting page 2018-12-03 14:36:54 +11:00
Nathan Nguyen
df649c8133 change relative link to absolute link 2018-11-30 10:40:43 +11:00
Dmitrii Metelkin
8f5e5dbb50 Merge pull request #139 from catalyst/StyleSheetLoadingError
Fix problem with loading stylesheet in preview mode
2018-11-16 13:36:02 +11:00
Nathan Nguyen
f4962f22a8 Fix problem with loading stylesheet in preview mode 2018-11-16 10:40:08 +11:00
Dan Marsden
1ec50dadb2 add details about version support 2018-10-11 14:01:28 +13:00
Ilya Tregubov
54045d5ce1 Incease timeout to prevent settings page throwing error (from time to time) 2018-10-11 11:15:04 +11:00
Dan Marsden
e84534f7b6 Fix #127 fix boost header when outage plugin in use. 2018-10-05 15:19:12 +13:00
Dan Marsden
ceb9e065b9 Use correct check for behat running. 2018-10-05 14:21:03 +13:00
Dan Marsden
3639883d30 Don't use curl when running behat tests to get page outage.
Behat step improvements.
2018-10-05 13:45:08 +13:00
Dan Marsden
6c69d46ebe Fix some behat steps. 2018-10-05 11:49:59 +13:00
Dan Marsden
6cea3f52c2 Fix travis config for old php versions. 2018-10-05 11:08:56 +13:00
Dan Marsden
49bdb687c3 Fix #120 increase timeout values to prevent ci failures. 2018-10-05 10:20:59 +13:00
Dan Marsden
c175333f88 Remove incorrect usage of example.com in tests.
remove http part of test - site might be https.
2018-10-03 22:55:09 +13:00
Dan Marsden
3e5446d8d1 tidy up coding guideline travis failures. 2018-10-03 22:10:39 +13:00
Dan Marsden
6c489ad20e codiing guideline improvements to css file. 2018-10-03 15:50:27 +13:00
Dan Marsden
a33e80b4aa Coding guidelines - tidy up some spacing in behat tests. 2018-10-03 15:46:11 +13:00
Dan Marsden
fa0641ec47 update travis config. 2018-10-03 15:34:13 +13:00
Dan Marsden
20df09d3e9 Revert "Temporarly disabling one scenario test, see Issue #68."
This reverts commit 42fec9e752.
2018-10-03 15:28:03 +13:00
Dan Marsden
ff59dac023 Revert "Travis is freezing with a few behat tests which creates outages. It works fine locally both manually and with selenium. Ignoring tests and opening issue #77 to deal with it later as the code works fine."
This reverts commit fc2349f312.
2018-10-03 15:27:21 +13:00
adamlynam-catalyst
5aaf0ddeda Adding check for use of ip restrictions before warning (#134)
* Adding check for use of ip restrictions before warning about bootstrap.php not being included in config.php

* Replacing reference to same class with self
2018-10-03 15:22:31 +13:00
Dan Marsden
b3917b7b63 fix postgres version used in travis. 2018-10-03 15:20:26 +13:00
Dan Marsden
882f6a1afc Fix #124 use correct urls in redirects. 2018-10-03 15:16:36 +13:00
Dan Marsden
07e26e312c Convert deprecated pix_url calls. 2018-10-03 15:10:59 +13:00
Dan Marsden
92f7ec0541 add behat tests back to master branch. 2018-10-03 15:10:33 +13:00
Dan Marsden
84b35f01fa Master branch now requires 3.3 and higher so we can merge
version specific changes.
2018-10-03 15:00:20 +13:00
SECRET Olivier
62bf9f38ef Merge pull request #133 from catalyst/oliviersecret2
add privacy provider
2018-07-25 10:34:00 +10:00
SECRET Olivier
cbebb4a839 Fix lang String 2018-07-02 12:48:25 +10:00
Olivier SECRET
aee5ae8adb add privacy provider
to fix unit test failure
2018-06-25 11:48:15 +10:00
25 changed files with 263 additions and 186 deletions

View File

@@ -1,55 +1,60 @@
language: php
notifications:
email:
recipients:
- daniel.roperto@catalyst-au.net
sudo: true
addons:
firefox: "47.0.1"
postgresql: "9.4"
apt:
packages:
- oracle-java8-installer
- oracle-java8-set-default
cache:
directories:
- $HOME/.composer/cache
addons:
postgresql: "9.3"
- $HOME/.composer/cache
- $HOME/.npm
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.5
env: DB=pgsql MOODLE_BRANCH=MOODLE_30_STABLE
- php: 5.5
env: DB=mysqli MOODLE_BRANCH=MOODLE_30_STABLE
- 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 moodlerooms/moodle-plugin-ci ci ^1
- 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 -vvv
- moodle-plugin-ci install
script:
- 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
- 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

View File

@@ -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,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?
-------------

View File

@@ -40,13 +40,10 @@ 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();
@@ -85,5 +82,4 @@ $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);
}

View File

@@ -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(

View File

@@ -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.
}
}

View File

@@ -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, 1); // It is localhost, time to connect is enough.
curl_setopt($curl, CURLOPT_TIMEOUT, 5); // It is localhost, time to fetch index is enough.
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.
$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 = str_replace('\'"', '', $allowedips);
$allowedips = addslashes($allowedips);
$code = <<<'EOT'
<?php
@@ -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) {

View File

@@ -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',
]),

View File

@@ -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')]);

View File

@@ -0,0 +1,54 @@
<?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';
}
}

View File

@@ -36,10 +36,10 @@ $PAGE->set_url(new moodle_url('/auth/outage/manage.php'));
$mform = new delete();
if ($mform->is_cancelled()) {
redirect('/auth/outage/manage.php');
redirect(new moodle_url('/auth/outage/manage.php'));
} else if ($fromform = $mform->get_data()) {
outagedb::delete($fromform->id);
redirect('/auth/outage/manage.php');
redirect(new moodle_url('/auth/outage/manage.php'));
}
$id = required_param('id', PARAM_INT);

View File

@@ -39,10 +39,10 @@ $PAGE->set_url(new moodle_url('/auth/outage/manage.php'));
$mform = new edit();
if ($mform->is_cancelled()) {
redirect('/auth/outage/manage.php');
redirect(new moodle_url('/auth/outage/manage.php'));
} else if ($outage = $mform->get_data()) {
$id = outagedb::save($outage);
redirect('/auth/outage/manage.php#auth_outage_id_'.$id);
redirect($CFG->wwwroot. '/auth/outage/manage.php#auth_outage_id_'.$id);
}
$clone = optional_param('clone', 0, PARAM_INT);

View File

@@ -36,10 +36,10 @@ $PAGE->set_url(new moodle_url('/auth/outage/manage.php'));
$mform = new finish();
if ($mform->is_cancelled()) {
redirect('/auth/outage/manage.php');
redirect(new moodle_url('/auth/outage/manage.php'));
} else if ($fromform = $mform->get_data()) {
outagedb::finish($fromform->id);
redirect('/auth/outage/manage.php');
redirect(new moodle_url('/auth/outage/manage.php'));
}
$id = required_param('id', PARAM_INT);

View File

@@ -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}.';
@@ -143,3 +143,8 @@ $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
View File

@@ -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',
];
}

View File

@@ -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> |

View File

@@ -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"

View File

@@ -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

View File

@@ -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 |

View File

@@ -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;
}
}

View File

@@ -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() {

View File

@@ -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+.
}
/**
@@ -293,7 +289,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('heyyou
if (!remoteip_in_list('hey\'\"you
a.b.c.d
e.e.e.e/20')) {
header($_SERVER['SERVER_PROTOCOL'] . ' 503 Moodle under maintenance');
@@ -503,8 +499,6 @@ EOT;
outagelib::reinject();
self::assertNotEmpty($CFG->additionalhtmltopofbody);
$this->resetDebugging(); // Function pix_url deprecated in Moodle 33+.
}
private function create_outage() {

View File

@@ -28,7 +28,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->component = "auth_outage";
$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->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!

View File

@@ -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;
}

View File

@@ -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;
}
};

View File

@@ -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');