8 Commits

Author SHA1 Message Date
Anupama Dharmajan
2fb8f2f186 Bump version 2022-01-13 16:49:48 +11:00
Anupama Dharmajan
907cf73e54 Update plugin name in moodle release workflow 2022-01-13 16:46:51 +11:00
Brendan Heywood
c6c0382eab Merge pull request #276 from catalyst/MOODLE_32_STABLE-reusable-workflows
Add reusable workflow for moodle release
2022-01-13 16:40:36 +11:00
Anupama Dharmajan
7bf8b9a748 Add reusable workflow for moodle release 2022-01-13 16:27:31 +11:00
Brendan Heywood
99e43b6c76 Merge pull request #198 from ledship/MOODLE_32_STABLE-time
Accept unix time for --start CLI option to MOODLE_32_STABLE branch
2020-07-23 14:17:07 +10:00
Alexander
1d1fb94142 Accept unix time for --start CLI option 2020-07-23 14:26:03 +12:00
Brendan Heywood
2366b3ea18 Merge pull request #205 from ledship/MOODLE_32_STABLE-ci
Fix MOODLE_32_STABLE travis config
2020-07-22 13:41:33 +10:00
Alexander
a252f55bdf Fix travis CI and use correct branch in README 2020-07-22 14:02:28 +12:00
11 changed files with 41 additions and 136 deletions

20
.github/workflows/moodle-release.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
#
# 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 }}

View File

@@ -1,47 +0,0 @@
language: php
cache:
directories:
- $HOME/.composer/cache
addons:
postgresql: "9.5"
php:
- 7.0
services:
- mysql
env:
- DB=pgsql MOODLE_BRANCH=MOODLE_30_STABLE
- DB=pgsql MOODLE_BRANCH=MOODLE_31_STABLE
- DB=pgsql MOODLE_BRANCH=MOODLE_32_STABLE
matrix:
include:
- php: 5.6
env: DB=pgsql MOODLE_BRANCH=MOODLE_30_STABLE
- php: 5.6
env: DB=mysqli MOODLE_BRANCH=MOODLE_30_STABLE
before_install:
- phpenv config-rm xdebug.ini
- cd ../..
- composer selfupdate
- 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 -vvv
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

View File

