mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 08:55:15 +02:00
MDL-81924 core: Remove unused AWS classes and tests
Originally implemented as MDL-80962.
This commit is contained in:
parent
310f5f50ee
commit
d5bdb07c28
9
.upgradenotes/MDL-80962-2024071606563987.yml
Normal file
9
.upgradenotes/MDL-80962-2024071606563987.yml
Normal file
@ -0,0 +1,9 @@
|
||||
issueNumber: MDL-80962
|
||||
notes:
|
||||
core:
|
||||
- message: >
|
||||
The following classes are deprecated as they are handled by core_sms API and smsgateway_aws plugin:
|
||||
- admin_settings_aws_region (lib/classes/aws/admin_settings_aws_region.php)
|
||||
- aws_helper (lib/classes/aws/aws_helper.php)
|
||||
- client_factory (lib/classes/aws/client_factory.php)
|
||||
type: deprecated
|
8
.upgradenotes/MDL-80962-2024071606591847.yml
Normal file
8
.upgradenotes/MDL-80962-2024071606591847.yml
Normal file
@ -0,0 +1,8 @@
|
||||
issueNumber: MDL-80962
|
||||
notes:
|
||||
core:
|
||||
- message: >
|
||||
The following test classes are removed as their base classes are deprecated:
|
||||
- admin_settings_aws_region_test (lib/tests/aws/admin_settings_aws_region_test.php)
|
||||
- aws_helper_test (lib/tests/aws/aws_helper_test.php)
|
||||
type: removed
|
@ -14,15 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Admin setting for AWS regions.
|
||||
*
|
||||
* @package core
|
||||
* @author Dmitrii Metelkin <dmitriim@catalyst-au.net>
|
||||
* @copyright 2020 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace core\aws;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
@ -35,6 +26,8 @@ require_once($CFG->dirroot . '/lib/adminlib.php');
|
||||
* @package core
|
||||
* @copyright 2020 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @deprecated Since Moodle 4.5
|
||||
* @todo MDL-82459 Final deprecation in Moodle 5.0.
|
||||
*/
|
||||
class admin_settings_aws_region extends \admin_setting_configtext {
|
||||
|
||||
@ -44,8 +37,15 @@ class admin_settings_aws_region extends \admin_setting_configtext {
|
||||
* @param mixed $data array or string depending on setting
|
||||
* @param string $query
|
||||
* @return string
|
||||
* @deprecated Since Moodle 4.5
|
||||
*/
|
||||
#[\core\attribute\deprecated(
|
||||
'admin_settings_aws_region::output_html()',
|
||||
since: '4.5',
|
||||
mdl: 'MDL-80962',
|
||||
)]
|
||||
public function output_html($data, $query='') {
|
||||
\core\deprecation::emit_deprecation_if_present([$this, __FUNCTION__]);
|
||||
global $CFG, $OUTPUT;
|
||||
|
||||
$default = $this->get_defaultsetting();
|
||||
|
@ -14,15 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* AWS helper class. Contains useful functions when interacting with the SDK.
|
||||
*
|
||||
* @package core
|
||||
* @author Peter Burnett <peterburnett@catalyst-au.net>
|
||||
* @copyright 2020 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace core\aws;
|
||||
|
||||
use Aws\CommandInterface;
|
||||
@ -34,6 +25,8 @@ use Psr\Http\Message\RequestInterface;
|
||||
*
|
||||
* @copyright 2020 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @deprecated Since Moodle 4.5
|
||||
* @todo MDL-82459 Final deprecation in Moodle 5.0.
|
||||
*/
|
||||
class aws_helper {
|
||||
|
||||
@ -41,8 +34,15 @@ class aws_helper {
|
||||
* This creates a proxy string suitable for use with the AWS SDK.
|
||||
*
|
||||
* @return string the string to use for proxy settings.
|
||||
* @deprecated Since Moodle 4.5
|
||||
*/
|
||||
#[\core\attribute\deprecated(
|
||||
'aws_helper::get_proxy_string()',
|
||||
since: '4.5',
|
||||
mdl: 'MDL-80962',
|
||||
)]
|
||||
public static function get_proxy_string(): string {
|
||||
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
|
||||
global $CFG;
|
||||
$proxy = '';
|
||||
if (empty($CFG->proxytype)) {
|
||||
@ -71,8 +71,15 @@ class aws_helper {
|
||||
*
|
||||
* @param AwsClient $client
|
||||
* @return AwsClient
|
||||
* @deprecated Since Moodle 4.5
|
||||
*/
|
||||
#[\core\attribute\deprecated(
|
||||
'aws_helper::configure_client_proxy()',
|
||||
since: '4.5',
|
||||
mdl: 'MDL-80962',
|
||||
)]
|
||||
public static function configure_client_proxy(AwsClient $client): AwsClient {
|
||||
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
|
||||
$client->getHandlerList()->appendBuild(self::add_proxy_when_required(), 'proxy_bypass');
|
||||
return $client;
|
||||
}
|
||||
@ -81,8 +88,15 @@ class aws_helper {
|
||||
* Generate a middleware higher order function to wrap the handler and append proxy configuration based on target.
|
||||
*
|
||||
* @return callable Middleware high order callable.
|
||||
* @deprecated Since Moodle 4.5
|
||||
*/
|
||||
#[\core\attribute\deprecated(
|
||||
'aws_helper::add_proxy_when_required()',
|
||||
since: '4.5',
|
||||
mdl: 'MDL-80962',
|
||||
)]
|
||||
protected static function add_proxy_when_required(): callable {
|
||||
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
|
||||
return function (callable $fn) {
|
||||
return function (CommandInterface $command, ?RequestInterface $request = null) use ($fn) {
|
||||
if (isset($request)) {
|
||||
|
@ -14,15 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* AWS Client factory. Retrieves a client with moodle specific HTTP configuration.
|
||||
*
|
||||
* @package core
|
||||
* @author Peter Burnett <peterburnett@catalyst-au.net>
|
||||
* @copyright 2022 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace core\aws;
|
||||
use Aws\AwsClient;
|
||||
|
||||
@ -32,6 +23,8 @@ use Aws\AwsClient;
|
||||
* @copyright 2022 Catalyst IT
|
||||
* @author Peter Burnett <peterburnett@catalyst-au.net>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @deprecated Since Moodle 4.5
|
||||
* @todo MDL-82459 Final deprecation in Moodle 5.0.
|
||||
*/
|
||||
class client_factory {
|
||||
/**
|
||||
@ -40,8 +33,15 @@ class client_factory {
|
||||
* @param string $class Fully qualified AWS classname e.g. \Aws\S3\S3Client
|
||||
* @param array $opts array of constructor options for AWS Client.
|
||||
* @return AwsClient
|
||||
* @deprecated Since Moodle 4.5
|
||||
*/
|
||||
#[\core\attribute\deprecated(
|
||||
'client_factory::get_client()',
|
||||
since: '4.5',
|
||||
mdl: 'MDL-80962',
|
||||
)]
|
||||
public static function get_client(string $class, array $opts): AwsClient {
|
||||
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
|
||||
// Modify the opts to add HTTP timeouts.
|
||||
if (empty($opts['http'])) {
|
||||
$opts['http'] = ['connect_timeout' => HOURSECS];
|
||||
|
@ -1,65 +0,0 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* factor_sms unit tests.
|
||||
*
|
||||
* @package core
|
||||
* @author Mikhail Golenkov <mikhailgolenkov@catalyst-au.net>
|
||||
* @copyright 2020 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace core\aws;
|
||||
|
||||
/**
|
||||
* Testcase for the list of AWS regions admin setting.
|
||||
*
|
||||
* @package core
|
||||
* @author Mikhail Golenkov <mikhailgolenkov@catalyst-au.net>
|
||||
* @copyright 2020 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \core\aws\admin_settings_aws_region
|
||||
*/
|
||||
class admin_settings_aws_region_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Cleanup after all tests are executed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown(): void {
|
||||
$admin = admin_get_root();
|
||||
$admin->purge_children(true);
|
||||
parent::tearDown();
|
||||
}
|
||||
/**
|
||||
* Test that output_html() method works and returns HTML string with expected content.
|
||||
*/
|
||||
public function test_output_html(): void {
|
||||
$this->resetAfterTest();
|
||||
$setting = new admin_settings_aws_region('test_aws_region',
|
||||
'Test visible name', 'Test description', 'Test default setting');
|
||||
$html = $setting->output_html('');
|
||||
$this->assertTrue(str_contains($html, 'Test visible name'));
|
||||
$this->assertTrue(str_contains($html, 'Test description'));
|
||||
$this->assertTrue(str_contains($html, 'Default: Test default setting'));
|
||||
$this->assertTrue(str_contains($html,
|
||||
'<input type="text" list="s__test_aws_region" name="s__test_aws_region" value=""'));
|
||||
$this->assertTrue(str_contains($html, '<datalist id="s__test_aws_region">'));
|
||||
$this->assertTrue(str_contains($html, '<option value="'));
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* aws_helper unit tests.
|
||||
*
|
||||
* @package core
|
||||
* @author Peter Burnett <peterburnett@catalyst-au.net>
|
||||
* @copyright 2020 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \core\aws\aws_helper
|
||||
*/
|
||||
|
||||
namespace core\aws;
|
||||
|
||||
/**
|
||||
* Testcase for the AWS helper.
|
||||
*
|
||||
* @package factor_sms
|
||||
* @author Peter Burnett <peterburnett@catalyst-au.net>
|
||||
* @copyright 2020 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \core\aws\aws_helper
|
||||
*/
|
||||
class aws_helper_test extends \advanced_testcase {
|
||||
|
||||
public function test_get_proxy_string(): void {
|
||||
global $CFG;
|
||||
$this->resetAfterTest();
|
||||
// Confirm with no config an empty string is returned.
|
||||
$CFG->proxyhost = '';
|
||||
$this->assertEquals('', aws_helper::get_proxy_string());
|
||||
|
||||
// Now set some configs.
|
||||
$CFG->proxyhost = '127.0.0.1';
|
||||
$CFG->proxyuser = 'user';
|
||||
$CFG->proxypassword = 'password';
|
||||
$CFG->proxyport = '1337';
|
||||
$this->assertEquals('user:password@127.0.0.1:1337', aws_helper::get_proxy_string());
|
||||
|
||||
// Now change to SOCKS proxy.
|
||||
$CFG->proxytype = 'SOCKS5';
|
||||
$this->assertEquals('socks5://user:password@127.0.0.1:1337', aws_helper::get_proxy_string());
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user