aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php145
1 files changed, 104 insertions, 41 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php
index e5b7e1a3f..fb42efba7 100644
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php
@@ -10,6 +10,14 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
function testPrincipalCollectionSet() {
$plugin = new Plugin();
+ $plugin->allowUnauthenticatedAccess = false;
+ $plugin->setDefaultACL([
+ [
+ 'principal' => '{DAV:}all',
+ 'privilege' => '{DAV:}all',
+ ],
+ ]);
+ //Anyone can do anything
$plugin->principalCollectionSet = [
'principals1',
'principals2',
@@ -25,8 +33,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$result = $server->getPropertiesForPath('', $requestedProperties);
$result = $result[0];
- $this->assertEquals(1,count($result[200]));
- $this->assertArrayHasKey('{DAV:}principal-collection-set',$result[200]);
+ $this->assertEquals(1, count($result[200]));
+ $this->assertArrayHasKey('{DAV:}principal-collection-set', $result[200]);
$this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}principal-collection-set']);
$expected = [
@@ -46,6 +54,12 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock());
$fakeServer->addPlugin($plugin);
$plugin = new Plugin();
+ $plugin->setDefaultACL([
+ [
+ 'principal' => '{DAV:}all',
+ 'privilege' => '{DAV:}all',
+ ],
+ ]);
$fakeServer->addPlugin($plugin);
@@ -56,8 +70,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$result = $fakeServer->getPropertiesForPath('', $requestedProperties);
$result = $result[0];
- $this->assertEquals(1,count($result[200]));
- $this->assertArrayHasKey('{DAV:}current-user-principal',$result[200]);
+ $this->assertEquals(1, count($result[200]));
+ $this->assertArrayHasKey('{DAV:}current-user-principal', $result[200]);
$this->assertInstanceOf('Sabre\DAVACL\Xml\Property\Principal', $result[200]['{DAV:}current-user-principal']);
$this->assertEquals(Xml\Property\Principal::UNAUTHENTICATED, $result[200]['{DAV:}current-user-principal']->getType());
@@ -67,8 +81,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$result = $fakeServer->getPropertiesForPath('', $requestedProperties);
$result = $result[0];
- $this->assertEquals(1,count($result[200]));
- $this->assertArrayHasKey('{DAV:}current-user-principal',$result[200]);
+ $this->assertEquals(1, count($result[200]));
+ $this->assertArrayHasKey('{DAV:}current-user-principal', $result[200]);
$this->assertInstanceOf('Sabre\DAVACL\Xml\Property\Principal', $result[200]['{DAV:}current-user-principal']);
$this->assertEquals(Xml\Property\Principal::HREF, $result[200]['{DAV:}current-user-principal']->getType());
$this->assertEquals('principals/admin/', $result[200]['{DAV:}current-user-principal']->getHref());
@@ -78,6 +92,13 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
function testSupportedPrivilegeSet() {
$plugin = new Plugin();
+ $plugin->allowUnauthenticatedAccess = false;
+ $plugin->setDefaultACL([
+ [
+ 'principal' => '{DAV:}all',
+ 'privilege' => '{DAV:}all',
+ ],
+ ]);
$server = new DAV\Server();
$server->addPlugin($plugin);
@@ -88,8 +109,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$result = $server->getPropertiesForPath('', $requestedProperties);
$result = $result[0];
- $this->assertEquals(1,count($result[200]));
- $this->assertArrayHasKey('{DAV:}supported-privilege-set',$result[200]);
+ $this->assertEquals(1, count($result[200]));
+ $this->assertArrayHasKey('{DAV:}supported-privilege-set', $result[200]);
$this->assertInstanceOf('Sabre\\DAVACL\\Xml\\Property\\SupportedPrivilegeSet', $result[200]['{DAV:}supported-privilege-set']);
$server = new DAV\Server();
@@ -98,26 +119,25 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$result = $server->xml->write('{DAV:}root', $prop);
$xpaths = [
- '/d:root' => 1,
- '/d:root/d:supported-privilege' => 1,
- '/d:root/d:supported-privilege/d:privilege' => 1,
- '/d:root/d:supported-privilege/d:privilege/d:all' => 1,
- '/d:root/d:supported-privilege/d:abstract' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege' => 2,
- '/d:root/d:supported-privilege/d:supported-privilege/d:privilege' => 2,
- '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:read' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:write' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege' => 8,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege' => 8,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-acl' => 1,
+ '/d:root' => 1,
+ '/d:root/d:supported-privilege' => 1,
+ '/d:root/d:supported-privilege/d:privilege' => 1,
+ '/d:root/d:supported-privilege/d:privilege/d:all' => 1,
+ '/d:root/d:supported-privilege/d:abstract' => 0,
+ '/d:root/d:supported-privilege/d:supported-privilege' => 2,
+ '/d:root/d:supported-privilege/d:supported-privilege/d:privilege' => 2,
+ '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:read' => 1,
+ '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:write' => 1,
+ '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege' => 7,
+ '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege' => 7,
+ '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-acl' => 1,
'/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-current-user-privilege-set' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-content' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-properties' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-acl' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:bind' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unbind' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unlock' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:abstract' => 0,
+ '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-content' => 1,
+ '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-properties' => 1,
+ '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:bind' => 1,
+ '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unbind' => 1,
+ '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unlock' => 1,
+ '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:abstract' => 0,
];
@@ -126,10 +146,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$dom2->loadXML($result);
$dxpath = new \DOMXPath($dom2);
- $dxpath->registerNamespace('d','DAV:');
- foreach($xpaths as $xpath=>$count) {
+ $dxpath->registerNamespace('d', 'DAV:');
+ foreach ($xpaths as $xpath => $count) {
- $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count. ' Full XML: ' . $result);
+ $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count . ' Full XML: ' . $result);
}
@@ -138,6 +158,13 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
function testACL() {
$plugin = new Plugin();
+ $plugin->allowUnauthenticatedAccess = false;
+ $plugin->setDefaultACL([
+ [
+ 'principal' => '{DAV:}all',
+ 'privilege' => '{DAV:}all',
+ ],
+ ]);
$nodes = [
new MockACLNode('foo', [
@@ -147,7 +174,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
]
]),
new DAV\SimpleCollection('principals', [
- $principal = new MockPrincipal('admin','principals/admin'),
+ $principal = new MockPrincipal('admin', 'principals/admin'),
]),
];
@@ -167,8 +194,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$result = $server->getPropertiesForPath('foo', $requestedProperties);
$result = $result[0];
- $this->assertEquals(1,count($result[200]),'The {DAV:}acl property did not return from the list. Full list: ' . print_r($result, true));
- $this->assertArrayHasKey('{DAV:}acl',$result[200]);
+ $this->assertEquals(1, count($result[200]), 'The {DAV:}acl property did not return from the list. Full list: ' . print_r($result, true));
+ $this->assertArrayHasKey('{DAV:}acl', $result[200]);
$this->assertInstanceOf('Sabre\\DAVACL\\Xml\Property\\Acl', $result[200]['{DAV:}acl']);
}
@@ -176,6 +203,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
function testACLRestrictions() {
$plugin = new Plugin();
+ $plugin->allowUnauthenticatedAccess = false;
$nodes = [
new MockACLNode('foo', [
@@ -185,7 +213,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
]
]),
new DAV\SimpleCollection('principals', [
- $principal = new MockPrincipal('admin','principals/admin'),
+ $principal = new MockPrincipal('admin', 'principals/admin'),
]),
];
@@ -205,8 +233,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$result = $server->getPropertiesForPath('foo', $requestedProperties);
$result = $result[0];
- $this->assertEquals(1,count($result[200]),'The {DAV:}acl-restrictions property did not return from the list. Full list: ' . print_r($result, true));
- $this->assertArrayHasKey('{DAV:}acl-restrictions',$result[200]);
+ $this->assertEquals(1, count($result[200]), 'The {DAV:}acl-restrictions property did not return from the list. Full list: ' . print_r($result, true));
+ $this->assertArrayHasKey('{DAV:}acl-restrictions', $result[200]);
$this->assertInstanceOf('Sabre\\DAVACL\\Xml\\Property\\AclRestrictions', $result[200]['{DAV:}acl-restrictions']);
}
@@ -215,7 +243,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$tree = [
new DAV\SimpleCollection('principals', [
- $principal = new MockPrincipal('user','principals/user'),
+ $principal = new MockPrincipal('user', 'principals/user'),
])
];
@@ -223,6 +251,13 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
//$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend())
//$fakeServer->addPlugin($plugin);
$plugin = new Plugin();
+ $plugin->allowUnauthenticatedAccess = false;
+ $plugin->setDefaultACL([
+ [
+ 'principal' => '{DAV:}all',
+ 'privilege' => '{DAV:}all',
+ ],
+ ]);
$fakeServer->addPlugin($plugin);
$requestedProperties = [
@@ -243,7 +278,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$tree = [
new DAV\SimpleCollection('principals', [
- $principal = new MockPrincipal('user','principals/user'),
+ $principal = new MockPrincipal('user', 'principals/user'),
]),
];
@@ -251,6 +286,13 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
//$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend());
//$fakeServer->addPlugin($plugin);
$plugin = new Plugin();
+ $plugin->allowUnauthenticatedAccess = false;
+ $plugin->setDefaultACL([
+ [
+ 'principal' => '{DAV:}all',
+ 'privilege' => '{DAV:}all',
+ ],
+ ]);
$fakeServer->addPlugin($plugin);
$requestedProperties = [
@@ -272,7 +314,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$tree = [
new DAV\SimpleCollection('principals', [
- $principal = new MockPrincipal('user','principals/user'),
+ $principal = new MockPrincipal('user', 'principals/user'),
]),
];
@@ -280,6 +322,13 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
//$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend());
//$fakeServer->addPlugin($plugin);
$plugin = new Plugin();
+ $plugin->allowUnauthenticatedAccess = false;
+ $plugin->setDefaultACL([
+ [
+ 'principal' => '{DAV:}all',
+ 'privilege' => '{DAV:}all',
+ ],
+ ]);
$fakeServer->addPlugin($plugin);
$requestedProperties = [
@@ -301,13 +350,20 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$tree = [
new DAV\SimpleCollection('principals', [
- $principal = new MockPrincipal('user','principals/user'),
+ $principal = new MockPrincipal('user', 'principals/user'),
]),
];
$fakeServer = new DAV\Server($tree);
$plugin = new Plugin();
+ $plugin->allowUnauthenticatedAccess = false;
$fakeServer->addPlugin($plugin);
+ $plugin->setDefaultACL([
+ [
+ 'principal' => '{DAV:}all',
+ 'privilege' => '{DAV:}all',
+ ],
+ ]);
$requestedProperties = [
'{DAV:}group-membership',
@@ -328,13 +384,20 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$tree = [
new DAV\SimpleCollection('principals', [
- $principal = new MockPrincipal('user','principals/user'),
+ $principal = new MockPrincipal('user', 'principals/user'),
]),
];
$fakeServer = new DAV\Server($tree);
$plugin = new Plugin();
+ $plugin->allowUnauthenticatedAccess = false;
$fakeServer->addPlugin($plugin);
+ $plugin->setDefaultACL([
+ [
+ 'principal' => '{DAV:}all',
+ 'privilege' => '{DAV:}all',
+ ],
+ ]);
$requestedProperties = [
'{DAV:}displayname',