Skip to content

Commit

Permalink
Fix Moodle plugin CI errors
Browse files Browse the repository at this point in the history
  • Loading branch information
patmr7 committed Nov 19, 2024
1 parent 813d66c commit 1409733
Show file tree
Hide file tree
Showing 260 changed files with 3,295 additions and 2,560 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Title of the workflow
name: Moodle Office 365 Plugin CI
name: Moodle Plugin CI for Microsoft plugins

# Run this workflow every time a new commit pushed to your repository or PR
# created.
on: [push, pull_request]

jobs:
check:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest

services:
postgres:
Expand Down
85 changes: 85 additions & 0 deletions auth/oidc/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
services:
- name: selenium/standalone-chrome:3
alias: behat
- name: mysql:8.0
alias: db
command:
- '--character-set-server=utf8mb4'
- '--collation-server=utf8mb4_unicode_ci'
- '--innodb_file_per_table=On'
- '--wait-timeout=28800'
- '--skip-log-bin'

cache:
paths:
- .cache

variables:
DEBIAN_FRONTEND: 'noninteractive'
COMPOSER_ALLOW_SUPERUSER: 1
COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/.cache/composer"
NPM_CONFIG_CACHE: "$CI_PROJECT_DIR/.cache/npm"
CI_BUILD_DIR: '/tmp/plugin'
MOODLE_BRANCH: 'MOODLE_404_STABLE'
MOODLE_BEHAT_WWWROOT: 'http://localhost:8000'
MOODLE_BEHAT_WDHOST: 'http://behat:4444/wd/hub'
MOODLE_START_BEHAT_SERVERS: 'no'
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
DB: 'mysqli'

stages:
- moodle-plugin-ci

.setupandruncheck: &setupandruncheck
stage: moodle-plugin-ci
before_script:
- mkdir -pv "$CI_BUILD_DIR"
- cp -ru "$CI_PROJECT_DIR/"* "$CI_BUILD_DIR"
- mkdir -p /usr/share/man/man1 /usr/share/man/man3 /usr/share/man/man7
- apt-get -qq update
- apt-get -yqq install --no-install-suggests default-jre-headless default-mysql-client
- 'curl -sS https://raw.githubusercontent.com/creationix/nvm/v0.39.3/install.sh | bash'
- . ~/.bashrc
- nvm install --default --latest-npm lts/gallium
- 'curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer'
- composer create-project -n --no-dev --no-progress --no-ansi moodlehq/moodle-plugin-ci /opt/mci ^4
- export PATH="/opt/mci/bin:/opt/mci/vendor/bin:$PATH"
- moodle-plugin-ci install --db-host db --db-name moodle
- '{ php -S 0.0.0.0:8000 -t "$CI_PROJECT_DIR/moodle" >/dev/null 2>&1 & }'
- TXT_RED="\e[31m"

