aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php286
1 files changed, 140 insertions, 146 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php
index fb73cc16a..2de0ba6a8 100644
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php
@@ -5,7 +5,6 @@ namespace Sabre\DAVACL;
use Sabre\DAV;
use Sabre\HTTP;
-
require_once 'Sabre/DAVACL/MockPrincipal.php';
require_once 'Sabre/DAVACL/MockACLNode.php';
@@ -14,21 +13,22 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase {
function testValues() {
$aclPlugin = new Plugin();
- $this->assertEquals('acl',$aclPlugin->getPluginName());
+ $this->assertEquals('acl', $aclPlugin->getPluginName());
$this->assertEquals(
- array('access-control', 'calendarserver-principal-property-search'),
+ ['access-control', 'calendarserver-principal-property-search'],
$aclPlugin->getFeatures()
);
$this->assertEquals(
- array(
+ [
'{DAV:}expand-property',
+ '{DAV:}principal-match',
'{DAV:}principal-property-search',
'{DAV:}principal-search-property-set'
- ),
+ ],
$aclPlugin->getSupportedReportSet(''));
- $this->assertEquals(array('ACL'), $aclPlugin->getMethods(''));
+ $this->assertEquals(['ACL'], $aclPlugin->getMethods(''));
$this->assertEquals(
@@ -39,90 +39,84 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase {
function testGetFlatPrivilegeSet() {
- $expected = array(
- '{DAV:}all' => array(
- 'privilege' => '{DAV:}all',
- 'abstract' => true,
- 'aggregates' => array(
+ $expected = [
+ '{DAV:}all' => [
+ 'privilege' => '{DAV:}all',
+ 'abstract' => false,
+ 'aggregates' => [
'{DAV:}read',
'{DAV:}write',
- ),
- 'concrete' => null,
- ),
- '{DAV:}read' => array(
- 'privilege' => '{DAV:}read',
- 'abstract' => false,
- 'aggregates' => array(
+ ],
+ 'concrete' => '{DAV:}all',
+ ],
+ '{DAV:}read' => [
+ 'privilege' => '{DAV:}read',
+ 'abstract' => false,
+ 'aggregates' => [
'{DAV:}read-acl',
'{DAV:}read-current-user-privilege-set',
- ),
+ ],
'concrete' => '{DAV:}read',
- ),
- '{DAV:}read-acl' => array(
- 'privilege' => '{DAV:}read-acl',
- 'abstract' => false,
- 'aggregates' => array(),
- 'concrete' => '{DAV:}read-acl',
- ),
- '{DAV:}read-current-user-privilege-set' => array(
- 'privilege' => '{DAV:}read-current-user-privilege-set',
- 'abstract' => false,
- 'aggregates' => array(),
- 'concrete' => '{DAV:}read-current-user-privilege-set',
- ),
- '{DAV:}write' => array(
- 'privilege' => '{DAV:}write',
- 'abstract' => false,
- 'aggregates' => array(
- '{DAV:}write-acl',
+ ],
+ '{DAV:}read-acl' => [
+ 'privilege' => '{DAV:}read-acl',
+ 'abstract' => false,
+ 'aggregates' => [],
+ 'concrete' => '{DAV:}read-acl',
+ ],
+ '{DAV:}read-current-user-privilege-set' => [
+ 'privilege' => '{DAV:}read-current-user-privilege-set',
+ 'abstract' => false,
+ 'aggregates' => [],
+ 'concrete' => '{DAV:}read-current-user-privilege-set',
+ ],
+ '{DAV:}write' => [
+ 'privilege' => '{DAV:}write',
+ 'abstract' => false,
+ 'aggregates' => [
'{DAV:}write-properties',
'{DAV:}write-content',
+ '{DAV:}unlock',
'{DAV:}bind',
'{DAV:}unbind',
- '{DAV:}unlock',
- ),
+ ],
'concrete' => '{DAV:}write',
- ),
- '{DAV:}write-acl' => array(
- 'privilege' => '{DAV:}write-acl',
- 'abstract' => false,
- 'aggregates' => array(),
- 'concrete' => '{DAV:}write-acl',
- ),
- '{DAV:}write-properties' => array(
- 'privilege' => '{DAV:}write-properties',
- 'abstract' => false,
- 'aggregates' => array(),
- 'concrete' => '{DAV:}write-properties',
- ),
- '{DAV:}write-content' => array(
- 'privilege' => '{DAV:}write-content',
- 'abstract' => false,
- 'aggregates' => array(),
- 'concrete' => '{DAV:}write-content',
- ),
- '{DAV:}unlock' => array(
- 'privilege' => '{DAV:}unlock',
- 'abstract' => false,
- 'aggregates' => array(),
- 'concrete' => '{DAV:}unlock',
- ),
- '{DAV:}bind' => array(
- 'privilege' => '{DAV:}bind',
- 'abstract' => false,
- 'aggregates' => array(),
- 'concrete' => '{DAV:}bind',
- ),
- '{DAV:}unbind' => array(
- 'privilege' => '{DAV:}unbind',
- 'abstract' => false,
- 'aggregates' => array(),
- 'concrete' => '{DAV:}unbind',
- ),
-
- );
+ ],
+ '{DAV:}write-properties' => [
+ 'privilege' => '{DAV:}write-properties',
+ 'abstract' => false,
+ 'aggregates' => [],
+ 'concrete' => '{DAV:}write-properties',
+ ],
+ '{DAV:}write-content' => [
+ 'privilege' => '{DAV:}write-content',
+ 'abstract' => false,
+ 'aggregates' => [],
+ 'concrete' => '{DAV:}write-content',
+ ],
+ '{DAV:}unlock' => [
+ 'privilege' => '{DAV:}unlock',
+ 'abstract' => false,
+ 'aggregates' => [],
+ 'concrete' => '{DAV:}unlock',
+ ],
+ '{DAV:}bind' => [
+ 'privilege' => '{DAV:}bind',
+ 'abstract' => false,
+ 'aggregates' => [],
+ 'concrete' => '{DAV:}bind',
+ ],
+ '{DAV:}unbind' => [
+ 'privilege' => '{DAV:}unbind',
+ 'abstract' => false,
+ 'aggregates' => [],
+ 'concrete' => '{DAV:}unbind',
+ ],
+
+ ];
$plugin = new Plugin();
+ $plugin->allowUnauthenticatedAccess = false;
$server = new DAV\Server();
$server->addPlugin($plugin);
$this->assertEquals($expected, $plugin->getFlatPrivilegeSet(''));
@@ -132,24 +126,26 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase {
function testCurrentUserPrincipalsNotLoggedIn() {
$acl = new Plugin();
+ $acl->allowUnauthenticatedAccess = false;
$server = new DAV\Server();
$server->addPlugin($acl);
- $this->assertEquals(array(),$acl->getCurrentUserPrincipals());
+ $this->assertEquals([], $acl->getCurrentUserPrincipals());
}
function testCurrentUserPrincipalsSimple() {
- $tree = array(
+ $tree = [
- new DAV\SimpleCollection('principals', array(
- new MockPrincipal('admin','principals/admin'),
- ))
+ new DAV\SimpleCollection('principals', [
+ new MockPrincipal('admin', 'principals/admin'),
+ ])
- );
+ ];
$acl = new Plugin();
+ $acl->allowUnauthenticatedAccess = false;
$server = new DAV\Server($tree);
$server->addPlugin($acl);
@@ -159,24 +155,25 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase {
//forcing login
$auth->beforeMethod(new HTTP\Request(), new HTTP\Response());
- $this->assertEquals(array('principals/admin'),$acl->getCurrentUserPrincipals());
+ $this->assertEquals(['principals/admin'], $acl->getCurrentUserPrincipals());
}
function testCurrentUserPrincipalsGroups() {
- $tree = array(
+ $tree = [
- new DAV\SimpleCollection('principals', array(
- new MockPrincipal('admin','principals/admin',array('principals/administrators', 'principals/everyone')),
- new MockPrincipal('administrators','principals/administrators',array('principals/groups'), array('principals/admin')),
- new MockPrincipal('everyone','principals/everyone',array(), array('principals/admin')),
- new MockPrincipal('groups','principals/groups',array(), array('principals/administrators')),
- ))
+ new DAV\SimpleCollection('principals', [
+ new MockPrincipal('admin', 'principals/admin', ['principals/administrators', 'principals/everyone']),
+ new MockPrincipal('administrators', 'principals/administrators', ['principals/groups'], ['principals/admin']),
+ new MockPrincipal('everyone', 'principals/everyone', [], ['principals/admin']),
+ new MockPrincipal('groups', 'principals/groups', [], ['principals/administrators']),
+ ])
- );
+ ];
$acl = new Plugin();
+ $acl->allowUnauthenticatedAccess = false;
$server = new DAV\Server($tree);
$server->addPlugin($acl);
@@ -186,75 +183,77 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase {
//forcing login
$auth->beforeMethod(new HTTP\Request(), new HTTP\Response());
- $expected = array(
+ $expected = [
'principals/admin',
'principals/administrators',
'principals/everyone',
'principals/groups',
- );
+ ];
- $this->assertEquals($expected,$acl->getCurrentUserPrincipals());
+ $this->assertEquals($expected, $acl->getCurrentUserPrincipals());
// The second one should trigger the cache and be identical
- $this->assertEquals($expected,$acl->getCurrentUserPrincipals());
+ $this->assertEquals($expected, $acl->getCurrentUserPrincipals());
}
function testGetACL() {
- $acl = array(
- array(
+ $acl = [
+ [
'principal' => 'principals/admin',
'privilege' => '{DAV:}read',
- ),
- array(
+ ],
+ [
'principal' => 'principals/admin',
'privilege' => '{DAV:}write',
- ),
- );
+ ],
+ ];
- $tree = array(
- new MockACLNode('foo',$acl),
- );
+ $tree = [
+ new MockACLNode('foo', $acl),
+ ];
$server = new DAV\Server($tree);
$aclPlugin = new Plugin();
+ $aclPlugin->allowUnauthenticatedAccess = false;
$server->addPlugin($aclPlugin);
- $this->assertEquals($acl,$aclPlugin->getACL('foo'));
+ $this->assertEquals($acl, $aclPlugin->getACL('foo'));
}
function testGetCurrentUserPrivilegeSet() {
- $acl = array(
- array(
+ $acl = [
+ [
'principal' => 'principals/admin',
'privilege' => '{DAV:}read',
- ),
- array(
+ ],
+ [
'principal' => 'principals/user1',
'privilege' => '{DAV:}read',
- ),
- array(
+ ],
+ [
'principal' => 'principals/admin',
'privilege' => '{DAV:}write',
- ),
- );
+ ],
+ ];
- $tree = array(
- new MockACLNode('foo',$acl),
+ $tree = [
+ new MockACLNode('foo', $acl),
- new DAV\SimpleCollection('principals', array(
- new MockPrincipal('admin','principals/admin'),
- )),
+ new DAV\SimpleCollection('principals', [
+ new MockPrincipal('admin', 'principals/admin'),
+ ]),
- );
+ ];
$server = new DAV\Server($tree);
$aclPlugin = new Plugin();
+ $aclPlugin->allowUnauthenticatedAccess = false;
$server->addPlugin($aclPlugin);
$auth = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock());
@@ -263,52 +262,51 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase {
//forcing login
$auth->beforeMethod(new HTTP\Request(), new HTTP\Response());
- $expected = array(
+ $expected = [
'{DAV:}write',
- '{DAV:}write-acl',
'{DAV:}write-properties',
'{DAV:}write-content',
- '{DAV:}bind',
- '{DAV:}unbind',
'{DAV:}unlock',
+ '{DAV:}write-acl',
'{DAV:}read',
'{DAV:}read-acl',
'{DAV:}read-current-user-privilege-set',
- );
+ ];
- $this->assertEquals($expected,$aclPlugin->getCurrentUserPrivilegeSet('foo'));
+ $this->assertEquals($expected, $aclPlugin->getCurrentUserPrivilegeSet('foo'));
}
function testCheckPrivileges() {
- $acl = array(
- array(
+ $acl = [
+ [
'principal' => 'principals/admin',
'privilege' => '{DAV:}read',
- ),
- array(
+ ],
+ [
'principal' => 'principals/user1',
'privilege' => '{DAV:}read',
- ),
- array(
+ ],
+ [
'principal' => 'principals/admin',
'privilege' => '{DAV:}write',
- ),
- );
+ ],
+ ];
- $tree = array(
- new MockACLNode('foo',$acl),
+ $tree = [
+ new MockACLNode('foo', $acl),
- new DAV\SimpleCollection('principals', array(
- new MockPrincipal('admin','principals/admin'),
- )),
+ new DAV\SimpleCollection('principals', [
+ new MockPrincipal('admin', 'principals/admin'),
+ ]),
- );
+ ];
$server = new DAV\Server($tree);
$aclPlugin = new Plugin();
+ $aclPlugin->allowUnauthenticatedAccess = false;
$server->addPlugin($aclPlugin);
$auth = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock());
@@ -317,11 +315,7 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase {
//forcing login
//$auth->beforeMethod('GET','/');
- $this->assertFalse($aclPlugin->checkPrivileges('foo', array('{DAV:}read'), Plugin::R_PARENT, false));
+ $this->assertFalse($aclPlugin->checkPrivileges('foo', ['{DAV:}read'], Plugin::R_PARENT, false));
}
}
-
-
-
-