@@ -1,6 +1,4 @@
<a href="https://travis-ci.org/catalyst/moodle-auth_outage">
<img src="https://travis-ci.org/catalyst/moodle-auth_outage.svg?branch=master">
</a>
![Build Status](https://github.com/catalyst/moodle-auth_outage/actions/workflows/ci.yml/badge.svg?branch=MOODLE_32_STABLE)(https://github.com/catalyst/moodle-auth_outage/actions)
# Moodle Outage manager plugin
@@ -39,16 +37,6 @@ If you have an older version of Moodle you can still make it work but you will
need to manually add one extra plugin, please check:
* https://github.com/catalyst/moodle-local_outage
Branches
--------
| Moodle version | Branch | PHP |
| ----------------- | ----------- | ---- |
| Moodle 2.7 to 3.2 | MOODLE_32_STABLE | 5.5+ |
| Totara up to 10 | TOTARA_10 | 5.5+ |
| Moodle 3.3 to 3.9 | MOODLE_39_STABLE | 7.0+ |
| Totara 11 to 12 | MOODLE_39_STABLE | 7.0+ |
| Moodle 3.10 | master | 7.2+ |
| Totara 13+ | master | 7.2+ |
Screenshots
-----------

View File

@@ -253,7 +253,6 @@ class outagelib {
if ((time() >= {{STARTTIME}}) && (time() < {{STOPTIME}})) {
define('MOODLE_INTERNAL', true);
require_once($CFG->dirroot.'/lib/moodlelib.php');
require_once($CFG->dirroot.'/lib/classes/ip_utils.php');
if (!remoteip_in_list('{{ALLOWEDIPS}}')) {
header($_SERVER['SERVER_PROTOCOL'] . ' 503 Moodle under maintenance');
header('Status: 503 Moodle under maintenance');

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 && $file !== 'preview/' . $basename) {
if ($basename !== $file) {
// @codingStandardsIgnoreStart
if (!PHPUNIT_TEST) {
error_log('Possible attempt for Path Traversal Attack (only filename expected): '.$file);

View File

@@ -69,10 +69,9 @@ abstract class auth_outage_base_testcase extends advanced_testcase {
parent::setUp();
$this->resetAfterTest(true);
}
public function tearDown() {
global $DB;
$DB->delete_records('auth_outage');
// Do not use https.
$CFG->wwwroot = 'http://www.example.com/moodle';
$CFG->httpswwwroot = $CFG->wwwroot;
}
}

View File

@@ -49,8 +49,8 @@ class calendar_test extends advanced_testcase {
* Creates an outage and checks if its in the calendar.
*/
public function test_create() {
$this->resetAfterTest(true);
self::setAdminUser();
$this->resetAfterTest(false);
$time = time();
self::$outage = new outage([
@@ -70,20 +70,8 @@ class calendar_test extends advanced_testcase {
* Updates an outage and checks the calendar.
*/
public function test_update() {
$this->resetAfterTest(true);
self::setAdminUser();
$time = time();
self::$outage = new outage([
'id' => 1,
'autostart' => false,
'warntime' => $time - 100,
'starttime' => $time,
'stoptime' => $time + (2 * 60 * 60),
'title' => 'Title',
'description' => 'Description',
]);
calendar::create(self::$outage);
$this->resetAfterTest(false);
self::$outage->title = 'New Title';
calendar::update(self::$outage);
@@ -94,22 +82,8 @@ class calendar_test extends advanced_testcase {
* Deletes an outage and checks the calendar.
*/
public function test_delete() {
$this->resetAfterTest(true);
self::setAdminUser();
$time = time();
self::$outage = new outage([
'id' => 1,
'autostart' => false,
'warntime' => $time - 100,
'starttime' => $time,
'stoptime' => $time + (2 * 60 * 60),
'title' => 'Title',
'description' => 'Description',
]);
calendar::create(self::$outage);
$this->check_calendar();
$this->resetAfterTest(true);
calendar::delete(self::$outage->id);
self::assertNull(calendar::load(self::$outage->id));
@@ -119,8 +93,8 @@ class calendar_test extends advanced_testcase {
* Try to update a non existing outage.
*/
public function test_update_notfound() {
$this->resetAfterTest(true);
self::setAdminUser();
$this->resetAfterTest(true);
$time = time();
$outage = new outage([
@@ -142,9 +116,8 @@ class calendar_test extends advanced_testcase {
* Try to delete a non existing outage.
*/
public function test_delete_notfound() {
$this->resetAfterTest(true);
self::setAdminUser();
$this->resetAfterTest(true);
calendar::delete(1);
self::assertCount(1, phpunit_util::get_debugging_messages());
phpunit_util::reset_debugging();

View File

@@ -57,7 +57,7 @@ class events_test extends advanced_testcase {
public function test_save() {
global $DB;
self::setAdminUser();
$this->resetAfterTest(true);
$this->resetAfterTest(false);
// Save new outage.
$now = time();
@@ -90,20 +90,7 @@ class events_test extends advanced_testcase {
global $DB;
self::setAdminUser();
$this->resetAfterTest(true);
// Save new outage.
$now = time();
$outage = new outage([
'autostart' => false,
'warntime' => $now - 60,
'starttime' => 60,
'stoptime' => 120,
'title' => 'Title',
'description' => 'Description',
]);
$outage->id = outagedb::save($outage);
self::$outage = $outage;
$this->resetAfterTest(false);
self::$outage->starttime += 10;
outagedb::save(self::$outage);
@@ -130,19 +117,6 @@ class events_test extends advanced_testcase {
self::setAdminUser();
$this->resetAfterTest(true);
// Save new outage.
$now = time();
$outage = new outage([
'autostart' => false,
'warntime' => $now - 60,
'starttime' => 60,
'stoptime' => 120,
'title' => 'Title',
'description' => 'Description',
]);
$outage->id = outagedb::save($outage);
self::$outage = $outage;
outagedb::delete(self::$outage->id);
// Should not exist.

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

View File

@@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->libdir.'/adminlib.php');
require_once(__DIR__.'/../base_testcase.php');
/**
* outagelib_test test class.
*
@@ -41,7 +41,7 @@ require_once(__DIR__.'/../base_testcase.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @SuppressWarnings(public) Allow as many methods as needed.
*/
class outagelib_test extends auth_outage_base_testcase {
class outagelib_test extends advanced_testcase {
/**
* Check if maintenance message is disabled as needed.
*/
@@ -293,7 +293,6 @@ class outagelib_test extends auth_outage_base_testcase {
if ((time() >= 123) && (time() < 456)) {
define('MOODLE_INTERNAL', true);
require_once($CFG->dirroot.'/lib/moodlelib.php');
require_once($CFG->dirroot.'/lib/classes/ip_utils.php');
if (!remoteip_in_list('heyyou
a.b.c.d
e.e.e.e/20')) {
@@ -334,7 +333,6 @@ EOT;
if ((time() >= 123) && (time() < 456)) {
define('MOODLE_INTERNAL', true);
require_once($CFG->dirroot.'/lib/moodlelib.php');
require_once($CFG->dirroot.'/lib/classes/ip_utils.php');
if (!remoteip_in_list('127.0.0.1')) {
header($_SERVER['SERVER_PROTOCOL'] . ' 503 Moodle under maintenance');
header('Status: 503 Moodle under maintenance');

View File

@@ -28,7 +28,8 @@
defined('MOODLE_INTERNAL') || die();
$plugin->component = "auth_outage";
$plugin->version = 2018062500; // The current plugin version (Date: YYYYMMDDXX).
$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->maturity = MATURITY_STABLE; // Suitable for PRODUCTION environments!
$plugin->supported = [27, 32]; // A range of branch numbers of supported moodle versions.