script:
- errors=()
- moodle-plugin-ci phplint || errors+=("phplint")
- moodle-plugin-ci phpmd || errors+=("phpmd")
- moodle-plugin-ci codechecker --max-warnings 0 || errors+=("codechecker")
- moodle-plugin-ci phpdoc --max-warnings 0 || errors+=("phpdoc")
- moodle-plugin-ci validate || errors+=("validate")
- moodle-plugin-ci savepoints || errors+=("savepoints")
- moodle-plugin-ci mustache || errors+=("mustache")
- moodle-plugin-ci grunt --max-lint-warnings 0 || errors+=("grunt")
- moodle-plugin-ci phpunit || errors+=("phpunit")
- moodle-plugin-ci behat --auto-rerun 0 --profile chrome || errors+=("behat")
- |-
if [ ${#errors[@]} -ne 0 ]; then
echo -e "${TXT_RED}Check errors: ${errors[@]}";
exit 1;
fi
php81:
tags:
- docker
image: moodlehq/moodle-php-apache:8.1
<<: *setupandruncheck

php82:
tags:
- docker
image: moodlehq/moodle-php-apache:8.2
<<: *setupandruncheck

php83:
tags:
- docker
image: moodlehq/moodle-php-apache:8.3
<<: *setupandruncheck
41 changes: 0 additions & 41 deletions auth/oidc/.travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions auth/oidc/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct($forceloginflow = null) {
*
* @return bool
*/
function can_be_manually_set() {
public function can_be_manually_set() {
return true;
}

Expand Down Expand Up @@ -197,8 +197,8 @@ public function handleredirect() {
* @param null $userid
* @return mixed
*/
public function disconnect($justremovetokens = false, $donotremovetokens = false, \moodle_url $redirect = null,
\moodle_url $selfurl = null, $userid = null) {
public function disconnect($justremovetokens = false, $donotremovetokens = false, ?\moodle_url $redirect = null,
?\moodle_url $selfurl = null, $userid = null) {
return $this->loginflow->disconnect($justremovetokens, $donotremovetokens, $redirect, $selfurl, $userid);
}

Expand Down
4 changes: 2 additions & 2 deletions auth/oidc/binding_username_claim.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@

$oidcconfig = get_config('auth_oidc');
if (!isset($oidcconfig->bindingusernameclaim)) {
// bindingusernameclaim is not set, set default value.
// Bindingusernameclaim is not set, set default value.
$formdata['bindingusernameclaim'] = 'auto';
$formdata['customclaimname'] = '';
set_config('bindingusernameclaim', 'auto', 'auth_oidc');
} else if(!$oidcconfig->bindingusernameclaim) {
} else if (!$oidcconfig->bindingusernameclaim) {
$formdata['bindingusernameclaim'] = 'auto';
$formdata['customclaimname'] = '';
} else if (in_array($oidcconfig->bindingusernameclaim, $predefinedbindingclaims)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc\adminsetting;

defined('MOODLE_INTERNAL') || die();

/**
* Choose an icon for the identity provider entry on the login page.
*/
Expand Down Expand Up @@ -93,8 +91,8 @@ public function write_setting($data) {
*/
public function output_html($data, $query = '') {
global $CFG, $OUTPUT;
$attrs = array('type' => 'text/css', 'rel' => 'stylesheet',
'href' => new \moodle_url('/auth/oidc/classes/adminsetting/iconselect.css'));
$attrs = ['type' => 'text/css', 'rel' => 'stylesheet',
'href' => new \moodle_url('/auth/oidc/classes/adminsetting/iconselect.css')];
$html = \html_writer::empty_tag('link', $attrs);
$html .= \html_writer::start_tag('div', ['style' => 'max-width: 390px']);
$selected = (!empty($data)) ? $data : $this->defaultsetting;
Expand All @@ -114,7 +112,7 @@ public function output_html($data, $query = '') {
}
$html .= \html_writer::empty_tag('input', $inputattrs);
$labelattrs = [
'class' => 'iconselect'
'class' => 'iconselect',
];
$html .= \html_writer::label($iconhtml, $id, true, $labelattrs);
}
Expand Down
13 changes: 7 additions & 6 deletions auth/oidc/classes/adminsetting/auth_oidc_admin_setting_label.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,22 @@

use admin_setting;

defined('MOODLE_INTERNAL') || die();

/**
* Display a static text.
*/
class auth_oidc_admin_setting_label extends admin_setting {
/**
* @var string $label The label for display purposes.
*/
private $label;

/**
* Constructor.
*
* @param $name
* @param $label
* @param $visiblename
* @param $description
* @param string $name The setting name.
* @param string $label The label to display.
* @param string $visiblename The visible name for the setting.
* @param string $description A description of the setting.
*/
public function __construct($name, $label, $visiblename, $description) {
parent::__construct($name, $visiblename, $description, '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc\adminsetting;

defined('MOODLE_INTERNAL') || die();

/**
* Displays the redirect URI for easier config.
*/
Expand Down Expand Up @@ -79,7 +77,7 @@ public function output_html($data, $query = '') {
'type' => 'radio',
'name' => $inputname,
'id' => $flowtypeid,
'value' => $flowtype
'value' => $flowtype,
];
if ($data === $flowtype || (empty($data) && $flowtype === $this->get_defaultsetting())) {
$radioattrs['checked'] = 'checked';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,22 @@

use auth_oidc\utils;

defined('MOODLE_INTERNAL') || die();

/**
* Displays the redirect URI for easier config.
*/
class auth_oidc_admin_setting_redirecturi extends \admin_setting {
/**
* @var string $url The redirect URL for the configuration.
*/
private $url;

/**
* Constructor.
*
* @param $name
* @param $heading
* @param $description
* @param string $name The setting name.
* @param string $heading The setting heading.
* @param string $description The setting description.
* @param string $url The redirect URL.
*/
public function __construct($name, $heading, $description, $url) {
$this->nosave = true;
Expand Down
2 changes: 0 additions & 2 deletions auth/oidc/classes/event/action_failed.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc\event;

defined('MOODLE_INTERNAL') || die();

/**
* Event fired whenever we need to record a debug message.
*/
Expand Down
2 changes: 0 additions & 2 deletions auth/oidc/classes/event/user_authed.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc\event;

defined('MOODLE_INTERNAL') || die();

/**
* Event fired when a user authenticated with OIDC, but does not log in.
*/
Expand Down
2 changes: 0 additions & 2 deletions auth/oidc/classes/event/user_connected.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc\event;

defined('MOODLE_INTERNAL') || die();

/**
* Fired when a user connects to OpenID Connect.
*/
Expand Down
2 changes: 0 additions & 2 deletions auth/oidc/classes/event/user_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc\event;

defined('MOODLE_INTERNAL') || die();

/**
* Event fired when OIDC creates a new user.
*/
Expand Down
2 changes: 0 additions & 2 deletions auth/oidc/classes/event/user_disconnected.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc\event;

defined('MOODLE_INTERNAL') || die();

/**
* Fired when a user disconnects from OpenID Connect.
*/
Expand Down
2 changes: 0 additions & 2 deletions auth/oidc/classes/event/user_loggedin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc\event;

defined('MOODLE_INTERNAL') || die();

/**
* Fired when a user uses OIDC to log in.
*/
Expand Down
4 changes: 1 addition & 3 deletions auth/oidc/classes/event/user_rename_attempt.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
use context_system;
use core\event\base;

defined('MOODLE_INTERNAL') || die();

/**
* Fired when a user attempts to change their username from the auth_oidc plugin.
*/
Expand Down Expand Up @@ -63,4 +61,4 @@ protected function init() {
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'user';
}
}
}
14 changes: 7 additions & 7 deletions auth/oidc/classes/form/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function definition() {
// Certificate source.
$mform->addElement('select', 'clientcertsource', auth_oidc_config_name_in_form('clientcertsource'), [
AUTH_OIDC_AUTH_CERT_SOURCE_TEXT => get_string('cert_source_text', 'auth_oidc'),
AUTH_OIDC_AUTH_CERT_SOURCE_FILE => get_string('cert_source_path', 'auth_oidc')
AUTH_OIDC_AUTH_CERT_SOURCE_FILE => get_string('cert_source_path', 'auth_oidc'),
]);
$mform->setDefault('clientcertsource', 0);
$mform->disabledIf('clientcertsource', 'clientauthmethod', 'neq', AUTH_OIDC_AUTH_METHOD_CERTIFICATE);
Expand Down Expand Up @@ -146,7 +146,7 @@ protected function definition() {
$mform->addElement('static', 'tokenendpoint_help', '', get_string('tokenendpoint_help', 'auth_oidc'));
$mform->addRule('tokenendpoint', null, 'required', null, 'client');

// "Other parameters" header.
// Other parameters header.
$mform->addElement('header', 'otherparams', get_string('settings_section_other_params', 'auth_oidc'));
$mform->setExpanded('otherparams');

Expand Down Expand Up @@ -184,11 +184,11 @@ protected function definition() {
/**
* Additional validate rules.
*
* @param $data
* @param $files
* @return array
* @param array $data Submitted data for validation.
* @param array $files Uploaded files for validation.
* @return array An array of validation errors, if any.
*/
function validation($data, $files) {
public function validation($data, $files) {
$errors = parent::validation($data, $files);

if (!isset($data['clientauthmethod'])) {
Expand Down Expand Up @@ -278,4 +278,4 @@ function validation($data, $files) {

return $errors;
}
}
}
Loading

0 comments on commit 1409733

Please sign in to comment.