aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAVACL
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAVACL')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php331
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php139
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php190
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php39
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php49
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php39
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php39
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php39
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php358
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php56
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php66
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php83
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php407
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php127
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php178
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php184
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php45
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php42
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php52
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php246
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php135
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php204
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/Property/ACLRestrictionsTest.php35
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/Property/ACLTest.php335
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/Property/CurrentUserPrivilegeSetTest.php68
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/Property/PrincipalTest.php181
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/Property/SupportedPrivilegeSetTest.php106
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php322
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/VersionTest.php17
29 files changed, 4112 insertions, 0 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php
new file mode 100644
index 000000000..9960180a3
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php
@@ -0,0 +1,331 @@
+<?php
+
+namespace Sabre\DAVACL;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+class ACLMethodTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @expectedException Sabre\DAV\Exception\BadRequest
+ */
+ function testCallback() {
+
+ $acl = new Plugin();
+ $server = new DAV\Server();
+ $server->addPlugin($acl);
+
+ $acl->unknownMethod('ACL','test');
+
+ }
+
+ function testCallbackPassthru() {
+
+ $acl = new Plugin();
+ $server = new DAV\Server();
+ $server->addPlugin($acl);
+
+ $this->assertNull($acl->unknownMethod('FOO','test'));
+
+ }
+
+ /**
+
+ /**
+ * @expectedException Sabre\DAV\Exception\MethodNotAllowed
+ */
+ function testNotSupportedByNode() {
+
+ $tree = array(
+ new DAV\SimpleCollection('test'),
+ );
+ $acl = new Plugin();
+ $server = new DAV\Server($tree);
+ $server->httpRequest = new HTTP\Request();
+ $body = '<?xml version="1.0"?>
+<d:acl xmlns:d="DAV:">
+</d:acl>';
+ $server->httpRequest->setBody($body);
+ $server->addPlugin($acl);
+
+ $acl->httpACL('test');
+
+ }
+
+ function testSuccessSimple() {
+
+ $tree = array(
+ new MockACLNode('test',array()),
+ );
+ $acl = new Plugin();
+ $server = new DAV\Server($tree);
+ $server->httpRequest = new HTTP\Request();
+ $body = '<?xml version="1.0"?>
+<d:acl xmlns:d="DAV:">
+</d:acl>';
+ $server->httpRequest->setBody($body);
+ $server->addPlugin($acl);
+
+ $this->assertNull($acl->httpACL('test'));
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\NotRecognizedPrincipal
+ */
+ function testUnrecognizedPrincipal() {
+
+ $tree = array(
+ new MockACLNode('test',array()),
+ );
+ $acl = new Plugin();
+ $server = new DAV\Server($tree);
+ $server->httpRequest = new HTTP\Request();
+ $body = '<?xml version="1.0"?>
+<d:acl xmlns:d="DAV:">
+ <d:ace>
+ <d:grant><d:privilege><d:read /></d:privilege></d:grant>
+ <d:principal><d:href>/principals/notfound</d:href></d:principal>
+ </d:ace>
+</d:acl>';
+ $server->httpRequest->setBody($body);
+ $server->addPlugin($acl);
+
+ $acl->httpACL('test');
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\NotRecognizedPrincipal
+ */
+ function testUnrecognizedPrincipal2() {
+
+ $tree = array(
+ new MockACLNode('test',array()),
+ new DAV\SimpleCollection('principals',array(
+ new DAV\SimpleCollection('notaprincipal'),
+ )),
+ );
+ $acl = new Plugin();
+ $server = new DAV\Server($tree);
+ $server->httpRequest = new HTTP\Request();
+ $body = '<?xml version="1.0"?>
+<d:acl xmlns:d="DAV:">
+ <d:ace>
+ <d:grant><d:privilege><d:read /></d:privilege></d:grant>
+ <d:principal><d:href>/principals/notaprincipal</d:href></d:principal>
+ </d:ace>
+</d:acl>';
+ $server->httpRequest->setBody($body);
+ $server->addPlugin($acl);
+
+ $acl->httpACL('test');
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\NotSupportedPrivilege
+ */
+ function testUnknownPrivilege() {
+
+ $tree = array(
+ new MockACLNode('test',array()),
+ );
+ $acl = new Plugin();
+ $server = new DAV\Server($tree);
+ $server->httpRequest = new HTTP\Request();
+ $body = '<?xml version="1.0"?>
+<d:acl xmlns:d="DAV:">
+ <d:ace>
+ <d:grant><d:privilege><d:bananas /></d:privilege></d:grant>
+ <d:principal><d:href>/principals/notfound</d:href></d:principal>
+ </d:ace>
+</d:acl>';
+ $server->httpRequest->setBody($body);
+ $server->addPlugin($acl);
+
+ $acl->httpACL('test');
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\NoAbstract
+ */
+ function testAbstractPrivilege() {
+
+ $tree = array(
+ new MockACLNode('test',array()),
+ );
+ $acl = new Plugin();
+ $server = new DAV\Server($tree);
+ $server->httpRequest = new HTTP\Request();
+ $body = '<?xml version="1.0"?>
+<d:acl xmlns:d="DAV:">
+ <d:ace>
+ <d:grant><d:privilege><d:read-acl /></d:privilege></d:grant>
+ <d:principal><d:href>/principals/notfound</d:href></d:principal>
+ </d:ace>
+</d:acl>';
+ $server->httpRequest->setBody($body);
+ $server->addPlugin($acl);
+
+ $acl->httpACL('test');
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\AceConflict
+ */
+ function testUpdateProtectedPrivilege() {
+
+ $oldACL = array(
+ array(
+ 'principal' => 'principals/notfound',
+ 'privilege' => '{DAV:}write',
+ 'protected' => true,
+ ),
+ );
+
+ $tree = array(
+ new MockACLNode('test',$oldACL),
+ );
+ $acl = new Plugin();
+ $server = new DAV\Server($tree);
+ $server->httpRequest = new HTTP\Request();
+ $body = '<?xml version="1.0"?>
+<d:acl xmlns:d="DAV:">
+ <d:ace>
+ <d:grant><d:privilege><d:read /></d:privilege></d:grant>
+ <d:principal><d:href>/principals/notfound</d:href></d:principal>
+ </d:ace>
+</d:acl>';
+ $server->httpRequest->setBody($body);
+ $server->addPlugin($acl);
+
+ $acl->httpACL('test');
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\AceConflict
+ */
+ function testUpdateProtectedPrivilege2() {
+
+ $oldACL = array(
+ array(
+ 'principal' => 'principals/notfound',
+ 'privilege' => '{DAV:}write',
+ 'protected' => true,
+ ),
+ );
+
+ $tree = array(
+ new MockACLNode('test',$oldACL),
+ );
+ $acl = new Plugin();
+ $server = new DAV\Server($tree);
+ $server->httpRequest = new HTTP\Request();
+ $body = '<?xml version="1.0"?>
+<d:acl xmlns:d="DAV:">
+ <d:ace>
+ <d:grant><d:privilege><d:write /></d:privilege></d:grant>
+ <d:principal><d:href>/principals/foo</d:href></d:principal>
+ </d:ace>
+</d:acl>';
+ $server->httpRequest->setBody($body);
+ $server->addPlugin($acl);
+
+ $acl->httpACL('test');
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\AceConflict
+ */
+ function testUpdateProtectedPrivilege3() {
+
+ $oldACL = array(
+ array(
+ 'principal' => 'principals/notfound',
+ 'privilege' => '{DAV:}write',
+ 'protected' => true,
+ ),
+ );
+
+ $tree = array(
+ new MockACLNode('test',$oldACL),
+ );
+ $acl = new Plugin();
+ $server = new DAV\Server($tree);
+ $server->httpRequest = new HTTP\Request();
+ $body = '<?xml version="1.0"?>
+<d:acl xmlns:d="DAV:">
+ <d:ace>
+ <d:grant><d:privilege><d:write /></d:privilege></d:grant>
+ <d:principal><d:href>/principals/notfound</d:href></d:principal>
+ </d:ace>
+</d:acl>';
+ $server->httpRequest->setBody($body);
+ $server->addPlugin($acl);
+
+ $acl->httpACL('test');
+
+ }
+
+ function testSuccessComplex () {
+
+ $oldACL = array(
+ array(
+ 'principal' => 'principals/foo',
+ 'privilege' => '{DAV:}write',
+ 'protected' => true,
+ ),
+ array(
+ 'principal' => 'principals/bar',
+ 'privilege' => '{DAV:}read',
+ ),
+ );
+
+ $tree = array(
+ $node = new MockACLNode('test',$oldACL),
+ new DAV\SimpleCollection('principals', array(
+ new MockPrincipal('foo','principals/foo'),
+ new MockPrincipal('baz','principals/baz'),
+ )),
+ );
+ $acl = new Plugin();
+ $server = new DAV\Server($tree);
+ $server->httpRequest = new HTTP\Request();
+ $body = '<?xml version="1.0"?>
+<d:acl xmlns:d="DAV:">
+ <d:ace>
+ <d:grant><d:privilege><d:write /></d:privilege></d:grant>
+ <d:principal><d:href>/principals/foo</d:href></d:principal>
+ <d:protected />
+ </d:ace>
+ <d:ace>
+ <d:grant><d:privilege><d:write /></d:privilege></d:grant>
+ <d:principal><d:href>/principals/baz</d:href></d:principal>
+ </d:ace>
+</d:acl>';
+ $server->httpRequest->setBody($body);
+ $server->addPlugin($acl);
+
+ $this->assertFalse($acl->unknownMethod('ACL','test'));
+
+ $this->assertEquals(array(
+ array(
+ 'principal' => 'principals/foo',
+ 'privilege' => '{DAV:}write',
+ 'protected' => true,
+ ),
+ array(
+ 'principal' => 'principals/baz',
+ 'privilege' => '{DAV:}write',
+ 'protected' => false,
+ ),
+ ), $node->getACL());
+
+ }
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php
new file mode 100644
index 000000000..3a9b35b45
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php
@@ -0,0 +1,139 @@
+<?php
+
+namespace Sabre\DAVACL;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+class AllowAccessTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @var DAV\Server
+ */
+ protected $server;
+
+ function setUp() {
+
+ $nodes = array(
+ new DAV\SimpleCollection('testdir'),
+ );
+
+ $this->server = new DAV\Server($nodes);
+ $aclPlugin = new Plugin();
+ $aclPlugin->allowAccessToNodesWithoutACL = true;
+ $this->server->addPlugin($aclPlugin);
+
+ }
+
+ function testGet() {
+
+ $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('GET','testdir')));
+
+ }
+
+ function testGetDoesntExist() {
+
+ $r = $this->server->broadcastEvent('beforeMethod',array('GET','foo'));
+ $this->assertTrue($r);
+
+ }
+
+ function testHEAD() {
+
+ $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('HEAD','testdir')));
+
+ }
+
+ function testOPTIONS() {
+
+ $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('OPTIONS','testdir')));
+
+ }
+
+ function testPUT() {
+
+ $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('PUT','testdir')));
+
+ }
+
+ function testACL() {
+
+ $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('ACL','testdir')));
+
+ }
+
+ function testPROPPATCH() {
+
+ $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('PROPPATCH','testdir')));
+
+ }
+
+ function testCOPY() {
+
+ $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('COPY','testdir')));
+
+ }
+
+ function testMOVE() {
+
+ $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('MOVE','testdir')));
+
+ }
+
+ function testLOCK() {
+
+ $this->assertTrue($this->server->broadcastEvent('beforeMethod',array('LOCK','testdir')));
+
+ }
+
+ function testBeforeBind() {
+
+ $this->assertTrue($this->server->broadcastEvent('beforeBind',array('testdir/file')));
+
+ }
+
+
+ function testBeforeUnbind() {
+
+ $this->assertTrue($this->server->broadcastEvent('beforeUnbind',array('testdir')));
+
+ }
+
+ function testAfterGetProperties() {
+
+ $properties = array(
+ 'href' => 'foo',
+ '200' => array(
+ '{DAV:}displayname' => 'foo',
+ '{DAV:}getcontentlength' => 500,
+ ),
+ '404' => array(
+ '{DAV:}bar' => null,
+ ),
+ '403' => array(
+ '{DAV:}owner' => null,
+ ),
+ );
+
+ $expected = array(
+ 'href' => 'foo',
+ '200' => array(
+ '{DAV:}displayname' => 'foo',
+ '{DAV:}getcontentlength' => 500,
+ ),
+ '404' => array(
+ '{DAV:}bar' => null,
+ ),
+ '403' => array(
+ '{DAV:}owner' => null,
+ ),
+ );
+
+ $r = $this->server->broadcastEvent('afterGetProperties',array('testdir',&$properties));
+ $this->assertTrue($r);
+
+ $this->assertEquals($expected, $properties);
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php
new file mode 100644
index 000000000..345d2cc5d
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php
@@ -0,0 +1,190 @@
+<?php
+
+namespace Sabre\DAVACL;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+class BlockAccessTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @var DAV\Server
+ */
+ protected $server;
+ protected $plugin;
+
+ function setUp() {
+
+ $nodes = array(
+ new DAV\SimpleCollection('testdir'),
+ );
+
+ $this->server = new DAV\Server($nodes);
+ $this->plugin = new Plugin();
+ $this->plugin->allowAccessToNodesWithoutACL = false;
+ $this->server->addPlugin($this->plugin);
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\NeedPrivileges
+ */
+ function testGet() {
+
+ $this->server->broadcastEvent('beforeMethod',array('GET','testdir'));
+
+ }
+
+ function testGetDoesntExist() {
+
+ $r = $this->server->broadcastEvent('beforeMethod',array('GET','foo'));
+ $this->assertTrue($r);
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\NeedPrivileges
+ */
+ function testHEAD() {
+
+ $this->server->broadcastEvent('beforeMethod',array('HEAD','testdir'));
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\NeedPrivileges
+ */
+ function testOPTIONS() {
+
+ $this->server->broadcastEvent('beforeMethod',array('OPTIONS','testdir'));
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\NeedPrivileges
+ */
+ function testPUT() {
+
+ $this->server->broadcastEvent('beforeMethod',array('PUT','testdir'));
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\NeedPrivileges
+ */
+ function testPROPPATCH() {
+
+ $this->server->broadcastEvent('beforeMethod',array('PROPPATCH','testdir'));
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\NeedPrivileges
+ */
+ function testCOPY() {
+
+ $this->server->broadcastEvent('beforeMethod',array('COPY','testdir'));
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\NeedPrivileges
+ */
+ function testMOVE() {
+
+ $this->server->broadcastEvent('beforeMethod',array('MOVE','testdir'));
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\NeedPrivileges
+ */
+ function testACL() {
+
+ $this->server->broadcastEvent('beforeMethod',array('ACL','testdir'));
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\NeedPrivileges
+ */
+ function testLOCK() {
+
+ $this->server->broadcastEvent('beforeMethod',array('LOCK','testdir'));
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\NeedPrivileges
+ */
+ function testBeforeBind() {
+
+ $this->server->broadcastEvent('beforeBind',array('testdir/file'));
+
+ }
+
+ /**
+ * @expectedException Sabre\DAVACL\Exception\NeedPrivileges
+ */
+ function testBeforeUnbind() {
+
+ $this->server->broadcastEvent('beforeUnbind',array('testdir'));
+
+ }
+
+ function testBeforeGetProperties() {
+
+ $requestedProperties = array(
+ '{DAV:}displayname',
+ '{DAV:}getcontentlength',
+ '{DAV:}bar',
+ '{DAV:}owner',
+ );
+ $returnedProperties = array();
+
+ $arguments = array(
+ 'testdir',
+ new DAV\SimpleCollection('testdir'),
+ &$requestedProperties,
+ &$returnedProperties
+ );
+ $r = $this->server->broadcastEvent('beforeGetProperties',$arguments);
+ $this->assertTrue($r);
+
+ $expected = array(
+ '403' => array(
+ '{DAV:}displayname' => null,
+ '{DAV:}getcontentlength' => null,
+ '{DAV:}bar' => null,
+ '{DAV:}owner' => null,
+ ),
+ );
+
+ $this->assertEquals($expected, $returnedProperties);
+ $this->assertEquals(array(), $requestedProperties);
+
+ }
+
+ function testBeforeGetPropertiesNoListing() {
+
+ $this->plugin->hideNodesFromListings = true;
+
+ $requestedProperties = array(
+ '{DAV:}displayname',
+ '{DAV:}getcontentlength',
+ '{DAV:}bar',
+ '{DAV:}owner',
+ );
+ $returnedProperties = array();
+
+ $arguments = array(
+ 'testdir',
+ new DAV\SimpleCollection('testdir'),
+ &$requestedProperties,
+ &$returnedProperties
+ );
+ $r = $this->server->broadcastEvent('beforeGetProperties',$arguments);
+ $this->assertFalse($r);
+
+ }
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php
new file mode 100644
index 000000000..fc48af67f
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace Sabre\DAVACL\Exception;
+
+use Sabre\DAV;
+
+class AceConflictTest extends \PHPUnit_Framework_TestCase {
+
+ function testSerialize() {
+
+ $ex = new AceConflict('message');
+
+ $server = new DAV\Server();
+ $dom = new \DOMDocument('1.0','utf-8');
+ $root = $dom->createElementNS('DAV:','d:root');
+ $dom->appendChild($root);
+
+ $ex->serialize($server, $root);
+
+ $xpaths = array(
+ '/d:root' => 1,
+ '/d:root/d:no-ace-conflict' => 1,
+ );
+
+ // Reloading because PHP DOM sucks
+ $dom2 = new \DOMDocument('1.0', 'utf-8');
+ $dom2->loadXML($dom->saveXML());
+
+ $dxpath = new \DOMXPath($dom2);
+ $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);
+
+ }
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php
new file mode 100644
index 000000000..7e66adab6
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace Sabre\DAVACL\Exception;
+
+use Sabre\DAV;
+
+class NeedPrivilegesTest extends \PHPUnit_Framework_TestCase {
+
+ function testSerialize() {
+
+ $uri = 'foo';
+ $privileges = array(
+ '{DAV:}read',
+ '{DAV:}write',
+ );
+ $ex = new NeedPrivileges($uri, $privileges);
+
+ $server = new DAV\Server();
+ $dom = new \DOMDocument('1.0','utf-8');
+ $root = $dom->createElementNS('DAV:','d:root');
+ $dom->appendChild($root);
+
+ $ex->serialize($server, $root);
+
+ $xpaths = array(
+ '/d:root' => 1,
+ '/d:root/d:need-privileges' => 1,
+ '/d:root/d:need-privileges/d:resource' => 2,
+ '/d:root/d:need-privileges/d:resource/d:href' => 2,
+ '/d:root/d:need-privileges/d:resource/d:privilege' => 2,
+ '/d:root/d:need-privileges/d:resource/d:privilege/d:read' => 1,
+ '/d:root/d:need-privileges/d:resource/d:privilege/d:write' => 1,
+ );
+
+ // Reloading because PHP DOM sucks
+ $dom2 = new \DOMDocument('1.0', 'utf-8');
+ $dom2->loadXML($dom->saveXML());
+
+ $dxpath = new \DOMXPath($dom2);
+ $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);
+
+ }
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php
new file mode 100644
index 000000000..2406c1c38
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace Sabre\DAVACL\Exception;
+
+use Sabre\DAV;
+
+class NoAbstractTest extends \PHPUnit_Framework_TestCase {
+
+ function testSerialize() {
+
+ $ex = new NoAbstract('message');
+
+ $server = new DAV\Server();
+ $dom = new \DOMDocument('1.0','utf-8');
+ $root = $dom->createElementNS('DAV:','d:root');
+ $dom->appendChild($root);
+
+ $ex->serialize($server, $root);
+
+ $xpaths = array(
+ '/d:root' => 1,
+ '/d:root/d:no-abstract' => 1,
+ );
+
+ // Reloading because PHP DOM sucks
+ $dom2 = new \DOMDocument('1.0', 'utf-8');
+ $dom2->loadXML($dom->saveXML());
+
+ $dxpath = new \DOMXPath($dom2);
+ $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);
+
+ }
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php
new file mode 100644
index 000000000..6077b0ba5
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace Sabre\DAVACL\Exception;
+
+use Sabre\DAV;
+
+class NotRecognizedPrincipalTest extends \PHPUnit_Framework_TestCase {
+
+ function testSerialize() {
+
+ $ex = new NotRecognizedPrincipal('message');
+
+ $server = new DAV\Server();
+ $dom = new \DOMDocument('1.0','utf-8');
+ $root = $dom->createElementNS('DAV:','d:root');
+ $dom->appendChild($root);
+
+ $ex->serialize($server, $root);
+
+ $xpaths = array(
+ '/d:root' => 1,
+ '/d:root/d:recognized-principal' => 1,
+ );
+
+ // Reloading because PHP DOM sucks
+ $dom2 = new \DOMDocument('1.0', 'utf-8');
+ $dom2->loadXML($dom->saveXML());
+
+ $dxpath = new \DOMXPath($dom2);
+ $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);
+
+ }
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php
new file mode 100644
index 000000000..8e7b3685d
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace Sabre\DAVACL\Exception;
+
+use Sabre\DAV;
+
+class NotSupportedPrivilegeTest extends \PHPUnit_Framework_TestCase {
+
+ function testSerialize() {
+
+ $ex = new NotSupportedPrivilege('message');
+
+ $server = new DAV\Server();
+ $dom = new \DOMDocument('1.0','utf-8');
+ $root = $dom->createElementNS('DAV:','d:root');
+ $dom->appendChild($root);
+
+ $ex->serialize($server, $root);
+
+ $xpaths = array(
+ '/d:root' => 1,
+ '/d:root/d:not-supported-privilege' => 1,
+ );
+
+ // Reloading because PHP DOM sucks
+ $dom2 = new \DOMDocument('1.0', 'utf-8');
+ $dom2->loadXML($dom->saveXML());
+
+ $dxpath = new \DOMXPath($dom2);
+ $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);
+
+ }
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php
new file mode 100644
index 000000000..324788d4a
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php
@@ -0,0 +1,358 @@
+<?php
+
+namespace Sabre\DAVACL;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+require_once 'Sabre/HTTP/ResponseMock.php';
+
+class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase {
+
+ function getServer() {
+
+ $tree = array(
+ new MockPropertyNode('node1', array(
+ '{http://sabredav.org/ns}simple' => 'foo',
+ '{http://sabredav.org/ns}href' => new DAV\Property\Href('node2'),
+ '{DAV:}displayname' => 'Node 1',
+ )),
+ new MockPropertyNode('node2', array(
+ '{http://sabredav.org/ns}simple' => 'simple',
+ '{http://sabredav.org/ns}hreflist' => new DAV\Property\HrefList(array('node1','node3')),
+ '{DAV:}displayname' => 'Node 2',
+ )),
+ new MockPropertyNode('node3', array(
+ '{http://sabredav.org/ns}simple' => 'simple',
+ '{DAV:}displayname' => 'Node 3',
+ )),
+ );
+
+ $fakeServer = new DAV\Server($tree);
+ $fakeServer->debugExceptions = true;
+ $fakeServer->httpResponse = new HTTP\ResponseMock();
+ $plugin = new Plugin();
+ $plugin->allowAccessToNodesWithoutACL = true;
+
+ $this->assertTrue($plugin instanceof Plugin);
+ $fakeServer->addPlugin($plugin);
+ $this->assertEquals($plugin, $fakeServer->getPlugin('acl'));
+
+ return $fakeServer;
+
+ }
+
+ function testSimple() {
+
+ $xml = '<?xml version="1.0"?>
+<d:expand-property xmlns:d="DAV:">
+ <d:property name="displayname" />
+ <d:property name="foo" namespace="http://www.sabredav.org/NS/2010/nonexistant" />
+ <d:property name="simple" namespace="http://sabredav.org/ns" />
+ <d:property name="href" namespace="http://sabredav.org/ns" />
+</d:expand-property>';
+
+ $serverVars = array(
+ 'REQUEST_METHOD' => 'REPORT',
+ 'HTTP_DEPTH' => '0',
+ 'REQUEST_URI' => '/node1',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody($xml);
+
+ $server = $this->getServer();
+ $server->httpRequest = $request;
+
+ $server->exec();
+
+ $this->assertEquals('HTTP/1.1 207 Multi-Status', $server->httpResponse->status,'Incorrect status code received. Full body: ' . $server->httpResponse->body);
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ), $server->httpResponse->headers);
+
+
+ $check = array(
+ '/d:multistatus',
+ '/d:multistatus/d:response' => 1,
+ '/d:multistatus/d:response/d:href' => 1,
+ '/d:multistatus/d:response/d:propstat' => 2,
+ '/d:multistatus/d:response/d:propstat/d:prop' => 2,
+ '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:simple' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:href' => 1,
+ );
+
+ $xml = simplexml_load_string($server->httpResponse->body);
+ $xml->registerXPathNamespace('d','DAV:');
+ $xml->registerXPathNamespace('s','http://sabredav.org/ns');
+ foreach($check as $v1=>$v2) {
+
+ $xpath = is_int($v1)?$v2:$v1;
+
+ $result = $xml->xpath($xpath);
+
+ $count = 1;
+ if (!is_int($v1)) $count = $v2;
+
+ $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response: ' . $server->httpResponse->body);
+
+ }
+
+ }
+
+ /**
+ * @depends testSimple
+ */
+ function testExpand() {
+
+ $xml = '<?xml version="1.0"?>
+<d:expand-property xmlns:d="DAV:">
+ <d:property name="href" namespace="http://sabredav.org/ns">
+ <d:property name="displayname" />
+ </d:property>
+</d:expand-property>';
+
+ $serverVars = array(
+ 'REQUEST_METHOD' => 'REPORT',
+ 'HTTP_DEPTH' => '0',
+ 'REQUEST_URI' => '/node1',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody($xml);
+
+ $server = $this->getServer();
+ $server->httpRequest = $request;
+
+ $server->exec();
+
+ $this->assertEquals('HTTP/1.1 207 Multi-Status', $server->httpResponse->status, 'Incorrect response status received. Full response body: ' . $server->httpResponse->body);
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ), $server->httpResponse->headers);
+
+
+ $check = array(
+ '/d:multistatus',
+ '/d:multistatus/d:response' => 1,
+ '/d:multistatus/d:response/d:href' => 1,
+ '/d:multistatus/d:response/d:propstat' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop/d:displayname' => 1,
+ );
+
+ $xml = simplexml_load_string($server->httpResponse->body);
+ $xml->registerXPathNamespace('d','DAV:');
+ $xml->registerXPathNamespace('s','http://sabredav.org/ns');
+ foreach($check as $v1=>$v2) {
+
+ $xpath = is_int($v1)?$v2:$v1;
+
+ $result = $xml->xpath($xpath);
+
+ $count = 1;
+ if (!is_int($v1)) $count = $v2;
+
+ $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result));
+
+ }
+
+ }
+
+ /**
+ * @depends testSimple
+ */
+ function testExpandHrefList() {
+
+ $xml = '<?xml version="1.0"?>
+<d:expand-property xmlns:d="DAV:">
+ <d:property name="hreflist" namespace="http://sabredav.org/ns">
+ <d:property name="displayname" />
+ </d:property>
+</d:expand-property>';
+
+ $serverVars = array(
+ 'REQUEST_METHOD' => 'REPORT',
+ 'HTTP_DEPTH' => '0',
+ 'REQUEST_URI' => '/node2',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody($xml);
+
+ $server = $this->getServer();
+ $server->httpRequest = $request;
+
+ $server->exec();
+
+ $this->assertEquals('HTTP/1.1 207 Multi-Status', $server->httpResponse->status);
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ), $server->httpResponse->headers);
+
+
+ $check = array(
+ '/d:multistatus',
+ '/d:multistatus/d:response' => 1,
+ '/d:multistatus/d:response/d:href' => 1,
+ '/d:multistatus/d:response/d:propstat' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 2,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 2,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2,
+ );
+
+ $xml = simplexml_load_string($server->httpResponse->body);
+ $xml->registerXPathNamespace('d','DAV:');
+ $xml->registerXPathNamespace('s','http://sabredav.org/ns');
+ foreach($check as $v1=>$v2) {
+
+ $xpath = is_int($v1)?$v2:$v1;
+
+ $result = $xml->xpath($xpath);
+
+ $count = 1;
+ if (!is_int($v1)) $count = $v2;
+
+ $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result));
+
+ }
+
+ }
+
+ /**
+ * @depends testExpand
+ */
+ function testExpandDeep() {
+
+ $xml = '<?xml version="1.0"?>
+<d:expand-property xmlns:d="DAV:">
+ <d:property name="hreflist" namespace="http://sabredav.org/ns">
+ <d:property name="href" namespace="http://sabredav.org/ns">
+ <d:property name="displayname" />
+ </d:property>
+ <d:property name="displayname" />
+ </d:property>
+</d:expand-property>';
+
+ $serverVars = array(
+ 'REQUEST_METHOD' => 'REPORT',
+ 'HTTP_DEPTH' => '0',
+ 'REQUEST_URI' => '/node2',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody($xml);
+
+ $server = $this->getServer();
+ $server->httpRequest = $request;
+
+ $server->exec();
+
+ $this->assertEquals('HTTP/1.1 207 Multi-Status', $server->httpResponse->status);
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ), $server->httpResponse->headers);
+
+
+ $check = array(
+ '/d:multistatus',
+ '/d:multistatus/d:response' => 1,
+ '/d:multistatus/d:response/d:href' => 1,
+ '/d:multistatus/d:response/d:propstat' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 3,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 3,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href' => 2,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1,
+ '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop/d:displayname' => 1,
+ );
+
+ $xml = simplexml_load_string($server->httpResponse->body);
+ $xml->registerXPathNamespace('d','DAV:');
+ $xml->registerXPathNamespace('s','http://sabredav.org/ns');
+ foreach($check as $v1=>$v2) {
+
+ $xpath = is_int($v1)?$v2:$v1;
+
+ $result = $xml->xpath($xpath);
+
+ $count = 1;
+ if (!is_int($v1)) $count = $v2;
+
+ $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result));
+
+ }
+
+ }
+}
+class MockPropertyNode implements DAV\INode, DAV\IProperties {
+
+ function __construct($name, array $properties) {
+
+ $this->name = $name;
+ $this->properties = $properties;
+
+ }
+
+ function getName() {
+
+ return $this->name;
+
+ }
+
+ function getProperties($requestedProperties) {
+
+ $returnedProperties = array();
+ foreach($requestedProperties as $requestedProperty) {
+ if (isset($this->properties[$requestedProperty])) {
+ $returnedProperties[$requestedProperty] =
+ $this->properties[$requestedProperty];
+ }
+ }
+ return $returnedProperties;
+
+ }
+
+ function delete() {
+
+ throw new DAV\Exception('Not implemented');
+
+ }
+
+ function setName($name) {
+
+ throw new DAV\Exception('Not implemented');
+
+ }
+
+ function getLastModified() {
+
+ return null;
+
+ }
+
+ function updateProperties($properties) {
+
+ throw new DAV\Exception('Not implemented');
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php b/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php
new file mode 100644
index 000000000..7b3e8fc12
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php
@@ -0,0 +1,56 @@
+<?php
+
+namespace Sabre\DAVACL;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+class MockACLNode extends DAV\Node implements IACL {
+
+ public $name;
+ public $acl;
+
+ function __construct($name, array $acl = array()) {
+
+ $this->name = $name;
+ $this->acl = $acl;
+
+ }
+
+ function getName() {
+
+ return $this->name;
+
+ }
+
+ function getOwner() {
+
+ return null;
+
+ }
+
+ function getGroup() {
+
+ return null;
+
+ }
+
+ function getACL() {
+
+ return $this->acl;
+
+ }
+
+ function setACL(array $acl) {
+
+ $this->acl = $acl;
+
+ }
+
+ function getSupportedPrivilegeSet() {
+
+ return null;
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php b/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php
new file mode 100644
index 000000000..dd8542b8d
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php
@@ -0,0 +1,66 @@
+<?php
+
+namespace Sabre\DAVACL;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+class MockPrincipal extends DAV\Node implements IPrincipal {
+
+ public $name;
+ public $principalUrl;
+ public $groupMembership = array();
+ public $groupMemberSet = array();
+
+ function __construct($name,$principalUrl,array $groupMembership = array(), array $groupMemberSet = array()) {
+
+ $this->name = $name;
+ $this->principalUrl = $principalUrl;
+ $this->groupMembership = $groupMembership;
+ $this->groupMemberSet = $groupMemberSet;
+
+ }
+
+ function getName() {
+
+ return $this->name;
+
+ }
+
+ function getDisplayName() {
+
+ return $this->getName();
+
+ }
+
+ function getAlternateUriSet() {
+
+ return array();
+
+ }
+
+ function getPrincipalUrl() {
+
+ return $this->principalUrl;
+
+ }
+
+ function getGroupMemberSet() {
+
+ return $this->groupMemberSet;
+
+ }
+
+ function getGroupMemberShip() {
+
+ return $this->groupMembership;
+
+ }
+
+ function setGroupMemberSet(array $groupMemberSet) {
+
+ $this->groupMemberSet = $groupMemberSet;
+
+ }
+}
+
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php
new file mode 100644
index 000000000..23c4b6e85
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php
@@ -0,0 +1,83 @@
+<?php
+
+namespace Sabre\DAVACL;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+
+require_once 'Sabre/DAVACL/MockACLNode.php';
+require_once 'Sabre/HTTP/ResponseMock.php';
+
+class PluginAdminTest extends \PHPUnit_Framework_TestCase {
+
+ function testNoAdminAccess() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+
+ $tree = array(
+ new MockACLNode('adminonly', array()),
+ new PrincipalCollection($principalBackend),
+ );
+
+ $fakeServer = new DAV\Server($tree);
+ $plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'realm');
+ $fakeServer->addPlugin($plugin);
+ $plugin = new Plugin();
+ $fakeServer->addPlugin($plugin);
+
+ $request = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'OPTIONS',
+ 'HTTP_DEPTH' => 1,
+ 'REQUEST_URI' => '/adminonly',
+ ));
+
+ $response = new HTTP\ResponseMock();
+
+ $fakeServer->httpRequest = $request;
+ $fakeServer->httpResponse = $response;
+
+ $fakeServer->exec();
+
+ $this->assertEquals('HTTP/1.1 403 Forbidden', $response->status);
+
+ }
+
+ /**
+ * @depends testNoAdminAccess
+ */
+ function testAdminAccess() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+
+ $tree = array(
+ new MockACLNode('adminonly', array()),
+ new PrincipalCollection($principalBackend),
+ );
+
+ $fakeServer = new DAV\Server($tree);
+ $plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'realm');
+ $fakeServer->addPlugin($plugin);
+ $plugin = new Plugin();
+ $plugin->adminPrincipals = array(
+ 'principals/admin',
+ );
+ $fakeServer->addPlugin($plugin);
+
+ $request = new HTTP\Request(array(
+ 'REQUEST_METHOD' => 'OPTIONS',
+ 'HTTP_DEPTH' => 1,
+ 'REQUEST_URI' => '/adminonly',
+ ));
+
+ $response = new HTTP\ResponseMock();
+
+ $fakeServer->httpRequest = $request;
+ $fakeServer->httpResponse = $response;
+
+ $fakeServer->exec();
+
+ $this->assertEquals('HTTP/1.1 200 OK', $response->status);
+
+ }
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php
new file mode 100644
index 000000000..8c0626e50
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php
@@ -0,0 +1,407 @@
+<?php
+
+namespace Sabre\DAVACL;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+
+class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
+
+ function testPrincipalCollectionSet() {
+
+ $plugin = new Plugin();
+ $plugin->principalCollectionSet = array(
+ 'principals1',
+ 'principals2',
+ );
+
+ $requestedProperties = array(
+ '{DAV:}principal-collection-set',
+ );
+
+ $returnedProperties = array(
+ 200 => array(),
+ 404 => array(),
+ );
+
+ $server = new DAV\Server();
+ $server->addPlugin($plugin);
+
+ $this->assertNull($plugin->beforeGetProperties('', new DAV\SimpleCollection('root'), $requestedProperties, $returnedProperties));
+
+ $this->assertEquals(1,count($returnedProperties[200]));
+ $this->assertArrayHasKey('{DAV:}principal-collection-set',$returnedProperties[200]);
+ $this->assertInstanceOf('Sabre\\DAV\\Property\\HrefList', $returnedProperties[200]['{DAV:}principal-collection-set']);
+
+ $expected = array(
+ 'principals1/',
+ 'principals2/',
+ );
+
+
+ $this->assertEquals($expected, $returnedProperties[200]['{DAV:}principal-collection-set']->getHrefs());
+
+
+ }
+
+ function testCurrentUserPrincipal() {
+
+ $fakeServer = new DAV\Server();
+ $plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'realm');
+ $fakeServer->addPlugin($plugin);
+ $plugin = new Plugin();
+ $fakeServer->addPlugin($plugin);
+
+
+ $requestedProperties = array(
+ '{DAV:}current-user-principal',
+ );
+
+ $returnedProperties = array(
+ 200 => array(),
+ 404 => array(),
+ );
+
+ $this->assertNull($plugin->beforeGetProperties('', new DAV\SimpleCollection('root'), $requestedProperties, $returnedProperties));
+
+ $this->assertEquals(1,count($returnedProperties[200]));
+ $this->assertArrayHasKey('{DAV:}current-user-principal',$returnedProperties[200]);
+ $this->assertInstanceOf('Sabre\DAVACL\Property\Principal', $returnedProperties[200]['{DAV:}current-user-principal']);
+ $this->assertEquals(Property\Principal::UNAUTHENTICATED, $returnedProperties[200]['{DAV:}current-user-principal']->getType());
+
+ // This will force the login
+ $fakeServer->broadCastEvent('beforeMethod',array('GET',''));
+
+
+ $requestedProperties = array(
+ '{DAV:}current-user-principal',
+ );
+
+ $returnedProperties = array(
+ 200 => array(),
+ 404 => array(),
+ );
+
+
+ $this->assertNull($plugin->beforeGetProperties('', new DAV\SimpleCollection('root'), $requestedProperties, $returnedProperties));
+
+
+ $this->assertEquals(1,count($returnedProperties[200]));
+ $this->assertArrayHasKey('{DAV:}current-user-principal',$returnedProperties[200]);
+ $this->assertInstanceOf('Sabre\DAVACL\Property\Principal', $returnedProperties[200]['{DAV:}current-user-principal']);
+ $this->assertEquals(Property\Principal::HREF, $returnedProperties[200]['{DAV:}current-user-principal']->getType());
+ $this->assertEquals('principals/admin/', $returnedProperties[200]['{DAV:}current-user-principal']->getHref());
+
+ }
+
+ function testSupportedPrivilegeSet() {
+
+ $plugin = new Plugin();
+ $server = new DAV\Server();
+ $server->addPlugin($plugin);
+
+ $requestedProperties = array(
+ '{DAV:}supported-privilege-set',
+ );
+
+ $returnedProperties = array(
+ 200 => array(),
+ 404 => array(),
+ );
+
+
+ $this->assertNull($plugin->beforeGetProperties('', new DAV\SimpleCollection('root'), $requestedProperties, $returnedProperties));
+
+ $this->assertEquals(1,count($returnedProperties[200]));
+ $this->assertArrayHasKey('{DAV:}supported-privilege-set',$returnedProperties[200]);
+ $this->assertInstanceOf('Sabre\\DAVACL\\Property\\SupportedPrivilegeSet', $returnedProperties[200]['{DAV:}supported-privilege-set']);
+
+ $server = new DAV\Server();
+ $prop = $returnedProperties[200]['{DAV:}supported-privilege-set'];
+
+ $dom = new \DOMDocument('1.0', 'utf-8');
+ $root = $dom->createElement('d:root');
+ $root->setAttribute('xmlns:d','DAV:');
+ $dom->appendChild($root);
+ $prop->serialize($server, $root);
+
+
+ $xpaths = array(
+ '/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/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' => 8,
+ );
+
+
+ // reloading because php dom sucks
+ $dom2 = new \DOMDocument('1.0', 'utf-8');
+ $dom2->loadXML($dom->saveXML());
+
+ $dxpath = new \DOMXPath($dom2);
+ $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);
+
+ }
+
+ }
+
+ function testACL() {
+
+ $plugin = new Plugin();
+
+ $nodes = array(
+ new MockACLNode('foo', array(
+ array(
+ 'principal' => 'principals/admin',
+ 'privilege' => '{DAV:}read',
+ )
+ )),
+ new DAV\SimpleCollection('principals', array(
+ $principal = new MockPrincipal('admin','principals/admin'),
+ )),
+
+ );
+
+ $server = new DAV\Server($nodes);
+ $server->addPlugin($plugin);
+ $authPlugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'realm');
+ $server->addPlugin($authPlugin);
+
+ // Force login
+ $authPlugin->beforeMethod('BLA','foo');
+
+ $requestedProperties = array(
+ '{DAV:}acl',
+ );
+
+ $returnedProperties = array(
+ 200 => array(),
+ 404 => array(),
+ );
+
+
+ $this->assertNull($plugin->beforeGetProperties('foo', $nodes[0], $requestedProperties, $returnedProperties));
+
+ $this->assertEquals(1,count($returnedProperties[200]),'The {DAV:}acl property did not return from the list. Full list: ' . print_r($returnedProperties,true));
+ $this->assertArrayHasKey('{DAV:}acl',$returnedProperties[200]);
+ $this->assertInstanceOf('Sabre\\DAVACL\\Property\\ACL', $returnedProperties[200]['{DAV:}acl']);
+
+ }
+
+ function testACLRestrictions() {
+
+ $plugin = new Plugin();
+
+ $nodes = array(
+ new MockACLNode('foo', array(
+ array(
+ 'principal' => 'principals/admin',
+ 'privilege' => '{DAV:}read',
+ )
+ )),
+ new DAV\SimpleCollection('principals', array(
+ $principal = new MockPrincipal('admin','principals/admin'),
+ )),
+
+ );
+
+ $server = new DAV\Server($nodes);
+ $server->addPlugin($plugin);
+ $authPlugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'realm');
+ $server->addPlugin($authPlugin);
+
+ // Force login
+ $authPlugin->beforeMethod('BLA','foo');
+
+ $requestedProperties = array(
+ '{DAV:}acl-restrictions',
+ );
+
+ $returnedProperties = array(
+ 200 => array(),
+ 404 => array(),
+ );
+
+
+ $this->assertNull($plugin->beforeGetProperties('foo', $nodes[0], $requestedProperties, $returnedProperties));
+
+ $this->assertEquals(1,count($returnedProperties[200]),'The {DAV:}acl-restrictions property did not return from the list. Full list: ' . print_r($returnedProperties,true));
+ $this->assertArrayHasKey('{DAV:}acl-restrictions',$returnedProperties[200]);
+ $this->assertInstanceOf('Sabre\\DAVACL\\Property\\ACLRestrictions', $returnedProperties[200]['{DAV:}acl-restrictions']);
+
+ }
+
+ function testAlternateUriSet() {
+
+ $tree = array(
+ new DAV\SimpleCollection('principals', array(
+ $principal = new MockPrincipal('user','principals/user'),
+ )),
+ );
+
+ $fakeServer = new DAV\Server($tree);
+ //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend(),'realm');
+ //$fakeServer->addPlugin($plugin);
+ $plugin = new Plugin();
+ $fakeServer->addPlugin($plugin);
+
+ $requestedProperties = array(
+ '{DAV:}alternate-URI-set',
+ );
+ $returnedProperties = array();
+
+ $result = $plugin->beforeGetProperties('principals/user',$principal,$requestedProperties,$returnedProperties);
+
+ $this->assertNull($result);
+
+ $this->assertTrue(isset($returnedProperties[200]));
+ $this->assertTrue(isset($returnedProperties[200]['{DAV:}alternate-URI-set']));
+ $this->assertInstanceOf('Sabre\\DAV\\Property\\HrefList', $returnedProperties[200]['{DAV:}alternate-URI-set']);
+
+ $this->assertEquals(array(), $returnedProperties[200]['{DAV:}alternate-URI-set']->getHrefs());
+
+ }
+
+ function testPrincipalURL() {
+
+ $tree = array(
+ new DAV\SimpleCollection('principals', array(
+ $principal = new MockPrincipal('user','principals/user'),
+ )),
+ );
+
+ $fakeServer = new DAV\Server($tree);
+ //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend(),'realm');
+ //$fakeServer->addPlugin($plugin);
+ $plugin = new Plugin();
+ $fakeServer->addPlugin($plugin);
+
+ $requestedProperties = array(
+ '{DAV:}principal-URL',
+ );
+ $returnedProperties = array();
+
+ $result = $plugin->beforeGetProperties('principals/user',$principal,$requestedProperties,$returnedProperties);
+
+ $this->assertNull($result);
+
+ $this->assertTrue(isset($returnedProperties[200]));
+ $this->assertTrue(isset($returnedProperties[200]['{DAV:}principal-URL']));
+ $this->assertInstanceOf('Sabre\\DAV\\Property\\Href', $returnedProperties[200]['{DAV:}principal-URL']);
+
+ $this->assertEquals('principals/user/', $returnedProperties[200]['{DAV:}principal-URL']->getHref());
+
+ }
+
+ function testGroupMemberSet() {
+
+ $tree = array(
+ new DAV\SimpleCollection('principals', array(
+ $principal = new MockPrincipal('user','principals/user'),
+ )),
+ );
+
+ $fakeServer = new DAV\Server($tree);
+ //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend(),'realm');
+ //$fakeServer->addPlugin($plugin);
+ $plugin = new Plugin();
+ $fakeServer->addPlugin($plugin);
+
+ $requestedProperties = array(
+ '{DAV:}group-member-set',
+ );
+ $returnedProperties = array();
+
+ $result = $plugin->beforeGetProperties('principals/user',$principal,$requestedProperties,$returnedProperties);
+
+ $this->assertNull($result);
+
+ $this->assertTrue(isset($returnedProperties[200]));
+ $this->assertTrue(isset($returnedProperties[200]['{DAV:}group-member-set']));
+ $this->assertInstanceOf('Sabre\\DAV\\Property\\HrefList', $returnedProperties[200]['{DAV:}group-member-set']);
+
+ $this->assertEquals(array(), $returnedProperties[200]['{DAV:}group-member-set']->getHrefs());
+
+ }
+
+ function testGroupMemberShip() {
+
+ $tree = array(
+ new DAV\SimpleCollection('principals', array(
+ $principal = new MockPrincipal('user','principals/user'),
+ )),
+ );
+
+ $fakeServer = new DAV\Server($tree);
+ //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend(),'realm');
+ //$fakeServer->addPlugin($plugin);
+ $plugin = new Plugin();
+ $fakeServer->addPlugin($plugin);
+
+ $requestedProperties = array(
+ '{DAV:}group-membership',
+ );
+ $returnedProperties = array();
+
+ $result = $plugin->beforeGetProperties('principals/user',$principal,$requestedProperties,$returnedProperties);
+
+ $this->assertNull($result);
+
+ $this->assertTrue(isset($returnedProperties[200]));
+ $this->assertTrue(isset($returnedProperties[200]['{DAV:}group-membership']));
+ $this->assertInstanceOf('Sabre\\DAV\\Property\\HrefList', $returnedProperties[200]['{DAV:}group-membership']);
+
+ $this->assertEquals(array(), $returnedProperties[200]['{DAV:}group-membership']->getHrefs());
+
+ }
+
+ function testGetDisplayName() {
+
+ $tree = array(
+ new DAV\SimpleCollection('principals', array(
+ $principal = new MockPrincipal('user','principals/user'),
+ )),
+ );
+
+ $fakeServer = new DAV\Server($tree);
+ //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend(),'realm');
+ //$fakeServer->addPlugin($plugin);
+ $plugin = new Plugin();
+ $fakeServer->addPlugin($plugin);
+
+ $requestedProperties = array(
+ '{DAV:}displayname',
+ );
+ $returnedProperties = array();
+
+ $result = $plugin->beforeGetProperties('principals/user',$principal,$requestedProperties,$returnedProperties);
+
+ $this->assertNull($result);
+
+ $this->assertTrue(isset($returnedProperties[200]));
+ $this->assertTrue(isset($returnedProperties[200]['{DAV:}displayname']));
+
+ $this->assertEquals('user', $returnedProperties[200]['{DAV:}displayname']);
+
+ }
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php
new file mode 100644
index 000000000..53568654f
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php
@@ -0,0 +1,127 @@
+<?php
+
+namespace Sabre\DAVACL;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+
+require_once 'Sabre/DAVACL/MockPrincipal.php';
+
+class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase {
+
+ public function testUpdatePropertiesPassthrough() {
+
+ $tree = array(
+ new DAV\SimpleCollection('foo'),
+ );
+ $server = new DAV\Server($tree);
+ $server->addPlugin(new Plugin());
+
+ $result = $server->updateProperties('foo', array(
+ '{DAV:}foo' => 'bar',
+ ));
+
+ $expected = array(
+ 'href' => 'foo',
+ '403' => array(
+ '{DAV:}foo' => null,
+ ),
+ );
+
+ $this->assertEquals($expected, $result);
+
+ }
+
+ public function testRemoveGroupMembers() {
+
+ $tree = array(
+ new MockPrincipal('foo','foo'),
+ );
+ $server = new DAV\Server($tree);
+ $server->addPlugin(new Plugin());
+
+ $result = $server->updateProperties('foo', array(
+ '{DAV:}group-member-set' => null,
+ ));
+
+ $expected = array(
+ 'href' => 'foo',
+ '200' => array(
+ '{DAV:}group-member-set' => null,
+ ),
+ );
+
+ $this->assertEquals($expected, $result);
+ $this->assertEquals(array(),$tree[0]->getGroupMemberSet());
+
+ }
+
+ public function testSetGroupMembers() {
+
+ $tree = array(
+ new MockPrincipal('foo','foo'),
+ );
+ $server = new DAV\Server($tree);
+ $server->addPlugin(new Plugin());
+
+ $result = $server->updateProperties('foo', array(
+ '{DAV:}group-member-set' => new DAV\Property\HrefList(array('/bar','/baz'), true),
+ ));
+
+ $expected = array(
+ 'href' => 'foo',
+ '200' => array(
+ '{DAV:}group-member-set' => null,
+ ),
+ );
+
+ $this->assertEquals($expected, $result);
+ $this->assertEquals(array('bar','baz'),$tree[0]->getGroupMemberSet());
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception
+ */
+ public function testSetBadValue() {
+
+ $tree = array(
+ new MockPrincipal('foo','foo'),
+ );
+ $server = new DAV\Server($tree);
+ $server->addPlugin(new Plugin());
+
+ $result = $server->updateProperties('foo', array(
+ '{DAV:}group-member-set' => new \StdClass(),
+ ));
+
+ }
+
+ public function testSetBadNode() {
+
+ $tree = array(
+ new DAV\SimpleCollection('foo'),
+ );
+ $server = new DAV\Server($tree);
+ $server->addPlugin(new Plugin());
+
+ $result = $server->updateProperties('foo', array(
+ '{DAV:}group-member-set' => new DAV\Property\HrefList(array('/bar','/baz'),false),
+ '{DAV:}bar' => 'baz',
+ ));
+
+ $expected = array(
+ 'href' => 'foo',
+ '403' => array(
+ '{DAV:}group-member-set' => null,
+ ),
+ '424' => array(
+ '{DAV:}bar' => null,
+ ),
+ );
+
+ $this->assertEquals($expected, $result);
+
+ }
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php
new file mode 100644
index 000000000..3fe75ca0e
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php
@@ -0,0 +1,178 @@
+<?php
+
+namespace Sabre\DAVACL\PrincipalBackend;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+
+abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
+
+ abstract function getPDO();
+
+ function testConstruct() {
+
+ $pdo = $this->getPDO();
+ $backend = new PDO($pdo);
+ $this->assertTrue($backend instanceof PDO);
+
+ }
+
+ /**
+ * @depends testConstruct
+ */
+ function testGetPrincipalsByPrefix() {
+
+ $pdo = $this->getPDO();
+ $backend = new PDO($pdo);
+
+ $expected = array(
+ array(
+ 'uri' => 'principals/user',
+ '{http://sabredav.org/ns}email-address' => 'user@example.org',
+ '{DAV:}displayname' => 'User',
+ ),
+ array(
+ 'uri' => 'principals/group',
+ '{http://sabredav.org/ns}email-address' => 'group@example.org',
+ '{DAV:}displayname' => 'Group',
+ ),
+ );
+
+ $this->assertEquals($expected, $backend->getPrincipalsByPrefix('principals'));
+ $this->assertEquals(array(), $backend->getPrincipalsByPrefix('foo'));
+
+ }
+
+ /**
+ * @depends testConstruct
+ */
+ function testGetPrincipalByPath() {
+
+ $pdo = $this->getPDO();
+ $backend = new PDO($pdo);
+
+ $expected = array(
+ 'id' => 1,
+ 'uri' => 'principals/user',
+ '{http://sabredav.org/ns}email-address' => 'user@example.org',
+ '{DAV:}displayname' => 'User',
+ );
+
+ $this->assertEquals($expected, $backend->getPrincipalByPath('principals/user'));
+ $this->assertEquals(null, $backend->getPrincipalByPath('foo'));
+
+ }
+
+ function testGetGroupMemberSet() {
+
+ $pdo = $this->getPDO();
+ $backend = new PDO($pdo);
+ $expected = array('principals/user');
+
+ $this->assertEquals($expected,$backend->getGroupMemberSet('principals/group'));
+
+ }
+
+ function testGetGroupMembership() {
+
+ $pdo = $this->getPDO();
+ $backend = new PDO($pdo);
+ $expected = array('principals/group');
+
+ $this->assertEquals($expected,$backend->getGroupMembership('principals/user'));
+
+ }
+
+ function testSetGroupMemberSet() {
+
+ $pdo = $this->getPDO();
+
+ // Start situation
+ $backend = new PDO($pdo);
+ $this->assertEquals(array('principals/user'), $backend->getGroupMemberSet('principals/group'));
+
+ // Removing all principals
+ $backend->setGroupMemberSet('principals/group', array());
+ $this->assertEquals(array(), $backend->getGroupMemberSet('principals/group'));
+
+ // Adding principals again
+ $backend->setGroupMemberSet('principals/group', array('principals/user'));
+ $this->assertEquals(array('principals/user'), $backend->getGroupMemberSet('principals/group'));
+
+
+ }
+
+ function testSearchPrincipals() {
+
+ $pdo = $this->getPDO();
+
+ $backend = new PDO($pdo);
+
+ $result = $backend->searchPrincipals('principals', array('{DAV:}blabla' => 'foo'));
+ $this->assertEquals(array(), $result);
+
+ $result = $backend->searchPrincipals('principals', array('{DAV:}displayname' => 'ou'));
+ $this->assertEquals(array('principals/group'), $result);
+
+ $result = $backend->searchPrincipals('principals', array('{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE'));
+ $this->assertEquals(array('principals/user'), $result);
+
+ $result = $backend->searchPrincipals('mom', array('{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE'));
+ $this->assertEquals(array(), $result);
+
+ }
+
+ function testUpdatePrincipal() {
+
+ $pdo = $this->getPDO();
+ $backend = new PDO($pdo);
+
+ $result = $backend->updatePrincipal('principals/user', array(
+ '{DAV:}displayname' => 'pietje',
+ '{http://sabredav.org/ns}vcard-url' => 'blabla',
+ ));
+
+ $this->assertTrue($result);
+
+ $this->assertEquals(array(
+ 'id' => 1,
+ 'uri' => 'principals/user',
+ '{DAV:}displayname' => 'pietje',
+ '{http://sabredav.org/ns}vcard-url' => 'blabla',
+ '{http://sabredav.org/ns}email-address' => 'user@example.org',
+ ), $backend->getPrincipalByPath('principals/user'));
+
+ }
+
+ function testUpdatePrincipalUnknownField() {
+
+ $pdo = $this->getPDO();
+ $backend = new PDO($pdo);
+
+ $result = $backend->updatePrincipal('principals/user', array(
+ '{DAV:}displayname' => 'pietje',
+ '{http://sabredav.org/ns}vcard-url' => 'blabla',
+ '{DAV:}unknown' => 'foo',
+ ));
+
+ $this->assertEquals(array(
+ 424 => array(
+ '{DAV:}displayname' => null,
+ '{http://sabredav.org/ns}vcard-url' => null,
+ ),
+ 403 => array(
+ '{DAV:}unknown' => null,
+ ),
+ ), $result);
+
+ $this->assertEquals(array(
+ 'id' => '1',
+ 'uri' => 'principals/user',
+ '{DAV:}displayname' => 'User',
+ '{http://sabredav.org/ns}email-address' => 'user@example.org',
+ ), $backend->getPrincipalByPath('principals/user'));
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php
new file mode 100644
index 000000000..354446e34
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php
@@ -0,0 +1,184 @@
+<?php
+
+namespace Sabre\DAVACL\PrincipalBackend;
+
+class Mock extends AbstractBackend {
+
+ public $groupMembers = array();
+ public $principals;
+
+ function __construct() {
+
+ $this->principals = array(
+ array(
+ 'uri' => 'principals/user1',
+ '{DAV:}displayname' => 'User 1',
+ '{http://sabredav.org/ns}email-address' => 'user1.sabredav@sabredav.org',
+ '{http://sabredav.org/ns}vcard-url' => 'addressbooks/user1/book1/vcard1.vcf',
+ ),
+ array(
+ 'uri' => 'principals/admin',
+ '{DAV:}displayname' => 'Admin',
+ ),
+ array(
+ 'uri' => 'principals/user2',
+ '{DAV:}displayname' => 'User 2',
+ '{http://sabredav.org/ns}email-address' => 'user2.sabredav@sabredav.org',
+ ),
+ );
+
+
+ }
+
+ function getPrincipalsByPrefix($prefix) {
+
+ $prefix = trim($prefix,'/') . '/';
+ $return = array();
+
+ foreach($this->principals as $principal) {
+
+ if (strpos($principal['uri'], $prefix)!==0) continue;
+
+ $return[] = $principal;
+
+ }
+
+ return $return;
+
+ }
+
+ function addPrincipal(array $principal) {
+
+ $this->principals[] = $principal;
+
+ }
+
+ function getPrincipalByPath($path) {
+
+ foreach($this->getPrincipalsByPrefix('principals') as $principal) {
+ if ($principal['uri'] === $path) return $principal;
+ }
+
+ }
+
+ function searchPrincipals($prefixPath, array $searchProperties) {
+
+ $matches = array();
+ foreach($this->getPrincipalsByPrefix($prefixPath) as $principal) {
+
+ foreach($searchProperties as $key=>$value) {
+
+ if (!isset($principal[$key])) {
+ continue 2;
+ }
+ if (mb_stripos($principal[$key],$value, 0, 'UTF-8')===false) {
+ continue 2;
+ }
+
+ }
+ $matches[] = $principal['uri'];
+
+ }
+ return $matches;
+
+ }
+
+ function getGroupMemberSet($path) {
+
+ return isset($this->groupMembers[$path]) ? $this->groupMembers[$path] : array();
+
+ }
+
+ function getGroupMembership($path) {
+
+ $membership = array();
+ foreach($this->groupMembers as $group=>$members) {
+ if (in_array($path, $members)) $membership[] = $group;
+ }
+ return $membership;
+
+ }
+
+ function setGroupMemberSet($path, array $members) {
+
+ $this->groupMembers[$path] = $members;
+
+ }
+
+ /**
+ * Updates one ore more webdav properties on a principal.
+ *
+ * The list of mutations is supplied as an array. Each key in the array is
+ * a propertyname, such as {DAV:}displayname.
+ *
+ * Each value is the actual value to be updated. If a value is null, it
+ * must be deleted.
+ *
+ * This method should be atomic. It must either completely succeed, or
+ * completely fail. Success and failure can simply be returned as 'true' or
+ * 'false'.
+ *
+ * It is also possible to return detailed failure information. In that case
+ * an array such as this should be returned:
+ *
+ * array(
+ * 200 => array(
+ * '{DAV:}prop1' => null,
+ * ),
+ * 201 => array(
+ * '{DAV:}prop2' => null,
+ * ),
+ * 403 => array(
+ * '{DAV:}prop3' => null,
+ * ),
+ * 424 => array(
+ * '{DAV:}prop4' => null,
+ * ),
+ * );
+ *
+ * In this previous example prop1 was successfully updated or deleted, and
+ * prop2 was succesfully created.
+ *
+ * prop3 failed to update due to '403 Forbidden' and because of this prop4
+ * also could not be updated with '424 Failed dependency'.
+ *
+ * This last example was actually incorrect. While 200 and 201 could appear
+ * in 1 response, if there's any error (403) the other properties should
+ * always fail with 423 (failed dependency).
+ *
+ * But anyway, if you don't want to scratch your head over this, just
+ * return true or false.
+ *
+ * @param string $path
+ * @param array $mutations
+ * @return array|bool
+ */
+ public function updatePrincipal($path, $mutations) {
+
+ $value = null;
+ foreach($this->principals as $principalIndex=>$value) {
+ if ($value['uri'] === $path) {
+ $principal = $value;
+ break;
+ }
+ }
+ if (!$principal) return false;
+
+ foreach($mutations as $prop=>$value) {
+
+ if (is_null($value) && isset($principal[$prop])) {
+ unset($principal[$prop]);
+ } else {
+ $principal[$prop] = $value;
+ }
+
+ }
+
+ $this->principals[$principalIndex] = $principal;
+
+ return true;
+
+ }
+
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php
new file mode 100644
index 000000000..84ba062ca
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Sabre\DAVACL\PrincipalBackend;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+
+require_once 'Sabre/TestUtil.php';
+
+class PDOMySQLTest extends AbstractPDOTest {
+
+ function getPDO() {
+
+ if (!SABRE_HASMYSQL) $this->markTestSkipped('MySQL driver is not available, or not properly configured');
+ $pdo = \Sabre\TestUtil::getMySQLDB();
+ if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database');
+ $pdo->query("DROP TABLE IF EXISTS principals");
+ $pdo->query("
+create table principals (
+ id integer unsigned not null primary key auto_increment,
+ uri varchar(50),
+ email varchar(80),
+ displayname VARCHAR(80),
+ vcardurl VARCHAR(80),
+ unique(uri)
+);");
+
+ $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/user','user@example.org','User')");
+ $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/group','group@example.org','Group')");
+ $pdo->query("DROP TABLE IF EXISTS groupmembers");
+ $pdo->query("CREATE TABLE groupmembers (
+ id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ principal_id INTEGER UNSIGNED NOT NULL,
+ member_id INTEGER UNSIGNED NOT NULL,
+ UNIQUE(principal_id, member_id)
+ );");
+
+ $pdo->query("INSERT INTO groupmembers (principal_id,member_id) VALUES (2,1)");
+
+ return $pdo;
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php
new file mode 100644
index 000000000..192e188f9
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php
@@ -0,0 +1,42 @@
+<?php
+
+namespace Sabre\DAVACL\PrincipalBackend;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+
+require_once 'Sabre/DAV/Auth/Backend/AbstractPDOTest.php';
+
+class PDOSQLiteTest extends AbstractPDOTest {
+
+ function tearDown() {
+
+ if (file_exists(SABRE_TEMPDIR . '/pdobackend')) unlink(SABRE_TEMPDIR . '/pdobackend');
+ if (file_exists(SABRE_TEMPDIR . '/pdobackend2')) unlink(SABRE_TEMPDIR . '/pdobackend2');
+
+ }
+
+ function getPDO() {
+
+ if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
+ $pdo = new \PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend');
+ $pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION);
+ $pdo->query('CREATE TABLE principals (id INTEGER PRIMARY KEY ASC, uri TEXT, email VARCHAR(80), displayname VARCHAR(80), vcardurl VARCHAR(80))');
+ $pdo->query('INSERT INTO principals VALUES (1, "principals/user","user@example.org","User",null)');
+ $pdo->query('INSERT INTO principals VALUES (2, "principals/group","group@example.org","Group",null)');
+
+ $pdo->query("CREATE TABLE groupmembers (
+ id INTEGER PRIMARY KEY ASC,
+ principal_id INT,
+ member_id INT,
+ UNIQUE(principal_id, member_id)
+ );");
+
+ $pdo->query("INSERT INTO groupmembers (principal_id,member_id) VALUES (2,1)");
+
+ return $pdo;
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php
new file mode 100644
index 000000000..10b0c04da
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php
@@ -0,0 +1,52 @@
+<?php
+
+namespace Sabre\DAVACL;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+
+class PrincipalCollectionTest extends \PHPUnit_Framework_TestCase {
+
+ public function testBasic() {
+
+ $backend = new PrincipalBackend\Mock();
+ $pc = new PrincipalCollection($backend);
+ $this->assertTrue($pc instanceof PrincipalCollection);
+
+ $this->assertEquals('principals',$pc->getName());
+
+ }
+
+ /**
+ * @depends testBasic
+ */
+ public function testGetChildren() {
+
+ $backend = new PrincipalBackend\Mock();
+ $pc = new PrincipalCollection($backend);
+
+ $children = $pc->getChildren();
+ $this->assertTrue(is_array($children));
+
+ foreach($children as $child) {
+ $this->assertTrue($child instanceof IPrincipal);
+ }
+
+ }
+
+ /**
+ * @depends testBasic
+ * @expectedException Sabre\DAV\Exception\MethodNotAllowed
+ */
+ public function testGetChildrenDisable() {
+
+ $backend = new PrincipalBackend\Mock();
+ $pc = new PrincipalCollection($backend);
+ $pc->disableListing = true;
+
+ $children = $pc->getChildren();
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php
new file mode 100644
index 000000000..9c3be4f9a
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php
@@ -0,0 +1,246 @@
+<?php
+
+namespace Sabre\DAVACL;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+require_once 'Sabre/HTTP/ResponseMock.php';
+
+class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase {
+
+ function getServer() {
+
+ $backend = new PrincipalBackend\Mock();
+
+ $dir = new DAV\SimpleCollection('root');
+ $principals = new PrincipalCollection($backend);
+ $dir->addChild($principals);
+
+ $fakeServer = new DAV\Server(new DAV\ObjectTree($dir));
+ $fakeServer->httpResponse = new HTTP\ResponseMock();
+ $fakeServer->debugExceptions = true;
+ $plugin = new MockPlugin($backend,'realm');
+ $plugin->allowAccessToNodesWithoutACL = true;
+
+ $this->assertTrue($plugin instanceof Plugin);
+ $fakeServer->addPlugin($plugin);
+ $this->assertEquals($plugin, $fakeServer->getPlugin('acl'));
+
+ return $fakeServer;
+
+ }
+
+ function testDepth1() {
+
+ $xml = '<?xml version="1.0"?>
+<d:principal-property-search xmlns:d="DAV:">
+ <d:property-search>
+ <d:prop>
+ <d:displayname />
+ </d:prop>
+ <d:match>user</d:match>
+ </d:property-search>
+ <d:prop>
+ <d:displayname />
+ <d:getcontentlength />
+ </d:prop>
+</d:principal-property-search>';
+
+ $serverVars = array(
+ 'REQUEST_METHOD' => 'REPORT',
+ 'HTTP_DEPTH' => '1',
+ 'REQUEST_URI' => '/principals',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody($xml);
+
+ $server = $this->getServer();
+ $server->httpRequest = $request;
+
+ $server->exec();
+
+ $this->assertEquals('HTTP/1.1 400 Bad request', $server->httpResponse->status);
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ), $server->httpResponse->headers);
+
+ }
+
+
+ function testUnknownSearchField() {
+
+ $xml = '<?xml version="1.0"?>
+<d:principal-property-search xmlns:d="DAV:">
+ <d:property-search>
+ <d:prop>
+ <d:yourmom />
+ </d:prop>
+ <d:match>user</d:match>
+ </d:property-search>
+ <d:prop>
+ <d:displayname />
+ <d:getcontentlength />
+ </d:prop>
+</d:principal-property-search>';
+
+ $serverVars = array(
+ 'REQUEST_METHOD' => 'REPORT',
+ 'HTTP_DEPTH' => '0',
+ 'REQUEST_URI' => '/principals',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody($xml);
+
+ $server = $this->getServer();
+ $server->httpRequest = $request;
+
+ $server->exec();
+
+ $this->assertEquals('HTTP/1.1 207 Multi-Status', $server->httpResponse->status);
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ 'Vary' => 'Brief,Prefer',
+ ), $server->httpResponse->headers);
+
+ }
+
+ function testCorrect() {
+
+ $xml = '<?xml version="1.0"?>
+<d:principal-property-search xmlns:d="DAV:">
+ <d:apply-to-principal-collection-set />
+ <d:property-search>
+ <d:prop>
+ <d:displayname />
+ </d:prop>
+ <d:match>user</d:match>
+ </d:property-search>
+ <d:prop>
+ <d:displayname />
+ <d:getcontentlength />
+ </d:prop>
+</d:principal-property-search>';
+
+ $serverVars = array(
+ 'REQUEST_METHOD' => 'REPORT',
+ 'HTTP_DEPTH' => '0',
+ 'REQUEST_URI' => '/',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody($xml);
+
+ $server = $this->getServer();
+ $server->httpRequest = $request;
+
+ $server->exec();
+
+ $this->assertEquals('HTTP/1.1 207 Multi-Status', $server->httpResponse->status, $server->httpResponse->body);
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ 'Vary' => 'Brief,Prefer',
+ ), $server->httpResponse->headers);
+
+
+ $check = array(
+ '/d:multistatus',
+ '/d:multistatus/d:response' => 2,
+ '/d:multistatus/d:response/d:href' => 2,
+ '/d:multistatus/d:response/d:propstat' => 4,
+ '/d:multistatus/d:response/d:propstat/d:prop' => 4,
+ '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2,
+ '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 2,
+ '/d:multistatus/d:response/d:propstat/d:status' => 4,
+ );
+
+ $xml = simplexml_load_string($server->httpResponse->body);
+ $xml->registerXPathNamespace('d','DAV:');
+ foreach($check as $v1=>$v2) {
+
+ $xpath = is_int($v1)?$v2:$v1;
+
+ $result = $xml->xpath($xpath);
+
+ $count = 1;
+ if (!is_int($v1)) $count = $v2;
+
+ $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body);
+
+ }
+
+ }
+ function testWrongUri() {
+
+ $xml = '<?xml version="1.0"?>
+<d:principal-property-search xmlns:d="DAV:">
+ <d:property-search>
+ <d:prop>
+ <d:displayname />
+ </d:prop>
+ <d:match>user</d:match>
+ </d:property-search>
+ <d:prop>
+ <d:displayname />
+ <d:getcontentlength />
+ </d:prop>
+</d:principal-property-search>';
+
+ $serverVars = array(
+ 'REQUEST_METHOD' => 'REPORT',
+ 'HTTP_DEPTH' => '0',
+ 'REQUEST_URI' => '/',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody($xml);
+
+ $server = $this->getServer();
+ $server->httpRequest = $request;
+
+ $server->exec();
+
+ $this->assertEquals('HTTP/1.1 207 Multi-Status', $server->httpResponse->status, $server->httpResponse->body);
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ 'Vary' => 'Brief,Prefer',
+ ), $server->httpResponse->headers);
+
+
+ $check = array(
+ '/d:multistatus',
+ '/d:multistatus/d:response' => 0,
+ );
+
+ $xml = simplexml_load_string($server->httpResponse->body);
+ $xml->registerXPathNamespace('d','DAV:');
+ foreach($check as $v1=>$v2) {
+
+ $xpath = is_int($v1)?$v2:$v1;
+
+ $result = $xml->xpath($xpath);
+
+ $count = 1;
+ if (!is_int($v1)) $count = $v2;
+
+ $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body);
+
+ }
+
+ }
+}
+
+class MockPlugin extends Plugin {
+
+ function getCurrentUserPrivilegeSet($node) {
+
+ return array(
+ '{DAV:}read',
+ '{DAV:}write',
+ );
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php
new file mode 100644
index 000000000..412389e8b
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php
@@ -0,0 +1,135 @@
+<?php
+
+namespace Sabre\DAVACL;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+require_once 'Sabre/HTTP/ResponseMock.php';
+
+class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase {
+
+ function getServer() {
+
+ $backend = new PrincipalBackend\Mock();
+
+ $dir = new DAV\SimpleCollection('root');
+ $principals = new PrincipalCollection($backend);
+ $dir->addChild($principals);
+
+ $fakeServer = new DAV\Server(new DAV\ObjectTree($dir));
+ $fakeServer->httpResponse = new HTTP\ResponseMock();
+ $plugin = new Plugin($backend,'realm');
+ $this->assertTrue($plugin instanceof Plugin);
+ $fakeServer->addPlugin($plugin);
+ $this->assertEquals($plugin, $fakeServer->getPlugin('acl'));
+
+ return $fakeServer;
+
+ }
+
+ function testDepth1() {
+
+ $xml = '<?xml version="1.0"?>
+<d:principal-search-property-set xmlns:d="DAV:" />';
+
+ $serverVars = array(
+ 'REQUEST_METHOD' => 'REPORT',
+ 'HTTP_DEPTH' => '1',
+ 'REQUEST_URI' => '/principals',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody($xml);
+
+ $server = $this->getServer();
+ $server->httpRequest = $request;
+
+ $server->exec();
+
+ $this->assertEquals('HTTP/1.1 400 Bad request', $server->httpResponse->status);
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ), $server->httpResponse->headers);
+
+ }
+
+ function testDepthIncorrectXML() {
+
+ $xml = '<?xml version="1.0"?>
+<d:principal-search-property-set xmlns:d="DAV:"><d:ohell /></d:principal-search-property-set>';
+
+ $serverVars = array(
+ 'REQUEST_METHOD' => 'REPORT',
+ 'HTTP_DEPTH' => '0',
+ 'REQUEST_URI' => '/principals',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody($xml);
+
+ $server = $this->getServer();
+ $server->httpRequest = $request;
+
+ $server->exec();
+
+ $this->assertEquals('HTTP/1.1 400 Bad request', $server->httpResponse->status, $server->httpResponse->body);
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ), $server->httpResponse->headers);
+
+ }
+
+ function testCorrect() {
+
+ $xml = '<?xml version="1.0"?>
+<d:principal-search-property-set xmlns:d="DAV:"/>';
+
+ $serverVars = array(
+ 'REQUEST_METHOD' => 'REPORT',
+ 'HTTP_DEPTH' => '0',
+ 'REQUEST_URI' => '/principals',
+ );
+
+ $request = new HTTP\Request($serverVars);
+ $request->setBody($xml);
+
+ $server = $this->getServer();
+ $server->httpRequest = $request;
+
+ $server->exec();
+
+ $this->assertEquals('HTTP/1.1 200 OK', $server->httpResponse->status, $server->httpResponse->body);
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ ), $server->httpResponse->headers);
+
+
+ $check = array(
+ '/d:principal-search-property-set',
+ '/d:principal-search-property-set/d:principal-search-property' => 2,
+ '/d:principal-search-property-set/d:principal-search-property/d:prop' => 2,
+ '/d:principal-search-property-set/d:principal-search-property/d:prop/d:displayname' => 1,
+ '/d:principal-search-property-set/d:principal-search-property/d:prop/s:email-address' => 1,
+ '/d:principal-search-property-set/d:principal-search-property/d:description' => 2,
+ );
+
+ $xml = simplexml_load_string($server->httpResponse->body);
+ $xml->registerXPathNamespace('d','DAV:');
+ $xml->registerXPathNamespace('s','http://sabredav.org/ns');
+ foreach($check as $v1=>$v2) {
+
+ $xpath = is_int($v1)?$v2:$v1;
+
+ $result = $xml->xpath($xpath);
+
+ $count = 1;
+ if (!is_int($v1)) $count = $v2;
+
+ $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body);
+
+ }
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php
new file mode 100644
index 000000000..2d4371138
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php
@@ -0,0 +1,204 @@
+<?php
+
+namespace Sabre\DAVACL;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+class PrincipalTest extends \PHPUnit_Framework_TestCase {
+
+ public function testConstruct() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array('uri' => 'principals/admin'));
+ $this->assertTrue($principal instanceof Principal);
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception
+ */
+ public function testConstructNoUri() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array());
+
+ }
+
+ public function testGetName() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array('uri' => 'principals/admin'));
+ $this->assertEquals('admin',$principal->getName());
+
+ }
+
+ public function testGetDisplayName() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array('uri' => 'principals/admin'));
+ $this->assertEquals('admin',$principal->getDisplayname());
+
+ $principal = new Principal($principalBackend, array(
+ 'uri' => 'principals/admin',
+ '{DAV:}displayname' => 'Mr. Admin'
+ ));
+ $this->assertEquals('Mr. Admin',$principal->getDisplayname());
+
+ }
+
+ public function testGetProperties() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array(
+ 'uri' => 'principals/admin',
+ '{DAV:}displayname' => 'Mr. Admin',
+ '{http://www.example.org/custom}custom' => 'Custom',
+ '{http://sabredav.org/ns}email-address' => 'admin@example.org',
+ ));
+
+ $keys = array(
+ '{DAV:}displayname',
+ '{http://www.example.org/custom}custom',
+ '{http://sabredav.org/ns}email-address',
+ );
+ $props = $principal->getProperties($keys);
+
+ foreach($keys as $key) $this->assertArrayHasKey($key,$props);
+
+ $this->assertEquals('Mr. Admin',$props['{DAV:}displayname']);
+
+ $this->assertEquals('admin@example.org', $props['{http://sabredav.org/ns}email-address']);
+ }
+
+ public function testUpdateProperties() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array('uri' => 'principals/admin'));
+ $result = $principal->updateProperties(array('{DAV:}yourmom'=>'test'));
+ $this->assertEquals(true,$result);
+
+ }
+
+ public function testGetPrincipalUrl() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array('uri' => 'principals/admin'));
+ $this->assertEquals('principals/admin',$principal->getPrincipalUrl());
+
+ }
+
+ public function testGetAlternateUriSet() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array(
+ 'uri' => 'principals/admin',
+ '{DAV:}displayname' => 'Mr. Admin',
+ '{http://www.example.org/custom}custom' => 'Custom',
+ '{http://sabredav.org/ns}email-address' => 'admin@example.org',
+ '{DAV:}alternate-URI-set' => array(
+ 'mailto:admin+1@example.org',
+ 'mailto:admin+2@example.org',
+ 'mailto:admin@example.org',
+ ),
+ ));
+
+ $expected = array(
+ 'mailto:admin+1@example.org',
+ 'mailto:admin+2@example.org',
+ 'mailto:admin@example.org',
+ );
+
+ $this->assertEquals($expected,$principal->getAlternateUriSet());
+
+ }
+ public function testGetAlternateUriSetEmpty() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array(
+ 'uri' => 'principals/admin',
+ ));
+
+ $expected = array();
+
+ $this->assertEquals($expected,$principal->getAlternateUriSet());
+
+ }
+
+ public function testGetGroupMemberSet() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array('uri' => 'principals/admin'));
+ $this->assertEquals(array(),$principal->getGroupMemberSet());
+
+ }
+ public function testGetGroupMembership() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array('uri' => 'principals/admin'));
+ $this->assertEquals(array(),$principal->getGroupMembership());
+
+ }
+
+ public function testSetGroupMemberSet() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array('uri' => 'principals/admin'));
+ $principal->setGroupMemberSet(array('principals/foo'));
+
+ $this->assertEquals(array(
+ 'principals/admin' => array('principals/foo'),
+ ), $principalBackend->groupMembers);
+
+ }
+
+ public function testGetOwner() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array('uri' => 'principals/admin'));
+ $this->assertEquals('principals/admin',$principal->getOwner());
+
+ }
+
+ public function testGetGroup() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array('uri' => 'principals/admin'));
+ $this->assertNull($principal->getGroup());
+
+ }
+
+ public function testGetACl() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array('uri' => 'principals/admin'));
+ $this->assertEquals(array(
+ array(
+ 'privilege' => '{DAV:}read',
+ 'principal' => 'principals/admin',
+ 'protected' => true,
+ )
+ ),$principal->getACL());
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\MethodNotAllowed
+ */
+ public function testSetACl() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array('uri' => 'principals/admin'));
+ $principal->setACL(array());
+
+ }
+
+ public function testGetSupportedPrivilegeSet() {
+
+ $principalBackend = new PrincipalBackend\Mock();
+ $principal = new Principal($principalBackend, array('uri' => 'principals/admin'));
+ $this->assertNull($principal->getSupportedPrivilegeSet());
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Property/ACLRestrictionsTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Property/ACLRestrictionsTest.php
new file mode 100644
index 000000000..72a2f36a4
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Property/ACLRestrictionsTest.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Sabre\DAVACL\Property;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+class ACLRestrictionsTest extends \PHPUnit_Framework_TestCase {
+
+ function testConstruct() {
+
+ $prop = new AclRestrictions();
+
+ }
+
+ function testSerializeEmpty() {
+
+ $dom = new \DOMDocument('1.0');
+ $root = $dom->createElementNS('DAV:','d:root');
+
+ $dom->appendChild($root);
+
+ $acl = new AclRestrictions();
+ $acl->serialize(new DAV\Server(), $root);
+
+ $xml = $dom->saveXML();
+ $expected = '<?xml version="1.0"?>
+<d:root xmlns:d="DAV:"><d:grant-only/><d:no-invert/></d:root>
+';
+ $this->assertEquals($expected, $xml);
+
+ }
+
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Property/ACLTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Property/ACLTest.php
new file mode 100644
index 000000000..7f2014df3
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Property/ACLTest.php
@@ -0,0 +1,335 @@
+<?php
+
+namespace Sabre\DAVACL\Property;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+
+class ACLTest extends \PHPUnit_Framework_TestCase {
+
+ function testConstruct() {
+
+ $acl = new Acl(array());
+
+ }
+
+ function testSerializeEmpty() {
+
+ $dom = new \DOMDocument('1.0');
+ $root = $dom->createElementNS('DAV:','d:root');
+
+ $dom->appendChild($root);
+
+ $acl = new Acl(array());
+ $acl->serialize(new DAV\Server(), $root);
+
+ $xml = $dom->saveXML();
+ $expected = '<?xml version="1.0"?>
+<d:root xmlns:d="DAV:"/>
+';
+ $this->assertEquals($expected, $xml);
+
+ }
+
+ function testSerialize() {
+
+ $dom = new \DOMDocument('1.0');
+ $root = $dom->createElementNS('DAV:','d:root');
+
+ $dom->appendChild($root);
+
+ $privileges = array(
+ array(
+ 'principal' => 'principals/evert',
+ 'privilege' => '{DAV:}write',
+ 'uri' => 'articles',
+ ),
+ array(
+ 'principal' => 'principals/foo',
+ 'privilege' => '{DAV:}read',
+ 'uri' => 'articles',
+ 'protected' => true,
+ ),
+ );
+
+ $acl = new Acl($privileges);
+ $acl->serialize(new DAV\Server(), $root);
+
+ $dom->formatOutput = true;
+
+ $xml = $dom->saveXML();
+ $expected = '<?xml version="1.0"?>
+<d:root xmlns:d="DAV:">
+ <d:ace>
+ <d:principal>
+ <d:href>/principals/evert/</d:href>
+ </d:principal>
+ <d:grant>
+ <d:privilege>
+ <d:write/>
+ </d:privilege>
+ </d:grant>
+ </d:ace>
+ <d:ace>
+ <d:principal>
+ <d:href>/principals/foo/</d:href>
+ </d:principal>
+ <d:grant>
+ <d:privilege>
+ <d:read/>
+ </d:privilege>
+ </d:grant>
+ <d:protected/>
+ </d:ace>
+</d:root>
+';
+ $this->assertEquals($expected, $xml);
+
+ }
+
+ function testSerializeSpecialPrincipals() {
+
+ $dom = new \DOMDocument('1.0');
+ $root = $dom->createElementNS('DAV:','d:root');
+
+ $dom->appendChild($root);
+
+ $privileges = array(
+ array(
+ 'principal' => '{DAV:}authenticated',
+ 'privilege' => '{DAV:}write',
+ 'uri' => 'articles',
+ ),
+ array(
+ 'principal' => '{DAV:}unauthenticated',
+ 'privilege' => '{DAV:}write',
+ 'uri' => 'articles',
+ ),
+ array(
+ 'principal' => '{DAV:}all',
+ 'privilege' => '{DAV:}write',
+ 'uri' => 'articles',
+ ),
+
+ );
+
+ $acl = new Acl($privileges);
+ $acl->serialize(new DAV\Server(), $root);
+
+ $dom->formatOutput = true;
+
+ $xml = $dom->saveXML();
+ $expected = '<?xml version="1.0"?>
+<d:root xmlns:d="DAV:">
+ <d:ace>
+ <d:principal>
+ <d:authenticated/>
+ </d:principal>
+ <d:grant>
+ <d:privilege>
+ <d:write/>
+ </d:privilege>
+ </d:grant>
+ </d:ace>
+ <d:ace>
+ <d:principal>
+ <d:unauthenticated/>
+ </d:principal>
+ <d:grant>
+ <d:privilege>
+ <d:write/>
+ </d:privilege>
+ </d:grant>
+ </d:ace>
+ <d:ace>
+ <d:principal>
+ <d:all/>
+ </d:principal>
+ <d:grant>
+ <d:privilege>
+ <d:write/>
+ </d:privilege>
+ </d:grant>
+ </d:ace>
+</d:root>
+';
+ $this->assertEquals($expected, $xml);
+
+ }
+
+ function testUnserialize() {
+
+ $source = '<?xml version="1.0"?>
+<d:root xmlns:d="DAV:">
+ <d:ace>
+ <d:principal>
+ <d:href>/principals/evert/</d:href>
+ </d:principal>
+ <d:grant>
+ <d:privilege>
+ <d:write/>
+ </d:privilege>
+ </d:grant>
+ </d:ace>
+ <d:ace>
+ <d:principal>
+ <d:href>/principals/foo/</d:href>
+ </d:principal>
+ <d:grant>
+ <d:privilege>
+ <d:read/>
+ </d:privilege>
+ </d:grant>
+ <d:protected/>
+ </d:ace>
+</d:root>
+';
+
+ $dom = DAV\XMLUtil::loadDOMDocument($source);
+ $result = Acl::unserialize($dom->firstChild);
+
+ $this->assertInstanceOf('Sabre\\DAVACL\\Property\\ACL', $result);
+
+ $expected = array(
+ array(
+ 'principal' => '/principals/evert/',
+ 'protected' => false,
+ 'privilege' => '{DAV:}write',
+ ),
+ array(
+ 'principal' => '/principals/foo/',
+ 'protected' => true,
+ 'privilege' => '{DAV:}read',
+ ),
+ );
+
+ $this->assertEquals($expected, $result->getPrivileges());
+
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\BadRequest
+ */
+ function testUnserializeNoPrincipal() {
+
+ $source = '<?xml version="1.0"?>
+<d:root xmlns:d="DAV:">
+ <d:ace>
+ <d:grant>
+ <d:privilege>
+ <d:write/>
+ </d:privilege>
+ </d:grant>
+ </d:ace>
+</d:root>
+';
+
+ $dom = DAV\XMLUtil::loadDOMDocument($source);
+ Acl::unserialize($dom->firstChild);
+
+ }
+
+ function testUnserializeOtherPrincipal() {
+
+ $source = '<?xml version="1.0"?>
+<d:root xmlns:d="DAV:">
+ <d:ace>
+ <d:grant>
+ <d:privilege>
+ <d:write/>
+ </d:privilege>
+ </d:grant>
+ <d:principal><d:authenticated /></d:principal>
+ </d:ace>
+ <d:ace>
+ <d:grant>
+ <d:privilege>
+ <d:write/>
+ </d:privilege>
+ </d:grant>
+ <d:principal><d:unauthenticated /></d:principal>
+ </d:ace>
+ <d:ace>
+ <d:grant>
+ <d:privilege>
+ <d:write/>
+ </d:privilege>
+ </d:grant>
+ <d:principal><d:all /></d:principal>
+ </d:ace>
+</d:root>
+';
+
+ $dom = DAV\XMLUtil::loadDOMDocument($source);
+ $result = Acl::unserialize($dom->firstChild);
+
+ $this->assertInstanceOf('Sabre\\DAVACL\\Property\\Acl', $result);
+
+ $expected = array(
+ array(
+ 'principal' => '{DAV:}authenticated',
+ 'protected' => false,
+ 'privilege' => '{DAV:}write',
+ ),
+ array(
+ 'principal' => '{DAV:}unauthenticated',
+ 'protected' => false,
+ 'privilege' => '{DAV:}write',
+ ),
+ array(
+ 'principal' => '{DAV:}all',
+ 'protected' => false,
+ 'privilege' => '{DAV:}write',
+ ),
+ );
+
+ $this->assertEquals($expected, $result->getPrivileges());
+
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\NotImplemented
+ */
+ function testUnserializeDeny() {
+
+ $source = '<?xml version="1.0"?>
+<d:root xmlns:d="DAV:">
+ <d:ace>
+ <d:deny>
+ <d:privilege>
+ <d:write/>
+ </d:privilege>
+ </d:deny>
+ <d:principal><d:href>/principals/evert</d:href></d:principal>
+ </d:ace>
+</d:root>
+';
+
+ $dom = DAV\XMLUtil::loadDOMDocument($source);
+ Acl::unserialize($dom->firstChild);
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\BadRequest
+ */
+ function testUnserializeMissingPriv() {
+
+ $source = '<?xml version="1.0"?>
+<d:root xmlns:d="DAV:">
+ <d:ace>
+ <d:grant>
+ <d:privilege />
+ </d:grant>
+ <d:principal><d:href>/principals/evert</d:href></d:principal>
+ </d:ace>
+</d:root>
+';
+
+ $dom = DAV\XMLUtil::loadDOMDocument($source);
+ Acl::unserialize($dom->firstChild);
+
+ }
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Property/CurrentUserPrivilegeSetTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Property/CurrentUserPrivilegeSetTest.php
new file mode 100644
index 000000000..e71addb65
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Property/CurrentUserPrivilegeSetTest.php
@@ -0,0 +1,68 @@
+<?php
+
+namespace Sabre\DAVACL\Property;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+
+class CurrentUserPrivilegeSetTest extends \PHPUnit_Framework_TestCase {
+
+ function testSerialize() {
+
+ $privileges = array(
+ '{DAV:}read',
+ '{DAV:}write',
+ );
+ $prop = new CurrentUserPrivilegeSet($privileges);
+
+ $server = new DAV\Server();
+ $dom = new \DOMDocument('1.0','utf-8');
+ $root = $dom->createElementNS('DAV:','d:root');
+ $dom->appendChild($root);
+
+ $prop->serialize($server, $root);
+
+ $xpaths = array(
+ '/d:root' => 1,
+ '/d:root/d:privilege' => 2,
+ '/d:root/d:privilege/d:read' => 1,
+ '/d:root/d:privilege/d:write' => 1,
+ );
+
+ // Reloading because PHP DOM sucks
+ $dom2 = new \DOMDocument('1.0', 'utf-8');
+ $dom2->loadXML($dom->saveXML());
+
+ $dxpath = new \DOMXPath($dom2);
+ $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);
+
+ }
+
+ }
+
+ function testUnserialize() {
+
+ $source = '<?xml version="1.0"?>
+<d:root xmlns:d="DAV:">
+ <d:privilege>
+ <d:write-properties />
+ </d:privilege>
+ <d:privilege>
+ <d:read />
+ </d:privilege>
+</d:root>
+';
+
+ $dom = DAV\XMLUtil::loadDOMDocument($source);
+ $result = CurrentUserPrivilegeSet::unserialize($dom->firstChild, array());
+ $this->assertTrue($result->has('{DAV:}read'));
+ $this->assertTrue($result->has('{DAV:}write-properties'));
+ $this->assertFalse($result->has('{DAV:}bind'));
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Property/PrincipalTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Property/PrincipalTest.php
new file mode 100644
index 000000000..be12c79ee
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Property/PrincipalTest.php
@@ -0,0 +1,181 @@
+<?php
+
+namespace Sabre\DAVACL\Property;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+class PrincipalTest extends \PHPUnit_Framework_TestCase {
+
+ function testSimple() {
+
+ $principal = new Principal(Principal::UNAUTHENTICATED);
+ $this->assertEquals(Principal::UNAUTHENTICATED, $principal->getType());
+ $this->assertNull($principal->getHref());
+
+ $principal = new Principal(Principal::AUTHENTICATED);
+ $this->assertEquals(Principal::AUTHENTICATED, $principal->getType());
+ $this->assertNull($principal->getHref());
+
+ $principal = new Principal(Principal::HREF,'admin');
+ $this->assertEquals(Principal::HREF, $principal->getType());
+ $this->assertEquals('admin',$principal->getHref());
+
+ }
+
+ /**
+ * @depends testSimple
+ * @expectedException Sabre\DAV\Exception
+ */
+ function testNoHref() {
+
+ $principal = new Principal(Principal::HREF);
+
+ }
+
+ /**
+ * @depends testSimple
+ */
+ function testSerializeUnAuthenticated() {
+
+ $prin = new Principal(Principal::UNAUTHENTICATED);
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:principal');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $objectTree = new DAV\ObjectTree(new DAV\SimpleCollection('rootdir'));
+ $server = new DAV\Server($objectTree);
+
+ $prin->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:principal xmlns:d="DAV:">' .
+'<d:unauthenticated/>' .
+'</d:principal>
+', $xml);
+
+ }
+
+
+ /**
+ * @depends testSerializeUnAuthenticated
+ */
+ function testSerializeAuthenticated() {
+
+ $prin = new Principal(Principal::AUTHENTICATED);
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:principal');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $objectTree = new DAV\ObjectTree(new DAV\SimpleCollection('rootdir'));
+ $server = new DAV\Server($objectTree);
+
+ $prin->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:principal xmlns:d="DAV:">' .
+'<d:authenticated/>' .
+'</d:principal>
+', $xml);
+
+ }
+
+
+ /**
+ * @depends testSerializeUnAuthenticated
+ */
+ function testSerializeHref() {
+
+ $prin = new Principal(Principal::HREF,'principals/admin');
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElement('d:principal');
+ $root->setAttribute('xmlns:d','DAV:');
+
+ $doc->appendChild($root);
+ $objectTree = new DAV\ObjectTree(new DAV\SimpleCollection('rootdir'));
+ $server = new DAV\Server($objectTree);
+
+ $prin->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:principal xmlns:d="DAV:">' .
+'<d:href>/principals/admin</d:href>' .
+'</d:principal>
+', $xml);
+
+ }
+
+ function testUnserializeHref() {
+
+ $xml = '<?xml version="1.0"?>
+<d:principal xmlns:d="DAV:">' .
+'<d:href>/principals/admin</d:href>' .
+'</d:principal>';
+
+ $dom = DAV\XMLUtil::loadDOMDocument($xml);
+
+ $principal = Principal::unserialize($dom->firstChild);
+ $this->assertEquals(Principal::HREF, $principal->getType());
+ $this->assertEquals('/principals/admin', $principal->getHref());
+
+ }
+
+ function testUnserializeAuthenticated() {
+
+ $xml = '<?xml version="1.0"?>
+<d:principal xmlns:d="DAV:">' .
+' <d:authenticated />' .
+'</d:principal>';
+
+ $dom = DAV\XMLUtil::loadDOMDocument($xml);
+
+ $principal = Principal::unserialize($dom->firstChild);
+ $this->assertEquals(Principal::AUTHENTICATED, $principal->getType());
+
+ }
+
+ function testUnserializeUnauthenticated() {
+
+ $xml = '<?xml version="1.0"?>
+<d:principal xmlns:d="DAV:">' .
+' <d:unauthenticated />' .
+'</d:principal>';
+
+ $dom = DAV\XMLUtil::loadDOMDocument($xml);
+
+ $principal = Principal::unserialize($dom->firstChild);
+ $this->assertEquals(Principal::UNAUTHENTICATED, $principal->getType());
+
+ }
+
+ /**
+ * @expectedException Sabre\DAV\Exception\BadRequest
+ */
+ function testUnserializeUnknown() {
+
+ $xml = '<?xml version="1.0"?>
+<d:principal xmlns:d="DAV:">' .
+' <d:foo />' .
+'</d:principal>';
+
+ $dom = DAV\XMLUtil::loadDOMDocument($xml);
+
+ Principal::unserialize($dom->firstChild);
+
+ }
+
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Property/SupportedPrivilegeSetTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Property/SupportedPrivilegeSetTest.php
new file mode 100644
index 000000000..943316331
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Property/SupportedPrivilegeSetTest.php
@@ -0,0 +1,106 @@
+<?php
+
+namespace Sabre\DAVACL\Property;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+
+
+class SupportedPrivilegeSetTest extends \PHPUnit_Framework_TestCase {
+
+ function testSimple() {
+
+ $prop = new SupportedPrivilegeSet(array(
+ 'privilege' => '{DAV:}all',
+ ));
+
+ }
+
+
+ /**
+ * @depends testSimple
+ */
+ function testSerializeSimple() {
+
+ $prop = new SupportedPrivilegeSet(array(
+ 'privilege' => '{DAV:}all',
+ ));
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElementNS('DAV:', 'd:supported-privilege-set');
+
+ $doc->appendChild($root);
+
+ $server = new DAV\Server();
+ $prop->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:supported-privilege-set xmlns:d="DAV:">' .
+'<d:supported-privilege>' .
+'<d:privilege>' .
+'<d:all/>' .
+'</d:privilege>' .
+'</d:supported-privilege>' .
+'</d:supported-privilege-set>
+', $xml);
+
+ }
+
+ /**
+ * @depends testSimple
+ */
+ function testSerializeAggregate() {
+
+ $prop = new SupportedPrivilegeSet(array(
+ 'privilege' => '{DAV:}all',
+ 'abstract' => true,
+ 'aggregates' => array(
+ array(
+ 'privilege' => '{DAV:}read',
+ ),
+ array(
+ 'privilege' => '{DAV:}write',
+ 'description' => 'booh',
+ ),
+ ),
+ ));
+
+ $doc = new \DOMDocument();
+ $root = $doc->createElementNS('DAV:', 'd:supported-privilege-set');
+
+ $doc->appendChild($root);
+
+ $server = new DAV\Server();
+ $prop->serialize($server, $root);
+
+ $xml = $doc->saveXML();
+
+ $this->assertEquals(
+'<?xml version="1.0"?>
+<d:supported-privilege-set xmlns:d="DAV:">' .
+'<d:supported-privilege>' .
+'<d:privilege>' .
+'<d:all/>' .
+'</d:privilege>' .
+'<d:abstract/>' .
+'<d:supported-privilege>' .
+'<d:privilege>' .
+'<d:read/>' .
+'</d:privilege>' .
+'</d:supported-privilege>' .
+'<d:supported-privilege>' .
+'<d:privilege>' .
+'<d:write/>' .
+'</d:privilege>' .
+'<d:description>booh</d:description>' .
+'</d:supported-privilege>' .
+'</d:supported-privilege>' .
+'</d:supported-privilege-set>
+', $xml);
+
+ }
+}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php
new file mode 100644
index 000000000..04ed5c330
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php
@@ -0,0 +1,322 @@
+<?php
+
+namespace Sabre\DAVACL;
+
+use Sabre\DAV;
+use Sabre\HTTP;
+
+
+require_once 'Sabre/DAVACL/MockPrincipal.php';
+require_once 'Sabre/DAVACL/MockACLNode.php';
+
+class SimplePluginTest extends \PHPUnit_Framework_TestCase {
+
+ function testValues() {
+
+ $aclPlugin = new Plugin();
+ $this->assertEquals('acl',$aclPlugin->getPluginName());
+ $this->assertEquals(
+ array('access-control', 'calendarserver-principal-property-search'),
+ $aclPlugin->getFeatures()
+ );
+
+ $this->assertEquals(
+ array(
+ '{DAV:}expand-property',
+ '{DAV:}principal-property-search',
+ '{DAV:}principal-search-property-set'
+ ),
+ $aclPlugin->getSupportedReportSet(''));
+
+ $this->assertEquals(array('ACL'), $aclPlugin->getMethods(''));
+
+ }
+
+ function testGetFlatPrivilegeSet() {
+
+ $expected = array(
+ '{DAV:}all' => array(
+ 'privilege' => '{DAV:}all',
+ 'abstract' => true,
+ 'aggregates' => array(
+ '{DAV:}read',
+ '{DAV:}write',
+ ),
+ 'concrete' => null,
+ ),
+ '{DAV:}read' => array(
+ 'privilege' => '{DAV:}read',
+ 'abstract' => false,
+ 'aggregates' => array(
+ '{DAV:}read-acl',
+ '{DAV:}read-current-user-privilege-set',
+ ),
+ 'concrete' => '{DAV:}read',
+ ),
+ '{DAV:}read-acl' => array(
+ 'privilege' => '{DAV:}read-acl',
+ 'abstract' => true,
+ 'aggregates' => array(),
+ 'concrete' => '{DAV:}read',
+ ),
+ '{DAV:}read-current-user-privilege-set' => array(
+ 'privilege' => '{DAV:}read-current-user-privilege-set',
+ 'abstract' => true,
+ 'aggregates' => array(),
+ 'concrete' => '{DAV:}read',
+ ),
+ '{DAV:}write' => array(
+ 'privilege' => '{DAV:}write',
+ 'abstract' => false,
+ 'aggregates' => array(
+ '{DAV:}write-acl',
+ '{DAV:}write-properties',
+ '{DAV:}write-content',
+ '{DAV:}bind',
+ '{DAV:}unbind',
+ '{DAV:}unlock',
+ ),
+ 'concrete' => '{DAV:}write',
+ ),
+ '{DAV:}write-acl' => array(
+ 'privilege' => '{DAV:}write-acl',
+ 'abstract' => true,
+ 'aggregates' => array(),
+ 'concrete' => '{DAV:}write',
+ ),
+ '{DAV:}write-properties' => array(
+ 'privilege' => '{DAV:}write-properties',
+ 'abstract' => true,
+ 'aggregates' => array(),
+ 'concrete' => '{DAV:}write',
+ ),
+ '{DAV:}write-content' => array(
+ 'privilege' => '{DAV:}write-content',
+ 'abstract' => true,
+ 'aggregates' => array(),
+ 'concrete' => '{DAV:}write',
+ ),
+ '{DAV:}unlock' => array(
+ 'privilege' => '{DAV:}unlock',
+ 'abstract' => true,
+ 'aggregates' => array(),
+ 'concrete' => '{DAV:}write',
+ ),
+ '{DAV:}bind' => array(
+ 'privilege' => '{DAV:}bind',
+ 'abstract' => true,
+ 'aggregates' => array(),
+ 'concrete' => '{DAV:}write',
+ ),
+ '{DAV:}unbind' => array(
+ 'privilege' => '{DAV:}unbind',
+ 'abstract' => true,
+ 'aggregates' => array(),
+ 'concrete' => '{DAV:}write',
+ ),
+
+ );
+
+ $plugin = new Plugin();
+ $server = new DAV\Server();
+ $server->addPlugin($plugin);
+ $this->assertEquals($expected, $plugin->getFlatPrivilegeSet(''));
+
+ }
+
+ function testCurrentUserPrincipalsNotLoggedIn() {
+
+ $acl = new Plugin();
+ $server = new DAV\Server();
+ $server->addPlugin($acl);
+
+ $this->assertEquals(array(),$acl->getCurrentUserPrincipals());
+
+ }
+
+ function testCurrentUserPrincipalsSimple() {
+
+ $tree = array(
+
+ new DAV\SimpleCollection('principals', array(
+ new MockPrincipal('admin','principals/admin'),
+ ))
+
+ );
+
+ $acl = new Plugin();
+ $server = new DAV\Server($tree);
+ $server->addPlugin($acl);
+
+ $auth = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'SabreDAV');
+ $server->addPlugin($auth);
+
+ //forcing login
+ $auth->beforeMethod('GET','/');
+
+ $this->assertEquals(array('principals/admin'),$acl->getCurrentUserPrincipals());
+
+ }
+
+ function testCurrentUserPrincipalsGroups() {
+
+ $tree = array(
+
+ 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')),
+ ))
+
+ );
+
+ $acl = new Plugin();
+ $server = new DAV\Server($tree);
+ $server->addPlugin($acl);
+
+ $auth = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'SabreDAV');
+ $server->addPlugin($auth);
+
+ //forcing login
+ $auth->beforeMethod('GET','/');
+
+ $expected = array(
+ 'principals/admin',
+ 'principals/administrators',
+ 'principals/everyone',
+ 'principals/groups',
+ );
+
+ $this->assertEquals($expected,$acl->getCurrentUserPrincipals());
+
+ // The second one should trigger the cache and be identical
+ $this->assertEquals($expected,$acl->getCurrentUserPrincipals());
+
+ }
+
+ function testGetACL() {
+
+ $acl = array(
+ array(
+ 'principal' => 'principals/admin',
+ 'privilege' => '{DAV:}read',
+ ),
+ array(
+ 'principal' => 'principals/admin',
+ 'privilege' => '{DAV:}write',
+ ),
+ );
+
+
+ $tree = array(
+ new MockACLNode('foo',$acl),
+ );
+
+ $server = new DAV\Server($tree);
+ $aclPlugin = new Plugin();
+ $server->addPlugin($aclPlugin);
+
+ $this->assertEquals($acl,$aclPlugin->getACL('foo'));
+
+ }
+
+ function testGetCurrentUserPrivilegeSet() {
+
+ $acl = array(
+ array(
+ '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),
+
+ new DAV\SimpleCollection('principals', array(
+ new MockPrincipal('admin','principals/admin'),
+ )),
+
+ );
+
+ $server = new DAV\Server($tree);
+ $aclPlugin = new Plugin();
+ $server->addPlugin($aclPlugin);
+
+ $auth = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'SabreDAV');
+ $server->addPlugin($auth);
+
+ //forcing login
+ $auth->beforeMethod('GET','/');
+
+ $expected = array(
+ '{DAV:}write',
+ '{DAV:}write-acl',
+ '{DAV:}write-properties',
+ '{DAV:}write-content',
+ '{DAV:}bind',
+ '{DAV:}unbind',
+ '{DAV:}unlock',
+ '{DAV:}read',
+ '{DAV:}read-acl',
+ '{DAV:}read-current-user-privilege-set',
+ );
+
+ $this->assertEquals($expected,$aclPlugin->getCurrentUserPrivilegeSet('foo'));
+
+ }
+
+ function testCheckPrivileges() {
+
+ $acl = array(
+ array(
+ '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),
+
+ new DAV\SimpleCollection('principals', array(
+ new MockPrincipal('admin','principals/admin'),
+ )),
+
+ );
+
+ $server = new DAV\Server($tree);
+ $aclPlugin = new Plugin();
+ $server->addPlugin($aclPlugin);
+
+ $auth = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'SabreDAV');
+ $server->addPlugin($auth);
+
+ //forcing login
+ //$auth->beforeMethod('GET','/');
+
+ $this->assertFalse($aclPlugin->checkPrivileges('foo', array('{DAV:}read'), Plugin::R_PARENT, false));
+
+ }
+}
+
+
+
+
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/VersionTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/VersionTest.php
new file mode 100644
index 000000000..c432527dc
--- /dev/null
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/VersionTest.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace Sabre\DAVACL;
+
+class VersionTest extends \PHPUnit_Framework_TestCase {
+
+ function testString() {
+
+ $v = Version::VERSION;
+ $this->assertEquals(-1, version_compare('1.0.0',$v));
+
+ $s = Version::STABILITY;
+ $this->assertTrue($s == 'alpha' || $s == 'beta' || $s =='stable');
+
+ }
+
+}