Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ public function get_ssp_version() {
// perform the full initialization. For better performance
// we only make sure \SimpleSAML\Configuration is accessible
// through _autoload.php.
require_once(__DIR__ . '/../vendor/autoload.php');
require_once(__DIR__ . '/../setuplib.php');
$config = new \SimpleSAML\Configuration([], '');
return $config->getVersion();
}
Expand Down
6 changes: 6 additions & 0 deletions setuplib.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@

require_once(__DIR__ . '/vendor/autoload.php');

if (class_exists(\Slim\Factory\Psr17\Psr17FactoryProvider::class)) {
\Slim\Factory\Psr17\Psr17FactoryProvider::setFactories([
\Slim\Factory\Psr17\GuzzlePsr17Factory::class,
]);
}

global $CFG;
require_once("{$CFG->dirroot}/auth/saml2/auth.php");

Expand Down
4 changes: 4 additions & 0 deletions tests/auth_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

namespace auth_saml2;

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

require_once(__DIR__ . '/psr17_factory_pin.php');

/**
* Unit tests for auth class.
*
Expand Down
7 changes: 6 additions & 1 deletion tests/autoloader_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

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

require_once(__DIR__ . '/../vendor/autoload.php');
require_once(__DIR__ . '/psr17_factory_pin.php');

/**
* Test Saml2 Autoloader
Expand All @@ -29,6 +29,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class autoloader_test extends \advanced_testcase {
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
require_once(__DIR__ . '/../vendor/autoload.php');
}

public function test_it_loads_classes(): void {
$classes = [
\Psr\Log\LoggerInterface::class,
Expand Down
4 changes: 4 additions & 0 deletions tests/form_regenerate_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

use auth_saml2\form\regenerate;

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

require_once(__DIR__ . '/psr17_factory_pin.php');

/**
* auth_saml2 form submission unit tests
* @package auth_saml2
Expand Down
4 changes: 4 additions & 0 deletions tests/generator_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

namespace auth_saml2;

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

require_once(__DIR__ . '/psr17_factory_pin.php');

/**
* Unit tests for test data generator.
*
Expand Down
4 changes: 4 additions & 0 deletions tests/group_rule_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

namespace auth_saml2;

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

require_once(__DIR__ . '/psr17_factory_pin.php');

/**
* Testcase class for group_rule class.
*
Expand Down
1 change: 1 addition & 0 deletions tests/locallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

defined('MOODLE_INTERNAL') || die();
require_once(__DIR__ . '/../locallib.php');
require_once(__DIR__ . '/psr17_factory_pin.php');

/**
* Tests for SAML
Expand Down
4 changes: 4 additions & 0 deletions tests/metadata_fetcher_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

namespace auth_saml2;

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

require_once(__DIR__ . '/psr17_factory_pin.php');

/**
* Testcase class for metadata_fetcher class.
*
Expand Down
4 changes: 4 additions & 0 deletions tests/metadata_parser_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

namespace auth_saml2;

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

require_once(__DIR__ . '/psr17_factory_pin.php');

/**
* Testcase class for metadata_parser class.
*
Expand Down
4 changes: 4 additions & 0 deletions tests/metadata_refresh_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

use auth_saml2\task\metadata_refresh;

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

require_once(__DIR__ . '/psr17_factory_pin.php');

/**
* Testcase class for metadata_refresh task class.
*
Expand Down
4 changes: 4 additions & 0 deletions tests/metadata_writer_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

namespace auth_saml2;

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

require_once(__DIR__ . '/psr17_factory_pin.php');

/**
* Testcase class for metadata_writer class.
*
Expand Down
34 changes: 34 additions & 0 deletions tests/psr17_factory_pin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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/>.

/**
* Pin Slim PSR-17 factory discovery to Guzzle for tests.
*
* SimpleSAML 2.4 bundles Nyholm/psr7; once loaded, Slim's PSR-17 discovery
* picks it over Guzzle and breaks core router tests in the same process.
*
* @package auth_saml2
* @copyright 2026 Catalyst IT Australia {@link http://www.catalyst-au.net}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

if (class_exists(\Slim\Factory\Psr17\Psr17FactoryProvider::class)) {
\Slim\Factory\Psr17\Psr17FactoryProvider::setFactories([
\Slim\Factory\Psr17\GuzzlePsr17Factory::class,
]);
}
4 changes: 4 additions & 0 deletions tests/redis_store_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

namespace auth_saml2;

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

require_once(__DIR__ . '/psr17_factory_pin.php');

/**
* Testcase class for auth/saml2 Redis store.
*
Expand Down
7 changes: 6 additions & 1 deletion tests/saml2_sitedata_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

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

require_once(__DIR__ . '/../vendor/autoload.php');
require_once(__DIR__ . '/psr17_factory_pin.php');

/**
* Saml2 site data test.
Expand All @@ -29,6 +29,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class saml2_sitedata_test extends \advanced_testcase {
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
require_once(__DIR__ . '/../vendor/autoload.php');
}

public function test_it_creates_the_directory_if_it_does_not_exist(): void {
global $CFG;

Expand Down
7 changes: 6 additions & 1 deletion tests/setting_idpmetadata_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

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

require_once(__DIR__ . '/../vendor/autoload.php');
require_once(__DIR__ . '/psr17_factory_pin.php');

/**
* Test setting idp Metadata.
Expand All @@ -34,6 +34,11 @@ final class setting_idpmetadata_test extends \advanced_testcase {
/** @var setting_idpmetadata */
private static $config;

public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
require_once(__DIR__ . '/../vendor/autoload.php');
}

protected function setUp(): void {
parent::setUp();
self::$config = new setting_idpmetadata();
Expand Down
4 changes: 4 additions & 0 deletions tests/ssl_algorithm_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

namespace auth_saml2;

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

require_once(__DIR__ . '/psr17_factory_pin.php');

/**
* Test Saml2 SSL Algorithms.
*
Expand Down
4 changes: 4 additions & 0 deletions tests/user_extractor_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

namespace auth_saml2;

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

require_once(__DIR__ . '/psr17_factory_pin.php');

/**
* Test for user extractor class.
*
Expand Down
4 changes: 4 additions & 0 deletions tests/user_fields_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

namespace auth_saml2;

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

require_once(__DIR__ . '/psr17_factory_pin.php');

/**
* Test for user fields class.
*
Expand Down
Loading