. /** * Tests for auth_plugin_userkey class. * * @package auth_userkey * @copyright 2016 Dmitrii Metelkin (dmitriim@catalyst-au.net) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * Tests for auth_plugin_userkey class. * * @copyright 2016 Dmitrii Metelkin (dmitriim@catalyst-au.net) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class auth_plugin_userkey_testcase extends advanced_testcase { /** * An instance of auth_plugin_userkey class. * @var auth_plugin_userkey */ protected $auth; /** * Initial set up. */ public function setUp() { global $CFG; require_once($CFG->dirroot . '/auth/userkey/auth.php'); $this->auth = new auth_plugin_userkey(); $this->resetAfterTest(); } /** * Test that users can't login using login form. */ public function test_users_can_not_login_using_login_form() { $user = new stdClass(); $user->auth = 'userkey'; $user->username = 'username'; $user->password = 'correctpassword'; self::getDataGenerator()->create_user($user); $this->assertFalse($this->auth->user_login('username', 'correctpassword')); $this->assertFalse($this->auth->user_login('username', 'incorrectpassword')); } /** * Test that the plugin doesn't allow to store users passwords. */ public function test_auth_plugin_does_not_allow_to_store_passwords() { $this->assertTrue($this->auth->prevent_local_passwords()); } /** * Test that the plugin is external. */ public function test_auth_plugin_is_external() { $this->assertFalse($this->auth->is_internal()); } /** * Test that the plugin doesn't allow users to change the passwords. */ public function test_auth_plugin_does_not_allow_to_change_passwords() { $this->assertFalse($this->auth->can_change_password()); } }