1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Tests for BigBlueButton Proxy server (and checksum). 19 * 20 * @package mod_bigbluebuttonbn 21 * @copyright 2018 - present, Blindside Networks Inc 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 * @author Laurent David (laurent [at] call-learning [dt] fr) 24 */ 25 26 namespace mod_bigbluebuttonbn\local\proxy; 27 use mod_bigbluebuttonbn\test\testcase_helper_trait; 28 29 /** 30 * Proxy base test 31 * 32 * @package mod_bigbluebuttonbn 33 * @copyright 2018 - present, Blindside Networks Inc 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 * @author Laurent David (laurent [at] call-learning [dt] fr) 36 * @covers \mod_bigbluebuttonbn\local\proxy\proxy_base 37 * @coversDefaultClass \mod_bigbluebuttonbn\local\proxy\proxy_base 38 */ 39 class proxy_base_test extends \advanced_testcase { 40 use testcase_helper_trait; 41 42 /** 43 * Setup 44 */ 45 public function setUp(): void { 46 parent::setUp(); 47 $this->initialise_mock_server(); 48 } 49 50 /** 51 * Test that different checksum algorithm work 52 * 53 * @return void 54 */ 55 public function test_get_checksum() { 56 $this->resetAfterTest(); 57 foreach (['SHA1', 'SHA512', 'SHA256'] as $algo) { 58 set_config('bigbluebuttonbn_checksum_algorithm', $algo); 59 $xmlinfo = self::get_status(); 60 $this->assertNotEmpty($xmlinfo); 61 $this->assertEquals('SUCCESS', $xmlinfo->returncode); 62 } 63 } 64 65 /** 66 * Test that we send a checksumError whenever the algorithm is not supported 67 * 68 * @return void 69 */ 70 public function test_get_checksum_not_supported() { 71 $this->resetAfterTest(); 72 $bbbgenerator = $this->getDataGenerator()->get_plugin_generator('mod_bigbluebuttonbn'); 73 $bbbgenerator->set_value('checksum_algorithms', ['SHA1', 'SHA256']); 74 // This should not be supported. 75 set_config('bigbluebuttonbn_checksum_algorithm', 'SHA512'); 76 $xmlinfo = self::get_status(); 77 $this->assertEquals($xmlinfo->messageKey, 'checksumError'); 78 } 79 80 81 /** 82 * Get the endpoint XML result. 83 * 84 * @return mixed 85 */ 86 protected static function get_status() { 87 $rc = new \ReflectionClass(proxy_base::class); 88 $rcm = $rc->getMethod('fetch_endpoint_xml'); 89 $rcm->setAccessible(true); 90 return $rcm->invoke(null, ''); 91 } 92 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body