More adjusted API tests
This commit is contained in:
parent
01052543c4
commit
285c73a173
|
@ -1,11 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace dokuwiki\test\Remote;
|
||||
|
||||
use dokuwiki\Remote\Api;
|
||||
|
||||
/**
|
||||
* Class remoteapicore_test
|
||||
*/
|
||||
class remoteapicore_aclcheck_test extends DokuWikiTest {
|
||||
class ApiCoreAclCheckTest extends \DokuWikiTest {
|
||||
|
||||
protected $userinfo;
|
||||
protected $oldAuthAcl;
|
||||
|
@ -18,7 +20,7 @@ class remoteapicore_aclcheck_test extends DokuWikiTest {
|
|||
global $auth;
|
||||
|
||||
/* auth caches data loaded from file, but recreated object forces reload */
|
||||
$auth = new auth_plugin_authplain();
|
||||
$auth = new \auth_plugin_authplain();
|
||||
}
|
||||
|
||||
public function setUp() : void {
|
||||
|
@ -58,7 +60,7 @@ class remoteapicore_aclcheck_test extends DokuWikiTest {
|
|||
copy($name . ".orig", $name);
|
||||
}
|
||||
|
||||
public function test_checkacl() {
|
||||
public function testCheckacl() {
|
||||
global $conf;
|
||||
global $AUTH_ACL, $USERINFO;
|
||||
/** @var auth_plugin_authplain $auth */
|
||||
|
@ -66,71 +68,71 @@ class remoteapicore_aclcheck_test extends DokuWikiTest {
|
|||
|
||||
$conf['useacl'] = 1;
|
||||
$_SERVER['REMOTE_USER'] = 'john';
|
||||
$USERINFO['grps'] = array('user');
|
||||
$AUTH_ACL = array(
|
||||
$USERINFO['grps'] = ['user'];
|
||||
$AUTH_ACL = [
|
||||
'* @ALL 0', //none
|
||||
'* @user 2', //edit
|
||||
'* @more 4', //create
|
||||
'nice_page user2 8' //upload
|
||||
);
|
||||
];
|
||||
|
||||
$params = array('nice_page');
|
||||
$params = ['nice_page'];
|
||||
$this->assertEquals(AUTH_EDIT, $this->remote->call('wiki.aclCheck', $params));
|
||||
|
||||
$auth->createUser("user1", "54321", "a User", "you@example.com");
|
||||
$auth->createUser("user2", "543210", "You", "he@example.com");
|
||||
$auth->createUser("mwuser", "12345", "Wiki User", "me@example.com", array('more')); //not in default group
|
||||
$auth->createUser("mwuser", "12345", "Wiki User", "me@example.com", ['more']); //not in default group
|
||||
|
||||
$params = array(
|
||||
$params = [
|
||||
'nice_page',
|
||||
'user1'
|
||||
);
|
||||
];
|
||||
$this->assertEquals(AUTH_EDIT, $this->remote->call('wiki.aclCheck', $params));
|
||||
|
||||
$params = array(
|
||||
$params = [
|
||||
'nice_page',
|
||||
'mwuser' // member of group 'more'
|
||||
);
|
||||
];
|
||||
$this->assertEquals(AUTH_CREATE, $this->remote->call('wiki.aclCheck', $params));
|
||||
|
||||
$params = array(
|
||||
$params = [
|
||||
'nice_page',
|
||||
'mwuser',
|
||||
array() //groups not retrieved
|
||||
);
|
||||
[] //groups not retrieved
|
||||
];
|
||||
$this->assertEquals(AUTH_NONE, $this->remote->call('wiki.aclCheck', $params));
|
||||
|
||||
$params = array(
|
||||
$params = [
|
||||
'nice_page',
|
||||
'notexistinguser',
|
||||
array('more')
|
||||
);
|
||||
['more']
|
||||
];
|
||||
$this->assertEquals(AUTH_CREATE, $this->remote->call('wiki.aclCheck', $params));
|
||||
|
||||
$params = array(
|
||||
$params = [
|
||||
'nice_page',
|
||||
'user2'
|
||||
);
|
||||
];
|
||||
$this->assertEquals(AUTH_UPLOAD, $this->remote->call('wiki.aclCheck', $params));
|
||||
|
||||
$params = array(
|
||||
$params = [
|
||||
'nice_page',
|
||||
'user2',
|
||||
array() //groups not retrieved
|
||||
);
|
||||
[] //groups not retrieved
|
||||
];
|
||||
$this->assertEquals(AUTH_UPLOAD, $this->remote->call('wiki.aclCheck', $params));
|
||||
|
||||
$params = array(
|
||||
$params = [
|
||||
'unknown_page',
|
||||
'user2'
|
||||
);
|
||||
];
|
||||
$this->assertEquals(AUTH_EDIT, $this->remote->call('wiki.aclCheck', $params));
|
||||
|
||||
$params = array(
|
||||
$params = [
|
||||
'unknown_page',
|
||||
'user2',
|
||||
array() //groups not retrieved
|
||||
);
|
||||
[] //groups not retrieved
|
||||
];
|
||||
$this->assertEquals(AUTH_NONE, $this->remote->call('wiki.aclCheck', $params));
|
||||
|
||||
$params = array(
|
Loading…
Reference in New Issue