From 8a2c72c1b972881fbfd552c094358adf5454ac3c Mon Sep 17 00:00:00 2001 From: Matthew Hilton Date: Tue, 17 Sep 2024 14:32:25 +1000 Subject: [PATCH 1/4] bugfix: use test client in unit tests --- classes/local/manager.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/classes/local/manager.php b/classes/local/manager.php index 5d791f97..acd2b30e 100644 --- a/classes/local/manager.php +++ b/classes/local/manager.php @@ -329,6 +329,10 @@ public static function get_available_fs_list() { * @return string */ public static function get_client_classname_from_fs($filesystem) { + // Unit tests need to return the test client. + if ($filesystem == '\tool_objectfs\tests\test_file_system') { + return '\tool_objectfs\tests\test_client'; + } $clientclass = str_replace('_file_system', '', $filesystem); return str_replace('tool_objectfs\\', 'tool_objectfs\\local\\store\\', $clientclass.'\\client'); } From 5b7a4de8a898e6e1a83c66dcfad90160a941bc82 Mon Sep 17 00:00:00 2001 From: Matthew Hilton Date: Tue, 17 Sep 2024 14:35:35 +1000 Subject: [PATCH 2/4] feat: add token expiry check --- classes/check/token_expiry.php | 71 ++++++++++++++++++++ classes/local/store/azure/client.php | 35 ++++++++++ classes/local/store/object_client.php | 6 ++ classes/local/store/object_client_base.php | 9 +++ classes/tests/test_client.php | 9 +++ lang/en/tool_objectfs.php | 6 ++ lib.php | 10 +-- settings.php | 4 ++ tests/local/store/clients_test.php | 41 ++++++++++++ tests/token_expiry_test.php | 77 ++++++++++++++++++++++ version.php | 4 +- 11 files changed, 266 insertions(+), 6 deletions(-) create mode 100644 classes/check/token_expiry.php create mode 100644 tests/token_expiry_test.php diff --git a/classes/check/token_expiry.php b/classes/check/token_expiry.php new file mode 100644 index 00000000..ad6e8d6d --- /dev/null +++ b/classes/check/token_expiry.php @@ -0,0 +1,71 @@ +. + +namespace tool_objectfs\check; + +use core\check\check; +use core\check\result; + +/** + * Token expiry check. + * + * @package tool_objectfs + * @author Matthew Hilton + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class token_expiry extends check { + /** + * Checks the token expiry time against thresholds + * @return result + */ + public function get_result(): result { + $config = \tool_objectfs\local\manager::get_objectfs_config(); + $client = \tool_objectfs\local\manager::get_client($config); + + // No client set - n/a. + if (empty($client)) { + return new result(result::NA, get_string('check:tokenexpiry:na', 'tool_objectfs')); + } + + $expirytime = $client->get_token_expiry_time(); + $secondsleft = $expirytime - time(); + + $strparams = [ + 'dayssince' => abs(round($secondsleft / DAYSECS)), + 'time' => userdate($expirytime), + ]; + + // Not implemented or token not set - n/a. + if ($expirytime == -1) { + return new result(result::NA, get_string('check:tokenexpiry:na', 'tool_objectfs')); + } + + // Is in past - token has expired. + if ($secondsleft < 0) { + return new result(result::CRITICAL, get_string('check:tokenexpiry:expired', 'tool_objectfs', $strparams)); + } + + // Is in warning period - warn. + $warnthreshold = (int) $config->tokenexpirywarnperiod; + if ($secondsleft < $warnthreshold) { + return new result(result::WARNING, get_string('check:tokenexpiry:expiresin', 'tool_objectfs', $strparams)); + } + + // Else ok. + return new result(result::OK, get_string('check:tokenexpiry:expiresin', 'tool_objectfs', $strparams)); + } +} diff --git a/classes/local/store/azure/client.php b/classes/local/store/azure/client.php index c96bdde8..ed755e0f 100644 --- a/classes/local/store/azure/client.php +++ b/classes/local/store/azure/client.php @@ -25,8 +25,10 @@ namespace tool_objectfs\local\store\azure; +use admin_setting_description; use SimpleXMLElement; use stdClass; +use tool_objectfs\check\token_expiry; use tool_objectfs\local\store\azure\stream_wrapper; use tool_objectfs\local\store\object_client_base; @@ -360,9 +362,42 @@ public function define_client_section($settings, $config) { new \lang_string('settings:azure:sastoken', 'tool_objectfs'), new \lang_string('settings:azure:sastoken_help', 'tool_objectfs'), '')); + // Admin_setting_check only exists in 4.5+, in lower versions fallback to a basic description. + if (class_exists('admin_setting_check')) { + $settings->add(new admin_setting_check('tool_objectfs/check_tokenexpiry', new token_expiry(), true)); + } else { + $summary = (new token_expiry())->get_result()->get_summary(); + $settings->add(new admin_setting_description('tool_objectfs/tokenexpirycheckresult', + get_string('checktoken_expiry', 'tool_objectfs'), $summary)); + } + return $settings; } + /** + * Returns token expiry time + * @return int + */ + public function get_token_expiry_time(): int { + if (empty($this->config->azure_sastoken)) { + return -1; + } + + // Parse the sas token (it just uses url parameter encoding). + $parts = []; + parse_str($this->config->azure_sastoken, $parts); + + // Get the 'se' part (signed expiry). + if (!isset($parts['se'])) { + // Assume expired (malformed). + return 0; + } + + // Parse timestamp string into unix timestamp int. + $expirystr = $parts['se']; + return strtotime($expirystr); + } + /** * Extract an error code from the XML response. * diff --git a/classes/local/store/object_client.php b/classes/local/store/object_client.php index 9121a824..cd8cbc7f 100644 --- a/classes/local/store/object_client.php +++ b/classes/local/store/object_client.php @@ -137,6 +137,12 @@ public function proxy_range_request(\stored_file $file, $ranges); */ public function test_range_request($filesystem); + /** + * Get the expiry time of the token used for this fs. + * returns -1 if not implemented, or no token is set. + * @return int unix timestamp the token set expires at + */ + public function get_token_expiry_time(): int; } diff --git a/classes/local/store/object_client_base.php b/classes/local/store/object_client_base.php index 4f03418d..fa1b7e8f 100644 --- a/classes/local/store/object_client_base.php +++ b/classes/local/store/object_client_base.php @@ -187,4 +187,13 @@ public function test_connection() { public function test_permissions($testdelete) { return (object)['success' => false, 'details' => '']; } + + /** + * Return expiry time of token, default is -1 meaning not implemented/enabled. + * @return int + */ + public function get_token_expiry_time(): int { + // Returning -1 = not implemented. + return -1; + } } diff --git a/classes/tests/test_client.php b/classes/tests/test_client.php index 7a380c17..dbed5711 100644 --- a/classes/tests/test_client.php +++ b/classes/tests/test_client.php @@ -157,5 +157,14 @@ public function test_permissions($testdelete) { public function get_maximum_upload_size() { return $this->maxupload; } + + /** + * Returns test expiry time. + * @return int + */ + public function get_token_expiry_time(): int { + global $CFG; + return $CFG->objectfs_phpunit_token_expiry_time; + } } diff --git a/lang/en/tool_objectfs.php b/lang/en/tool_objectfs.php index e8f48876..74b383a5 100644 --- a/lang/en/tool_objectfs.php +++ b/lang/en/tool_objectfs.php @@ -269,3 +269,9 @@ $string['check:proxyrangerequestsdisabled'] = 'The proxy range request setting is disabled.'; $string['checkproxy_range_request'] = 'Pre-signed URL range request proxy'; + +$string['checktoken_expiry'] = 'Token expiry'; +$string['check:tokenexpiry:expiresin'] = 'Token expires in {$a->dayssince} days on {$a->time}'; +$string['check:tokenexpiry:expired'] = 'Token expired for {$a->dayssince} days. Expired on {$a->time}'; +$string['check:tokenexpiry:na'] = 'Token expired not implemented for filesystem, or no token is set'; +$string['settings:tokenexpirywarnperiod'] = 'Token expiry warn period'; diff --git a/lib.php b/lib.php index dd50df39..708063a8 100644 --- a/lib.php +++ b/lib.php @@ -101,11 +101,13 @@ function tool_objectfs_pluginfile($course, $cm, context $context, $filearea, arr * @return array */ function tool_objectfs_status_checks() { + $checks = [ + new tool_objectfs\check\token_expiry(), + ]; + if (get_config('tool_objectfs', 'proxyrangerequests')) { - return [ - new tool_objectfs\check\proxy_range_request(), - ]; + $checks[] = new tool_objectfs\check\proxy_range_request(); } - return []; + return $checks; } diff --git a/settings.php b/settings.php index a941e506..aef3c571 100644 --- a/settings.php +++ b/settings.php @@ -106,6 +106,10 @@ new lang_string('settings:useproxy_help', 'tool_objectfs'), 0)); + $settings->add(new admin_setting_configduration('tool_objectfs/tokenexpirywarnperiod', + new lang_string('settings:tokenexpirywarnperiod', 'tool_objectfs'), + '', 60 * DAYSECS, DAYSECS)); + $settings->add(new admin_setting_heading('tool_objectfs/filetransfersettings', new lang_string('settings:filetransferheader', 'tool_objectfs'), '')); diff --git a/tests/local/store/clients_test.php b/tests/local/store/clients_test.php index 6403a234..2fcec176 100644 --- a/tests/local/store/clients_test.php +++ b/tests/local/store/clients_test.php @@ -18,6 +18,7 @@ use tool_objectfs\tests\test_digitalocean_integration_client as digitaloceanclient; use tool_objectfs\tests\test_s3_integration_client as s3client; +use tool_objectfs\tests\test_azure_integration_client as azureclient; /** * Client tests. @@ -107,4 +108,44 @@ public function test_digitalocean_client_test_connection_if_not_configured_prope $this->assertSame(get_string('settings:notconfigured', 'tool_objectfs'), $testresults->details); } + /** + * Provides values to azure_client_get_token_expiry test + * @return array + */ + public static function azure_client_get_token_expiry_provider(): array { + return [ + 'good token' => [ + 'sastoken' => 'sp=racwl&st=2024-09-13T01:11:06Z&se=2024-12-30T09:11:06Z&spr=https&sv=2022-11-02&sr=c&sig=abcd', + 'expectedtime' => 1735549866, + ], + 'malformed se' => [ + 'sastoken' => 'sp=racwl&st=2024-09-13T01:11:06Z&se=-12-30T09:11:06Z&spr=https&sv=2022-11-02&sr=c&sig=abcd', + 'expectedtime' => 0, + ], + 'missing se' => [ + 'sastoken' => 'sp=racwl&st=2024-09-13T01:11:06Z&spr=https&sv=2022-11-02&sr=c&sig=abcd', + 'expectedtime' => 0, + ], + 'no token' => [ + 'sastoken' => '', + 'expectedtime' => -1, + ], + ]; + } + + /** + * Tests azure client correctly extracts token expiry time + * @param string $sastoken + * @param int $expectedtime + * @dataProvider azure_client_get_token_expiry_provider + */ + public function test_azure_client_get_token_expiry(string $sastoken, int $expectedtime) { + $config = (object) [ + 'azure_container' => 'test', + 'azure_accountname' => 'test', + 'azure_sastoken' => $sastoken, + ]; + $azureclient = new azureclient($config); + $this->assertEquals($expectedtime, $azureclient->get_token_expiry_time()); + } } diff --git a/tests/token_expiry_test.php b/tests/token_expiry_test.php new file mode 100644 index 00000000..a658bd0f --- /dev/null +++ b/tests/token_expiry_test.php @@ -0,0 +1,77 @@ +. + +namespace tool_objectfs; + +use core\check\result; +use tool_objectfs\check\token_expiry; +use tool_objectfs\local\manager; +use tool_objectfs\tests\testcase; + +/** + * Token expiry check test. + * + * @covers \tool_objectfs\check\token_expiry + * @package tool_objectfs + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class token_expiry_test extends testcase { + /** + * Provides to test_get_result + * @return array + */ + public static function get_result_provider(): array { + return [ + 'ok' => [ + 'expiry' => time() + 10 * DAYSECS, + 'warnperiod' => 5 * DAYSECS, + 'expectedresult' => result::OK, + ], + 'warning' => [ + 'expiry' => time() + DAYSECS, + 'warnperiod' => 5 * DAYSECS, + 'expectedresult' => result::WARNING, + ], + 'expired' => [ + 'expiry' => time() - DAYSECS, + 'warnperiod' => 5 * DAYSECS, + 'expectedresult' => result::CRITICAL, + ], + ]; + } + + /** + * Tests getting check result + * @param int $expirytime time to use as the tokens expiry + * @param int $warnperiod period to set for warning about token expiry + * @param string $expectedresult one of the result:: constants that is expected to be returned. + * @dataProvider get_result_provider + */ + public function test_get_result(int $expirytime, int $warnperiod, string $expectedresult) { + global $CFG; + $config = manager::get_objectfs_config(); + $config->filesystem = '\\tool_objectfs\\tests\\test_file_system'; + manager::set_objectfs_config($config); + + $CFG->objectfs_phpunit_token_expiry_time = $expirytime; + set_config('tokenexpirywarnperiod', $warnperiod, 'tool_objectfs'); + + $check = new token_expiry(); + $result = $check->get_result(); + $this->assertEquals($expectedresult, $result->get_status()); + } +} diff --git a/version.php b/version.php index bea5f7e8..25c5d28d 100644 --- a/version.php +++ b/version.php @@ -25,8 +25,8 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2023051701; // The current plugin version (Date: YYYYMMDDXX). -$plugin->release = 2023051701; // Same as version. +$plugin->version = 2024091700; // The current plugin version (Date: YYYYMMDDXX). +$plugin->release = 2024091700; // Same as version. $plugin->requires = 2023042400; // Requires 4.2. $plugin->component = "tool_objectfs"; $plugin->maturity = MATURITY_STABLE; From c0f6c05d230b61267ec7c21b0e7368ac1e41b8c4 Mon Sep 17 00:00:00 2001 From: Matthew Hilton Date: Tue, 17 Sep 2024 14:35:44 +1000 Subject: [PATCH 3/4] chore: code standards fixup --- .../candidates/manipulator_candidates.php | 9 ++++----- classes/local/object_manipulator/object_manipulator.php | 9 ++++----- classes/local/store/object_client.php | 6 ++---- classes/privacy/provider.php | 1 + classes/task/objectfs_task.php | 5 ++--- classes/tests/test_azure_integration_client.php | 7 +++++-- classes/tests/test_client.php | 7 +++++-- classes/tests/test_digitalocean_integration_client.php | 7 +++++-- classes/tests/test_s3_integration_client.php | 7 +++++-- classes/tests/test_swift_integration_client.php | 7 +++++-- classes/tests/testcase.php | 7 +++++-- tests/local/object_manipulator/checker_test.php | 4 +++- tests/local/object_manipulator/deleter_test.php | 4 +++- tests/local/object_manipulator/orphaner_test.php | 4 +++- tests/local/object_manipulator/puller_test.php | 4 +++- tests/local/object_manipulator/pusher_test.php | 4 +++- tests/local/object_manipulator/recoverer_test.php | 4 +++- tests/local/tasks_test.php | 4 +++- tests/object_file_system_test.php | 4 +++- 19 files changed, 67 insertions(+), 37 deletions(-) diff --git a/classes/local/object_manipulator/candidates/manipulator_candidates.php b/classes/local/object_manipulator/candidates/manipulator_candidates.php index eac7ca90..6cb68bc9 100644 --- a/classes/local/object_manipulator/candidates/manipulator_candidates.php +++ b/classes/local/object_manipulator/candidates/manipulator_candidates.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace tool_objectfs\local\object_manipulator\candidates; + +use dml_exception; + /** * Interface manipulator_candidates * @package tool_objectfs @@ -21,11 +25,6 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - -namespace tool_objectfs\local\object_manipulator\candidates; - -use dml_exception; - interface manipulator_candidates { /** diff --git a/classes/local/object_manipulator/object_manipulator.php b/classes/local/object_manipulator/object_manipulator.php index 33d9d88a..8549106e 100644 --- a/classes/local/object_manipulator/object_manipulator.php +++ b/classes/local/object_manipulator/object_manipulator.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace tool_objectfs\local\object_manipulator; + +use stdClass; + /** * Object manipulator interface class. * @@ -22,11 +26,6 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - -namespace tool_objectfs\local\object_manipulator; - -use stdClass; - interface object_manipulator { diff --git a/classes/local/store/object_client.php b/classes/local/store/object_client.php index cd8cbc7f..80e3f6eb 100644 --- a/classes/local/store/object_client.php +++ b/classes/local/store/object_client.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace tool_objectfs\local\store; + /** * Objectfs client interface. * @@ -22,11 +24,7 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - -namespace tool_objectfs\local\store; - interface object_client { - /** * construct * @param \stdClass $config diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 2e6d16c6..ecfd06c3 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * Privacy provider. * diff --git a/classes/task/objectfs_task.php b/classes/task/objectfs_task.php index 33b8fb4a..86d39b2f 100644 --- a/classes/task/objectfs_task.php +++ b/classes/task/objectfs_task.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace tool_objectfs\task; + /** * Base abstract class for objectfs tasks. * @@ -22,9 +24,6 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - -namespace tool_objectfs\task; - interface objectfs_task { /** diff --git a/classes/tests/test_azure_integration_client.php b/classes/tests/test_azure_integration_client.php index cec69065..74965b27 100644 --- a/classes/tests/test_azure_integration_client.php +++ b/classes/tests/test_azure_integration_client.php @@ -19,8 +19,11 @@ use tool_objectfs\local\store\azure\client; /** - * [Description test_azure_integration_client] - * @package tool_objectfs + * Client used for integration testing azure client + * + * @package tool_objectfs + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class test_azure_integration_client extends client { diff --git a/classes/tests/test_client.php b/classes/tests/test_client.php index dbed5711..bda43c5e 100644 --- a/classes/tests/test_client.php +++ b/classes/tests/test_client.php @@ -19,8 +19,11 @@ use tool_objectfs\local\store\object_client_base; /** - * [Description test_client] - * @package tool_objectfs + * Test client for PHP unit tests + * + * @package tool_objectfs + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class test_client extends object_client_base { /** diff --git a/classes/tests/test_digitalocean_integration_client.php b/classes/tests/test_digitalocean_integration_client.php index 2a34c28c..5bf08cad 100644 --- a/classes/tests/test_digitalocean_integration_client.php +++ b/classes/tests/test_digitalocean_integration_client.php @@ -19,8 +19,11 @@ use tool_objectfs\local\store\digitalocean\client; /** - * [Description test_digitalocean_integration_client] - * @package tool_objectfs + * Client used for integration testing digitalocean client + * + * @package tool_objectfs + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class test_digitalocean_integration_client extends client { diff --git a/classes/tests/test_s3_integration_client.php b/classes/tests/test_s3_integration_client.php index 233f0b7e..06943973 100644 --- a/classes/tests/test_s3_integration_client.php +++ b/classes/tests/test_s3_integration_client.php @@ -19,8 +19,11 @@ use tool_objectfs\local\store\s3\client; /** - * [Description test_s3_integration_client] - * @package tool_objectfs + * Client used for integration testing aws client + * + * @package tool_objectfs + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class test_s3_integration_client extends client { diff --git a/classes/tests/test_swift_integration_client.php b/classes/tests/test_swift_integration_client.php index 4e1ede63..3013a299 100644 --- a/classes/tests/test_swift_integration_client.php +++ b/classes/tests/test_swift_integration_client.php @@ -19,8 +19,11 @@ use tool_objectfs\local\store\swift\client; /** - * [Description test_swift_integration_client] - * @package tool_objectfs + * Client used for integration testing swift client + * + * @package tool_objectfs + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class test_swift_integration_client extends client { diff --git a/classes/tests/testcase.php b/classes/tests/testcase.php index 6d85a3b5..f3efc8cf 100644 --- a/classes/tests/testcase.php +++ b/classes/tests/testcase.php @@ -26,8 +26,11 @@ use tool_objectfs\local\store\signed_url; /** - * [Description testcase] - * @package tool_objectfs + * Testcase with useful / shared methods for common objectfs tests. + * + * @package tool_objectfs + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ abstract class testcase extends \advanced_testcase { diff --git a/tests/local/object_manipulator/checker_test.php b/tests/local/object_manipulator/checker_test.php index 7ac8f98d..59699d8f 100644 --- a/tests/local/object_manipulator/checker_test.php +++ b/tests/local/object_manipulator/checker_test.php @@ -22,7 +22,9 @@ * Tests for object checker. * * @covers \tool_objectfs\local\object_manipulator\checker - * @package tool_objectfs + * @package tool_objectfs + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class checker_test extends \tool_objectfs\tests\testcase { diff --git a/tests/local/object_manipulator/deleter_test.php b/tests/local/object_manipulator/deleter_test.php index 56ddfa5b..a8b3f7a1 100644 --- a/tests/local/object_manipulator/deleter_test.php +++ b/tests/local/object_manipulator/deleter_test.php @@ -22,7 +22,9 @@ * Tests for object deleter. * * @covers \tool_objectfs\local\object_manipulator\deleter - * @package tool_objectfs + * @package tool_objectfs + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class deleter_test extends \tool_objectfs\tests\testcase { diff --git a/tests/local/object_manipulator/orphaner_test.php b/tests/local/object_manipulator/orphaner_test.php index 1498e0ff..9485b175 100644 --- a/tests/local/object_manipulator/orphaner_test.php +++ b/tests/local/object_manipulator/orphaner_test.php @@ -23,7 +23,9 @@ * Tests for object orphaner. * * @covers \tool_objectfs\local\object_manipulator\orphaner - * @package tool_objectfs + * @package tool_objectfs + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class orphaner_test extends \tool_objectfs\tests\testcase { diff --git a/tests/local/object_manipulator/puller_test.php b/tests/local/object_manipulator/puller_test.php index d54171cb..e00a81b9 100644 --- a/tests/local/object_manipulator/puller_test.php +++ b/tests/local/object_manipulator/puller_test.php @@ -22,7 +22,9 @@ * Tests for object puller. * * @covers \tool_objectfs\local\object_manipulator\puller - * @package tool_objectfs + * @package tool_objectfs + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class puller_test extends \tool_objectfs\tests\testcase { diff --git a/tests/local/object_manipulator/pusher_test.php b/tests/local/object_manipulator/pusher_test.php index e902f0be..37e832ba 100644 --- a/tests/local/object_manipulator/pusher_test.php +++ b/tests/local/object_manipulator/pusher_test.php @@ -23,7 +23,9 @@ * Tests for object pusher. * * @covers \tool_objectfs\local\object_manipulator\pusher - * @package tool_objectfs + * @package tool_objectfs + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class pusher_test extends \tool_objectfs\tests\testcase { diff --git a/tests/local/object_manipulator/recoverer_test.php b/tests/local/object_manipulator/recoverer_test.php index 1b8f7927..163677a4 100644 --- a/tests/local/object_manipulator/recoverer_test.php +++ b/tests/local/object_manipulator/recoverer_test.php @@ -23,7 +23,9 @@ * Tests for object recoverer. * * @covers \tool_objectfs\local\object_manipulator\recoverer - * @package tool_objectfs + * @package tool_objectfs + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class recoverer_test extends \tool_objectfs\tests\testcase { diff --git a/tests/local/tasks_test.php b/tests/local/tasks_test.php index afdc53b2..10f884fa 100644 --- a/tests/local/tasks_test.php +++ b/tests/local/tasks_test.php @@ -20,7 +20,9 @@ * End to end tests for tasks. Make sure all the plumbing is ok. * * @covers \tool_objectfs\local\manager - * @package tool_objectfs + * @package tool_objectfs + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class tasks_test extends \tool_objectfs\tests\testcase { diff --git a/tests/object_file_system_test.php b/tests/object_file_system_test.php index 0ccd2a5a..3621c064 100644 --- a/tests/object_file_system_test.php +++ b/tests/object_file_system_test.php @@ -24,7 +24,9 @@ * Test basic operations of object file system. * * @covers \tool_objectfs\local\store\object_file_system - * @package tool_objectfs + * @package tool_objectfs + * @copyright Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class object_file_system_test extends tests\testcase { From cf91aa2cd93afa0c31236cb958f7c405f85c501c Mon Sep 17 00:00:00 2001 From: Matthew Hilton Date: Tue, 17 Sep 2024 15:22:40 +1000 Subject: [PATCH 4/4] bugfix: load azure client in unit tests --- classes/tests/test_azure_integration_client.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/classes/tests/test_azure_integration_client.php b/classes/tests/test_azure_integration_client.php index 74965b27..c871e1f4 100644 --- a/classes/tests/test_azure_integration_client.php +++ b/classes/tests/test_azure_integration_client.php @@ -38,7 +38,10 @@ class test_azure_integration_client extends client { * @return void */ public function __construct($config) { - parent::__construct($config); + // Set config directly. Calling __construct will do nothing + // since unit tests do not have the azure sdk installed. + $this->config = $config; + $time = microtime(); $this->runidentifier = md5($time); }