1e5da8fd9SAndreas Gohr<?php 2e5da8fd9SAndreas Gohr 3e5da8fd9SAndreas Gohrnamespace dokuwiki\plugin\pureldap\test; 4e5da8fd9SAndreas Gohr 5e5da8fd9SAndreas Gohr/** 6e5da8fd9SAndreas Gohr * @group plugin_pureldap 7e5da8fd9SAndreas Gohr * @group plugins 8e5da8fd9SAndreas Gohr */ 9e5da8fd9SAndreas Gohrclass AuthTest extends \DokuWikiTest { 10e5da8fd9SAndreas Gohr 11e5da8fd9SAndreas Gohr public function setUp(): void 12e5da8fd9SAndreas Gohr { 13e5da8fd9SAndreas Gohr parent::setUp(); 14e5da8fd9SAndreas Gohr 15e5da8fd9SAndreas Gohr global $conf; 16e5da8fd9SAndreas Gohr $conf['auth'] = 'pureldap'; 17e5da8fd9SAndreas Gohr $conf['plugin']['pureldap']['base_dn'] = 'DC=example,DC=local'; 18e5da8fd9SAndreas Gohr $conf['plugin']['pureldap']['suffix'] = 'example.local'; 19e5da8fd9SAndreas Gohr $conf['plugin']['pureldap']['servers'] = ['localhost']; 20e5da8fd9SAndreas Gohr $conf['plugin']['pureldap']['port'] = 7636; 21e5da8fd9SAndreas Gohr $conf['plugin']['pureldap']['admin_username'] = 'vagrant'; 22e5da8fd9SAndreas Gohr $conf['plugin']['pureldap']['admin_password'] = 'vagrant'; 23e5da8fd9SAndreas Gohr $conf['plugin']['pureldap']['encryption'] = 'ssl'; 24e5da8fd9SAndreas Gohr $conf['plugin']['pureldap']['validate'] = 'self'; 25e5da8fd9SAndreas Gohr } 26e5da8fd9SAndreas Gohr 27e5da8fd9SAndreas Gohr public function testADlogin() { 28e5da8fd9SAndreas Gohr $auth = new \auth_plugin_pureldap(); 29e5da8fd9SAndreas Gohr $this->assertTrue($auth->checkPass('a.legrand', 'Foo_b_ar123!')); 30e5da8fd9SAndreas Gohr $this->assertFalse($auth->checkPass('a.legrand', 'wrong password')); 31e5da8fd9SAndreas Gohr } 32e5da8fd9SAndreas Gohr 33*9bafffeaSAndreas Gohr public function testADLongUserLogin() 34*9bafffeaSAndreas Gohr { 35*9bafffeaSAndreas Gohr $auth = new \auth_plugin_pureldap(); 36*9bafffeaSAndreas Gohr 37*9bafffeaSAndreas Gohr // sam account name 38*9bafffeaSAndreas Gohr $this->assertTrue($auth->checkPass('longlong', 'Foo_b_ar123!')); 39*9bafffeaSAndreas Gohr $this->assertFalse($auth->checkPass('longlong', 'wrong password')); 40*9bafffeaSAndreas Gohr 41*9bafffeaSAndreas Gohr $this->assertTrue($auth->checkPass('averylongusernamethatisverylong', 'Foo_b_ar123!')); 42*9bafffeaSAndreas Gohr $this->assertFalse($auth->checkPass('averylongusernamethatisverylong', 'wrong password')); 43*9bafffeaSAndreas Gohr } 44*9bafffeaSAndreas Gohr 45e5da8fd9SAndreas Gohr public function testADloginSSO() { 46e5da8fd9SAndreas Gohr global $conf; 47e5da8fd9SAndreas Gohr $conf['plugin']['pureldap']['sso'] = 1; 48e5da8fd9SAndreas Gohr 49e5da8fd9SAndreas Gohr $_SERVER['REMOTE_USER'] = 'a.legrand'; 50e5da8fd9SAndreas Gohr 51e5da8fd9SAndreas Gohr $auth = new \auth_plugin_pureldap(); 52e5da8fd9SAndreas Gohr $this->assertTrue($auth->checkPass('a.legrand', 'sso-only')); 53e5da8fd9SAndreas Gohr } 54e5da8fd9SAndreas Gohr} 55