separate some test AuthPlugins to single files

created AuthDeletePlugin and AuthCaseInsensitivePlugin under dokuwiki\test\mock
This commit is contained in:
Phy 2020-03-08 18:09:26 -04:00
parent 7a0654bebf
commit 4bdfdb3288
No known key found for this signature in database
GPG Key ID: D475AA55A8144239
7 changed files with 54 additions and 50 deletions

View File

@ -0,0 +1,12 @@
<?php
namespace dokuwiki\test\mock;
/**
* Class dokuwiki\Plugin\DokuWiki_Auth_Plugin
*/
class AuthCaseInsensitivePlugin extends AuthPlugin {
function isCaseSensitive(){
return false;
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace dokuwiki\test\mock;
/**
* Class dokuwiki\Plugin\DokuWiki_Auth_Plugin
*/
class AuthDeletePlugin extends AuthPlugin {
public $loggedOff = false;
public function __construct($canDeleteUser = true) {
$this->cando['delUser'] = $canDeleteUser;
}
public function checkPass($user, $pass) {
return $pass == 'password';
}
public function deleteUsers($users) {
return in_array($_SERVER['REMOTE_USER'], $users);
}
public function logoff() {
$this->loggedOff = true;
}
}

View File

@ -1,12 +1,6 @@
<?php
use dokuwiki\Extension\AuthPlugin;
class auth_acl_caseinsensitive_auth extends AuthPlugin {
function isCaseSensitive() {
return false;
}
}
use dokuwiki\test\mock\AuthCaseInsensitivePlugin;
class auth_acl_caseinsensitive_test extends DokuWikiTest {
protected $oldAuth;
@ -20,7 +14,7 @@ class auth_acl_caseinsensitive_test extends DokuWikiTest {
$this->oldAuth = $auth;
$this->oldAuthAcl = $AUTH_ACL;
$auth = new auth_acl_caseinsensitive_auth();
$auth = new AuthCaseInsensitivePlugin();
}
function tearDown() {

View File

@ -1,12 +1,7 @@
<?php
use dokuwiki\test\mock\AuthPlugin;
class auth_admin_test_AuthInSensitive extends AuthPlugin {
function isCaseSensitive(){
return false;
}
}
use dokuwiki\test\mock\AuthCaseInsensitivePlugin;
class auth_admin_test extends DokuWikiTest {
@ -25,7 +20,7 @@ class auth_admin_test extends DokuWikiTest {
function setInSensitive() {
global $auth;
$auth = new auth_admin_test_AuthInSensitive();
$auth = new AuthCaseInsensitivePlugin();
}
function teardown() {

View File

@ -1,29 +1,7 @@
<?php
use dokuwiki\Input\Input;
use dokuwiki\Extension\AuthPlugin;
class auth_deleteprofile_test_AuthDelete extends AuthPlugin {
public $loggedOff = false;
public function __construct($canDeleteUser = true) {
$this->cando['delUser'] = $canDeleteUser;
}
public function checkPass($user, $pass) {
return $pass == 'password';
}
public function deleteUsers($users) {
return in_array($_SERVER['REMOTE_USER'], $users);
}
public function logoff() {
$this->loggedOff = true;
}
}
use dokuwiki\test\mock\AuthDeletePlugin;
class auth_deleteprofile_test extends DokuWikiTest {
@ -56,7 +34,7 @@ class auth_deleteprofile_test extends DokuWikiTest {
$_REQUEST = $input;
$INPUT = new Input();
$auth = new auth_deleteprofile_test_AuthDelete();
$auth = new AuthDeletePlugin();
$this->assertTrue(auth_deleteprofile());
$this->assertTrue($auth->loggedOff);
@ -82,7 +60,7 @@ class auth_deleteprofile_test extends DokuWikiTest {
$_REQUEST = $input;
$INPUT = new Input();
$auth = new auth_deleteprofile_test_AuthDelete();
$auth = new AuthDeletePlugin();
// password check required - it fails, so don't delete profile
$this->assertFalse(auth_deleteprofile());
@ -112,7 +90,7 @@ class auth_deleteprofile_test extends DokuWikiTest {
$_REQUEST = $input;
$INPUT = new Input();
$auth = new auth_deleteprofile_test_AuthDelete(false);
$auth = new AuthDeletePlugin(false);
$conf['disableactions'] = '';
$this->assertFalse(auth_deleteprofile());
}
@ -136,7 +114,7 @@ class auth_deleteprofile_test extends DokuWikiTest {
$_REQUEST = $input;
$INPUT = new Input();
$auth = new auth_deleteprofile_test_AuthDelete();
$auth = new AuthDeletePlugin();
$conf['disableactions'] = 'profile_delete';
$this->assertFalse(actionOK('profile_delete'));
@ -165,7 +143,7 @@ class auth_deleteprofile_test extends DokuWikiTest {
$_REQUEST = $input;
$input_foundation = new Input();
$auth = new auth_deleteprofile_test_AuthDelete();
$auth = new AuthDeletePlugin();
$INPUT = clone $input_foundation;
$INPUT->remove('delete');

View File

@ -1,14 +1,10 @@
<?php
use dokuwiki\Extension\AuthPlugin;
use dokuwiki\test\mock\AuthPlugin;
use dokuwiki\Extension\RemotePlugin;
use dokuwiki\Remote\Api;
use dokuwiki\Remote\RemoteException;
class remote_test_MockAuthCase extends AuthPlugin {
function isCaseSensitive() { return true; }
}
class RemoteAPICoreTest {
function __getRemoteInfo() {
@ -169,7 +165,7 @@ class remote_test extends DokuWikiTest {
$this->userinfo = $USERINFO;
$this->remote = new Api();
$auth = new remote_test_MockAuthCase();
$auth = new AuthPlugin();
}
function tearDown() {

View File

@ -3,6 +3,7 @@
use dokuwiki\Remote\Api;
use dokuwiki\Remote\ApiCore;
use dokuwiki\test\mock\AuthPlugin;
use dokuwiki\test\mock\AuthDeletePlugin;
/**
* Class remoteapicore_test
@ -452,7 +453,7 @@ You can use up to five different levels of',
public function test_deleteUser()
{
global $conf, $auth;
$auth = new auth_deleteprofile_test_AuthDelete();
$auth = new AuthDeletePlugin();
$conf['remote'] = 1;
$conf['remoteuser'] = 'testuser';
$_SERVER['REMOTE_USER'] = 'testuser';