13 $plugin->allowUnauthenticatedAccess =
false;
14 $plugin->setDefaultACL([
16 'principal' =>
'{DAV:}all',
17 'privilege' =>
'{DAV:}all',
21 $plugin->principalCollectionSet = [
26 $requestedProperties = [
27 '{DAV:}principal-collection-set',
36 $this->assertEquals(1, count(
$result[200]));
37 $this->assertArrayHasKey(
'{DAV:}principal-collection-set',
$result[200]);
38 $this->assertInstanceOf(
'Sabre\\DAV\\Xml\\Property\\Href',
$result[200][
'{DAV:}principal-collection-set']);
46 $this->assertEquals($expected,
$result[200][
'{DAV:}principal-collection-set']->getHrefs());
55 $fakeServer->addPlugin($plugin);
57 $plugin->setDefaultACL([
59 'principal' =>
'{DAV:}all',
60 'privilege' =>
'{DAV:}all',
63 $fakeServer->addPlugin($plugin);
66 $requestedProperties = [
67 '{DAV:}current-user-principal',
70 $result = $fakeServer->getPropertiesForPath(
'', $requestedProperties);
73 $this->assertEquals(1, count(
$result[200]));
74 $this->assertArrayHasKey(
'{DAV:}current-user-principal',
$result[200]);
75 $this->assertInstanceOf(
'Sabre\DAVACL\Xml\Property\Principal',
$result[200][
'{DAV:}current-user-principal']);
76 $this->assertEquals(Xml\Property\Principal::UNAUTHENTICATED,
$result[200][
'{DAV:}current-user-principal']->getType());
79 $fakeServer->emit(
'beforeMethod', [$fakeServer->httpRequest, $fakeServer->httpResponse]);
81 $result = $fakeServer->getPropertiesForPath(
'', $requestedProperties);
84 $this->assertEquals(1, count(
$result[200]));
85 $this->assertArrayHasKey(
'{DAV:}current-user-principal',
$result[200]);
86 $this->assertInstanceOf(
'Sabre\DAVACL\Xml\Property\Principal',
$result[200][
'{DAV:}current-user-principal']);
87 $this->assertEquals(Xml\Property\Principal::HREF,
$result[200][
'{DAV:}current-user-principal']->getType());
88 $this->assertEquals(
'principals/admin/',
$result[200][
'{DAV:}current-user-principal']->getHref());
95 $plugin->allowUnauthenticatedAccess =
false;
96 $plugin->setDefaultACL([
98 'principal' =>
'{DAV:}all',
99 'privilege' =>
'{DAV:}all',
105 $requestedProperties = [
106 '{DAV:}supported-privilege-set',
109 $result =
$server->getPropertiesForPath(
'', $requestedProperties);
112 $this->assertEquals(1, count(
$result[200]));
113 $this->assertArrayHasKey(
'{DAV:}supported-privilege-set',
$result[200]);
114 $this->assertInstanceOf(
'Sabre\\DAVACL\\Xml\\Property\\SupportedPrivilegeSet',
$result[200][
'{DAV:}supported-privilege-set']);
118 $prop =
$result[200][
'{DAV:}supported-privilege-set'];
123 '/d:root/d:supported-privilege' => 1,
124 '/d:root/d:supported-privilege/d:privilege' => 1,
125 '/d:root/d:supported-privilege/d:privilege/d:all' => 1,
126 '/d:root/d:supported-privilege/d:abstract' => 0,
127 '/d:root/d:supported-privilege/d:supported-privilege' => 2,
128 '/d:root/d:supported-privilege/d:supported-privilege/d:privilege' => 2,
129 '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:read' => 1,
130 '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:write' => 1,
131 '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege' => 7,
132 '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege' => 7,
133 '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-acl' => 1,
134 '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-current-user-privilege-set' => 1,
135 '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-content' => 1,
136 '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-properties' => 1,
137 '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:bind' => 1,
138 '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unbind' => 1,
139 '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unlock' => 1,
140 '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:abstract' => 0,
145 $dom2 = new \DOMDocument(
'1.0',
'utf-8');
148 $dxpath = new \DOMXPath($dom2);
149 $dxpath->registerNamespace(
'd',
'DAV:');
150 foreach ($xpaths as $xpath => $count) {
152 $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);
161 $plugin->allowUnauthenticatedAccess =
false;
162 $plugin->setDefaultACL([
164 'principal' =>
'{DAV:}all',
165 'privilege' =>
'{DAV:}all',
172 'principal' =>
'principals/admin',
173 'privilege' =>
'{DAV:}read',
190 $requestedProperties = [
194 $result =
$server->getPropertiesForPath(
'foo', $requestedProperties);
197 $this->assertEquals(1, count(
$result[200]),
'The {DAV:}acl property did not return from the list. Full list: ' . print_r(
$result,
true));
198 $this->assertArrayHasKey(
'{DAV:}acl',
$result[200]);
199 $this->assertInstanceOf(
'Sabre\\DAVACL\\Xml\Property\\Acl',
$result[200][
'{DAV:}acl']);
206 $plugin->allowUnauthenticatedAccess =
false;
211 'principal' =>
'principals/admin',
212 'privilege' =>
'{DAV:}read',
229 $requestedProperties = [
230 '{DAV:}acl-restrictions',
233 $result =
$server->getPropertiesForPath(
'foo', $requestedProperties);
236 $this->assertEquals(1, count(
$result[200]),
'The {DAV:}acl-restrictions property did not return from the list. Full list: ' . print_r(
$result,
true));
237 $this->assertArrayHasKey(
'{DAV:}acl-restrictions',
$result[200]);
238 $this->assertInstanceOf(
'Sabre\\DAVACL\\Xml\\Property\\AclRestrictions',
$result[200][
'{DAV:}acl-restrictions']);
254 $plugin->allowUnauthenticatedAccess =
false;
255 $plugin->setDefaultACL([
257 'principal' =>
'{DAV:}all',
258 'privilege' =>
'{DAV:}all',
261 $fakeServer->addPlugin($plugin);
263 $requestedProperties = [
264 '{DAV:}alternate-URI-set',
266 $result = $fakeServer->getPropertiesForPath(
'principals/user', $requestedProperties);
269 $this->assertTrue(isset(
$result[200]));
270 $this->assertTrue(isset(
$result[200][
'{DAV:}alternate-URI-set']));
271 $this->assertInstanceOf(
'Sabre\\DAV\\Xml\\Property\\Href',
$result[200][
'{DAV:}alternate-URI-set']);
273 $this->assertEquals([],
$result[200][
'{DAV:}alternate-URI-set']->getHrefs());
289 $plugin->allowUnauthenticatedAccess =
false;
290 $plugin->setDefaultACL([
292 'principal' =>
'{DAV:}all',
293 'privilege' =>
'{DAV:}all',
296 $fakeServer->addPlugin($plugin);
298 $requestedProperties = [
299 '{DAV:}principal-URL',
302 $result = $fakeServer->getPropertiesForPath(
'principals/user', $requestedProperties);
305 $this->assertTrue(isset(
$result[200]));
306 $this->assertTrue(isset(
$result[200][
'{DAV:}principal-URL']));
307 $this->assertInstanceOf(
'Sabre\\DAV\\Xml\\Property\\Href',
$result[200][
'{DAV:}principal-URL']);
309 $this->assertEquals(
'principals/user/',
$result[200][
'{DAV:}principal-URL']->getHref());
325 $plugin->allowUnauthenticatedAccess =
false;
326 $plugin->setDefaultACL([
328 'principal' =>
'{DAV:}all',
329 'privilege' =>
'{DAV:}all',
332 $fakeServer->addPlugin($plugin);
334 $requestedProperties = [
335 '{DAV:}group-member-set',
338 $result = $fakeServer->getPropertiesForPath(
'principals/user', $requestedProperties);
341 $this->assertTrue(isset(
$result[200]));
342 $this->assertTrue(isset(
$result[200][
'{DAV:}group-member-set']));
343 $this->assertInstanceOf(
'Sabre\\DAV\\Xml\\Property\\Href',
$result[200][
'{DAV:}group-member-set']);
345 $this->assertEquals([],
$result[200][
'{DAV:}group-member-set']->getHrefs());
359 $plugin->allowUnauthenticatedAccess =
false;
360 $fakeServer->addPlugin($plugin);
361 $plugin->setDefaultACL([
363 'principal' =>
'{DAV:}all',
364 'privilege' =>
'{DAV:}all',
368 $requestedProperties = [
369 '{DAV:}group-membership',
372 $result = $fakeServer->getPropertiesForPath(
'principals/user', $requestedProperties);
375 $this->assertTrue(isset(
$result[200]));
376 $this->assertTrue(isset(
$result[200][
'{DAV:}group-membership']));
377 $this->assertInstanceOf(
'Sabre\\DAV\\Xml\\Property\\Href',
$result[200][
'{DAV:}group-membership']);
379 $this->assertEquals([],
$result[200][
'{DAV:}group-membership']->getHrefs());
393 $plugin->allowUnauthenticatedAccess =
false;
394 $fakeServer->addPlugin($plugin);
395 $plugin->setDefaultACL([
397 'principal' =>
'{DAV:}all',
398 'privilege' =>
'{DAV:}all',
402 $requestedProperties = [
406 $result = $fakeServer->getPropertiesForPath(
'principals/user', $requestedProperties);
409 $this->assertTrue(isset(
$result[200]));
410 $this->assertTrue(isset(
$result[200][
'{DAV:}displayname']));
412 $this->assertEquals(
'user',
$result[200][
'{DAV:}displayname']);
This plugin provides Authentication for a WebDAV server.
The Request class represents a single HTTP request.
testCurrentUserPrincipal()
testSupportedPrivilegeSet()
This class represents a single HTTP response.
testPrincipalCollectionSet()