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.php311
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php120
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php180
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php37
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php47
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php37
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php37
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php37
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php308
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php49
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php58
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php76
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php399
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php111
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php219
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php158
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php10
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php10
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php55
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php389
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php135
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php192
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php302
23 files changed, 0 insertions, 3277 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php
deleted file mode 100644
index 715559df3..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php
+++ /dev/null
@@ -1,311 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL;
-
-use Sabre\DAV;
-use Sabre\HTTP;
-
-class ACLMethodTest extends \PHPUnit\Framework\TestCase
-{
- public function testCallback()
- {
- $this->expectException('Sabre\DAV\Exception\BadRequest');
- $acl = new Plugin();
- $server = new DAV\Server();
- $server->addPlugin(new DAV\Auth\Plugin());
- $server->addPlugin($acl);
-
- $acl->httpAcl($server->httpRequest, $server->httpResponse);
- }
-
- /**
- /**
- */
- public function testNotSupportedByNode()
- {
- $this->expectException('Sabre\DAV\Exception\MethodNotAllowed');
- $tree = [
- new DAV\SimpleCollection('test'),
- ];
- $acl = new Plugin();
- $server = new DAV\Server($tree);
- $server->httpRequest = new HTTP\Request('GET', '/');
- $body = '<?xml version="1.0"?>
-<d:acl xmlns:d="DAV:">
-</d:acl>';
- $server->httpRequest->setBody($body);
- $server->addPlugin(new DAV\Auth\Plugin());
- $server->addPlugin($acl);
-
- $acl->httpACL($server->httpRequest, $server->httpResponse);
- }
-
- public function testSuccessSimple()
- {
- $tree = [
- new MockACLNode('test', []),
- ];
- $acl = new Plugin();
- $server = new DAV\Server($tree);
- $server->httpRequest = new HTTP\Request('GET', '/');
- $server->httpRequest->setUrl('/test');
-
- $body = '<?xml version="1.0"?>
-<d:acl xmlns:d="DAV:">
-</d:acl>';
- $server->httpRequest->setBody($body);
- $server->addPlugin(new DAV\Auth\Plugin());
- $server->addPlugin($acl);
-
- $this->assertFalse($acl->httpACL($server->httpRequest, $server->httpResponse));
- }
-
- public function testUnrecognizedPrincipal()
- {
- $this->expectException('Sabre\DAVACL\Exception\NotRecognizedPrincipal');
- $tree = [
- new MockACLNode('test', []),
- ];
- $acl = new Plugin();
- $server = new DAV\Server($tree);
- $server->httpRequest = new HTTP\Request('ACL', '/test');
- $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(new DAV\Auth\Plugin());
- $server->addPlugin($acl);
-
- $acl->httpACL($server->httpRequest, $server->httpResponse);
- }
-
- public function testUnrecognizedPrincipal2()
- {
- $this->expectException('Sabre\DAVACL\Exception\NotRecognizedPrincipal');
- $tree = [
- new MockACLNode('test', []),
- new DAV\SimpleCollection('principals', [
- new DAV\SimpleCollection('notaprincipal'),
- ]),
- ];
- $acl = new Plugin();
- $server = new DAV\Server($tree);
- $server->httpRequest = new HTTP\Request('ACL', '/test');
- $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(new DAV\Auth\Plugin());
- $server->addPlugin($acl);
-
- $acl->httpACL($server->httpRequest, $server->httpResponse);
- }
-
- public function testUnknownPrivilege()
- {
- $this->expectException('Sabre\DAVACL\Exception\NotSupportedPrivilege');
- $tree = [
- new MockACLNode('test', []),
- ];
- $acl = new Plugin();
- $server = new DAV\Server($tree);
- $server->httpRequest = new HTTP\Request('ACL', '/test');
- $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(new DAV\Auth\Plugin());
- $server->addPlugin($acl);
-
- $acl->httpACL($server->httpRequest, $server->httpResponse);
- }
-
- public function testAbstractPrivilege()
- {
- $this->expectException('Sabre\DAVACL\Exception\NoAbstract');
- $tree = [
- new MockACLNode('test', []),
- ];
- $acl = new Plugin();
- $server = new DAV\Server($tree);
- $server->on('getSupportedPrivilegeSet', function ($node, &$supportedPrivilegeSet) {
- $supportedPrivilegeSet['{DAV:}foo'] = ['abstract' => true];
- });
- $server->httpRequest = new HTTP\Request('ACL', '/test');
- $body = '<?xml version="1.0"?>
-<d:acl xmlns:d="DAV:">
- <d:ace>
- <d:grant><d:privilege><d:foo /></d:privilege></d:grant>
- <d:principal><d:href>/principals/foo/</d:href></d:principal>
- </d:ace>
-</d:acl>';
- $server->httpRequest->setBody($body);
- $server->addPlugin(new DAV\Auth\Plugin());
- $server->addPlugin($acl);
-
- $acl->httpACL($server->httpRequest, $server->httpResponse);
- }
-
- public function testUpdateProtectedPrivilege()
- {
- $this->expectException('Sabre\DAVACL\Exception\AceConflict');
- $oldACL = [
- [
- 'principal' => 'principals/notfound',
- 'privilege' => '{DAV:}write',
- 'protected' => true,
- ],
- ];
-
- $tree = [
- new MockACLNode('test', $oldACL),
- ];
- $acl = new Plugin();
- $server = new DAV\Server($tree);
- $server->httpRequest = new HTTP\Request('ACL', '/test');
- $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(new DAV\Auth\Plugin());
- $server->addPlugin($acl);
-
- $acl->httpACL($server->httpRequest, $server->httpResponse);
- }
-
- public function testUpdateProtectedPrivilege2()
- {
- $this->expectException('Sabre\DAVACL\Exception\AceConflict');
- $oldACL = [
- [
- 'principal' => 'principals/notfound',
- 'privilege' => '{DAV:}write',
- 'protected' => true,
- ],
- ];
-
- $tree = [
- new MockACLNode('test', $oldACL),
- ];
- $acl = new Plugin();
- $server = new DAV\Server($tree);
- $server->httpRequest = new HTTP\Request('ACL', '/test');
- $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(new DAV\Auth\Plugin());
- $server->addPlugin($acl);
-
- $acl->httpACL($server->httpRequest, $server->httpResponse);
- }
-
- public function testUpdateProtectedPrivilege3()
- {
- $this->expectException('Sabre\DAVACL\Exception\AceConflict');
- $oldACL = [
- [
- 'principal' => 'principals/notfound',
- 'privilege' => '{DAV:}write',
- 'protected' => true,
- ],
- ];
-
- $tree = [
- new MockACLNode('test', $oldACL),
- ];
- $acl = new Plugin();
- $server = new DAV\Server($tree);
- $server->httpRequest = new HTTP\Request('ACL', '/test');
- $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(new DAV\Auth\Plugin());
- $server->addPlugin($acl);
-
- $acl->httpACL($server->httpRequest, $server->httpResponse);
- }
-
- public function testSuccessComplex()
- {
- $oldACL = [
- [
- 'principal' => 'principals/foo',
- 'privilege' => '{DAV:}write',
- 'protected' => true,
- ],
- [
- 'principal' => 'principals/bar',
- 'privilege' => '{DAV:}read',
- ],
- ];
-
- $tree = [
- $node = new MockACLNode('test', $oldACL),
- new DAV\SimpleCollection('principals', [
- new MockPrincipal('foo', 'principals/foo'),
- new MockPrincipal('baz', 'principals/baz'),
- ]),
- ];
- $acl = new Plugin();
- $server = new DAV\Server($tree);
- $server->httpRequest = new HTTP\Request('ACL', '/test');
- $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(new DAV\Auth\Plugin());
- $server->addPlugin($acl);
-
- $this->assertFalse($acl->httpAcl($server->httpRequest, $server->httpResponse));
-
- $this->assertEquals([
- [
- 'principal' => 'principals/foo',
- 'privilege' => '{DAV:}write',
- 'protected' => true,
- ],
- [
- '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
deleted file mode 100644
index 04dd29c04..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php
+++ /dev/null
@@ -1,120 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL;
-
-use Sabre\DAV;
-
-class AllowAccessTest extends \PHPUnit\Framework\TestCase
-{
- /**
- * @var DAV\Server
- */
- protected $server;
-
- public function setup(): void
- {
- $nodes = [
- new DAV\Mock\Collection('testdir', [
- 'file1.txt' => 'contents',
- ]),
- ];
-
- $this->server = new DAV\Server($nodes);
- $this->server->addPlugin(
- new DAV\Auth\Plugin(
- new DAV\Auth\Backend\Mock()
- )
- );
- // Login
- $this->server->getPlugin('auth')->beforeMethod(
- new \Sabre\HTTP\Request('GET', '/'),
- new \Sabre\HTTP\Response()
- );
- $aclPlugin = new Plugin();
- $this->server->addPlugin($aclPlugin);
- }
-
- public function testGet()
- {
- $this->server->httpRequest->setMethod('GET');
- $this->server->httpRequest->setUrl('/testdir');
-
- $this->assertTrue($this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]));
- }
-
- public function testGetDoesntExist()
- {
- $this->server->httpRequest->setMethod('GET');
- $this->server->httpRequest->setUrl('/foo');
-
- $this->assertTrue($this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]));
- }
-
- public function testHEAD()
- {
- $this->server->httpRequest->setMethod('HEAD');
- $this->server->httpRequest->setUrl('/testdir');
-
- $this->assertTrue($this->server->emit('beforeMethod:HEAD', [$this->server->httpRequest, $this->server->httpResponse]));
- }
-
- public function testOPTIONS()
- {
- $this->server->httpRequest->setMethod('OPTIONS');
- $this->server->httpRequest->setUrl('/testdir');
-
- $this->assertTrue($this->server->emit('beforeMethod:OPTIONS', [$this->server->httpRequest, $this->server->httpResponse]));
- }
-
- public function testPUT()
- {
- $this->server->httpRequest->setMethod('PUT');
- $this->server->httpRequest->setUrl('/testdir/file1.txt');
-
- $this->assertTrue($this->server->emit('beforeMethod:PUT', [$this->server->httpRequest, $this->server->httpResponse]));
- }
-
- public function testPROPPATCH()
- {
- $this->server->httpRequest->setMethod('PROPPATCH');
- $this->server->httpRequest->setUrl('/testdir');
-
- $this->assertTrue($this->server->emit('beforeMethod:PROPPATCH', [$this->server->httpRequest, $this->server->httpResponse]));
- }
-
- public function testCOPY()
- {
- $this->server->httpRequest->setMethod('COPY');
- $this->server->httpRequest->setUrl('/testdir');
-
- $this->assertTrue($this->server->emit('beforeMethod:COPY', [$this->server->httpRequest, $this->server->httpResponse]));
- }
-
- public function testMOVE()
- {
- $this->server->httpRequest->setMethod('MOVE');
- $this->server->httpRequest->setUrl('/testdir');
-
- $this->assertTrue($this->server->emit('beforeMethod:MOVE', [$this->server->httpRequest, $this->server->httpResponse]));
- }
-
- public function testLOCK()
- {
- $this->server->httpRequest->setMethod('LOCK');
- $this->server->httpRequest->setUrl('/testdir');
-
- $this->assertTrue($this->server->emit('beforeMethod:LOCK', [$this->server->httpRequest, $this->server->httpResponse]));
- }
-
- public function testBeforeBind()
- {
- $this->assertTrue($this->server->emit('beforeBind', ['testdir/file']));
- }
-
- public function testBeforeUnbind()
- {
- $this->assertTrue($this->server->emit('beforeUnbind', ['testdir']));
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php
deleted file mode 100644
index 566167ef0..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php
+++ /dev/null
@@ -1,180 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL;
-
-use Sabre\DAV;
-
-class BlockAccessTest extends \PHPUnit\Framework\TestCase
-{
- /**
- * @var DAV\Server
- */
- protected $server;
- protected $plugin;
-
- public function setup(): void
- {
- $nodes = [
- new DAV\SimpleCollection('testdir'),
- ];
-
- $this->server = new DAV\Server($nodes);
- $this->plugin = new Plugin();
- $this->plugin->setDefaultAcl([]);
- $this->server->addPlugin(
- new DAV\Auth\Plugin(
- new DAV\Auth\Backend\Mock()
- )
- );
- // Login
- $this->server->getPlugin('auth')->beforeMethod(
- new \Sabre\HTTP\Request('GET', '/'),
- new \Sabre\HTTP\Response()
- );
- $this->server->addPlugin($this->plugin);
- }
-
- public function testGet()
- {
- $this->expectException('Sabre\DAVACL\Exception\NeedPrivileges');
- $this->server->httpRequest->setMethod('GET');
- $this->server->httpRequest->setUrl('/testdir');
-
- $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]);
- }
-
- public function testGetDoesntExist()
- {
- $this->server->httpRequest->setMethod('GET');
- $this->server->httpRequest->setUrl('/foo');
-
- $r = $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]);
- $this->assertTrue($r);
- }
-
- public function testHEAD()
- {
- $this->expectException('Sabre\DAVACL\Exception\NeedPrivileges');
- $this->server->httpRequest->setMethod('HEAD');
- $this->server->httpRequest->setUrl('/testdir');
-
- $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]);
- }
-
- public function testOPTIONS()
- {
- $this->expectException('Sabre\DAVACL\Exception\NeedPrivileges');
- $this->server->httpRequest->setMethod('OPTIONS');
- $this->server->httpRequest->setUrl('/testdir');
-
- $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]);
- }
-
- public function testPUT()
- {
- $this->expectException('Sabre\DAVACL\Exception\NeedPrivileges');
- $this->server->httpRequest->setMethod('PUT');
- $this->server->httpRequest->setUrl('/testdir');
-
- $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]);
- }
-
- public function testPROPPATCH()
- {
- $this->expectException('Sabre\DAVACL\Exception\NeedPrivileges');
- $this->server->httpRequest->setMethod('PROPPATCH');
- $this->server->httpRequest->setUrl('/testdir');
-
- $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]);
- }
-
- public function testCOPY()
- {
- $this->expectException('Sabre\DAVACL\Exception\NeedPrivileges');
- $this->server->httpRequest->setMethod('COPY');
- $this->server->httpRequest->setUrl('/testdir');
-
- $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]);
- }
-
- public function testMOVE()
- {
- $this->expectException('Sabre\DAVACL\Exception\NeedPrivileges');
- $this->server->httpRequest->setMethod('MOVE');
- $this->server->httpRequest->setUrl('/testdir');
-
- $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]);
- }
-
- public function testACL()
- {
- $this->expectException('Sabre\DAVACL\Exception\NeedPrivileges');
- $this->server->httpRequest->setMethod('ACL');
- $this->server->httpRequest->setUrl('/testdir');
-
- $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]);
- }
-
- public function testLOCK()
- {
- $this->expectException('Sabre\DAVACL\Exception\NeedPrivileges');
- $this->server->httpRequest->setMethod('LOCK');
- $this->server->httpRequest->setUrl('/testdir');
-
- $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]);
- }
-
- public function testBeforeBind()
- {
- $this->expectException('Sabre\DAVACL\Exception\NeedPrivileges');
- $this->server->emit('beforeBind', ['testdir/file']);
- }
-
- public function testBeforeUnbind()
- {
- $this->expectException('Sabre\DAVACL\Exception\NeedPrivileges');
- $this->server->emit('beforeUnbind', ['testdir']);
- }
-
- public function testPropFind()
- {
- $propFind = new DAV\PropFind('testdir', [
- '{DAV:}displayname',
- '{DAV:}getcontentlength',
- '{DAV:}bar',
- '{DAV:}owner',
- ]);
-
- $r = $this->server->emit('propFind', [$propFind, new DAV\SimpleCollection('testdir')]);
- $this->assertTrue($r);
-
- $expected = [
- 200 => [],
- 404 => [],
- 403 => [
- '{DAV:}displayname' => null,
- '{DAV:}getcontentlength' => null,
- '{DAV:}bar' => null,
- '{DAV:}owner' => null,
- ],
- ];
-
- $this->assertEquals($expected, $propFind->getResultForMultiStatus());
- }
-
- public function testBeforeGetPropertiesNoListing()
- {
- $this->plugin->hideNodesFromListings = true;
- $propFind = new DAV\PropFind('testdir', [
- '{DAV:}displayname',
- '{DAV:}getcontentlength',
- '{DAV:}bar',
- '{DAV:}owner',
- ]);
-
- $r = $this->server->emit('propFind', [$propFind, new DAV\SimpleCollection('testdir')]);
- $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
deleted file mode 100644
index 60fb8f3e8..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL\Exception;
-
-use Sabre\DAV;
-
-class AceConflictTest extends \PHPUnit\Framework\TestCase
-{
- public 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 = [
- '/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
deleted file mode 100644
index f08e536b5..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL\Exception;
-
-use Sabre\DAV;
-
-class NeedPrivilegesExceptionTest extends \PHPUnit\Framework\TestCase
-{
- public function testSerialize()
- {
- $uri = 'foo';
- $privileges = [
- '{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 = [
- '/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
deleted file mode 100644
index 38e9d8b93..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL\Exception;
-
-use Sabre\DAV;
-
-class NoAbstractTest extends \PHPUnit\Framework\TestCase
-{
- public 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 = [
- '/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
deleted file mode 100644
index 62915ea1d..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL\Exception;
-
-use Sabre\DAV;
-
-class NotRecognizedPrincipalTest extends \PHPUnit\Framework\TestCase
-{
- public 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 = [
- '/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
deleted file mode 100644
index 668c713d2..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL\Exception;
-
-use Sabre\DAV;
-
-class NotSupportedPrivilegeTest extends \PHPUnit\Framework\TestCase
-{
- public 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 = [
- '/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
deleted file mode 100644
index 8afe6d30f..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php
+++ /dev/null
@@ -1,308 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL;
-
-use Sabre\DAV;
-use Sabre\HTTP;
-
-class ExpandPropertiesTest extends \PHPUnit\Framework\TestCase
-{
- public function getServer()
- {
- $tree = [
- new DAV\Mock\PropertiesCollection('node1', [], [
- '{http://sabredav.org/ns}simple' => 'foo',
- '{http://sabredav.org/ns}href' => new DAV\Xml\Property\Href('node2'),
- '{DAV:}displayname' => 'Node 1',
- ]),
- new DAV\Mock\PropertiesCollection('node2', [], [
- '{http://sabredav.org/ns}simple' => 'simple',
- '{http://sabredav.org/ns}hreflist' => new DAV\Xml\Property\Href(['node1', 'node3']),
- '{DAV:}displayname' => 'Node 2',
- ]),
- new DAV\Mock\PropertiesCollection('node3', [], [
- '{http://sabredav.org/ns}simple' => 'simple',
- '{DAV:}displayname' => 'Node 3',
- ]),
- ];
-
- $fakeServer = new DAV\Server($tree);
- $fakeServer->sapi = new HTTP\SapiMock();
- $fakeServer->debugExceptions = true;
- $fakeServer->httpResponse = new HTTP\ResponseMock();
- $plugin = new Plugin();
- $plugin->allowUnauthenticatedAccess = false;
- // Anyone can do anything
- $plugin->setDefaultACL([
- [
- 'principal' => '{DAV:}all',
- 'privilege' => '{DAV:}all',
- ],
- ]);
- $this->assertTrue($plugin instanceof Plugin);
-
- $fakeServer->addPlugin($plugin);
- $this->assertEquals($plugin, $fakeServer->getPlugin('acl'));
-
- return $fakeServer;
- }
-
- public 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 = [
- 'REQUEST_METHOD' => 'REPORT',
- 'HTTP_DEPTH' => '0',
- 'REQUEST_URI' => '/node1',
- ];
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody($xml);
-
- $server = $this->getServer();
- $server->httpRequest = $request;
-
- $server->exec();
-
- $this->assertEquals(207, $server->httpResponse->status, 'Incorrect status code received. Full body: '.$server->httpResponse->getBodyAsString());
- $this->assertEquals([
- 'X-Sabre-Version' => [DAV\Version::VERSION],
- 'Content-Type' => ['application/xml; charset=utf-8'],
- ], $server->httpResponse->getHeaders());
-
- $check = [
- '/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->getBodyAsString());
- $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->getBodyAsString());
- }
- }
-
- /**
- * @depends testSimple
- */
- public 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 = [
- 'REQUEST_METHOD' => 'REPORT',
- 'HTTP_DEPTH' => '0',
- 'REQUEST_URI' => '/node1',
- ];
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody($xml);
-
- $server = $this->getServer();
- $server->httpRequest = $request;
-
- $server->exec();
-
- $this->assertEquals(207, $server->httpResponse->status, 'Incorrect response status received. Full response body: '.$server->httpResponse->getBodyAsString());
- $this->assertEquals([
- 'X-Sabre-Version' => [DAV\Version::VERSION],
- 'Content-Type' => ['application/xml; charset=utf-8'],
- ], $server->httpResponse->getHeaders());
-
- $check = [
- '/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->getBodyAsString());
- $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->getBodyAsString());
- }
- }
-
- /**
- * @depends testSimple
- */
- public 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 = [
- 'REQUEST_METHOD' => 'REPORT',
- 'HTTP_DEPTH' => '0',
- 'REQUEST_URI' => '/node2',
- ];
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody($xml);
-
- $server = $this->getServer();
- $server->httpRequest = $request;
-
- $server->exec();
-
- $this->assertEquals(207, $server->httpResponse->status);
- $this->assertEquals([
- 'X-Sabre-Version' => [DAV\Version::VERSION],
- 'Content-Type' => ['application/xml; charset=utf-8'],
- ], $server->httpResponse->getHeaders());
-
- $check = [
- '/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->getBodyAsString());
- $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
- */
- public 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 = [
- 'REQUEST_METHOD' => 'REPORT',
- 'HTTP_DEPTH' => '0',
- 'REQUEST_URI' => '/node2',
- ];
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody($xml);
-
- $server = $this->getServer();
- $server->httpRequest = $request;
-
- $server->exec();
-
- $this->assertEquals(207, $server->httpResponse->status);
- $this->assertEquals([
- 'X-Sabre-Version' => [DAV\Version::VERSION],
- 'Content-Type' => ['application/xml; charset=utf-8'],
- ], $server->httpResponse->getHeaders());
-
- $check = [
- '/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->getBodyAsString());
- $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));
- }
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php b/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php
deleted file mode 100644
index 51411f304..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL;
-
-use Sabre\DAV;
-
-class MockACLNode extends DAV\Node implements IACL
-{
- public $name;
- public $acl;
-
- public function __construct($name, array $acl = [])
- {
- $this->name = $name;
- $this->acl = $acl;
- }
-
- public function getName()
- {
- return $this->name;
- }
-
- public function getOwner()
- {
- return null;
- }
-
- public function getGroup()
- {
- return null;
- }
-
- public function getACL()
- {
- return $this->acl;
- }
-
- public function setACL(array $acl)
- {
- $this->acl = $acl;
- }
-
- public function getSupportedPrivilegeSet()
- {
- return null;
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php b/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php
deleted file mode 100644
index f67025c5a..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL;
-
-use Sabre\DAV;
-
-class MockPrincipal extends DAV\Node implements IPrincipal
-{
- public $name;
- public $principalUrl;
- public $groupMembership = [];
- public $groupMemberSet = [];
-
- public function __construct($name, $principalUrl, array $groupMembership = [], array $groupMemberSet = [])
- {
- $this->name = $name;
- $this->principalUrl = $principalUrl;
- $this->groupMembership = $groupMembership;
- $this->groupMemberSet = $groupMemberSet;
- }
-
- public function getName()
- {
- return $this->name;
- }
-
- public function getDisplayName()
- {
- return $this->getName();
- }
-
- public function getAlternateUriSet()
- {
- return [];
- }
-
- public function getPrincipalUrl()
- {
- return $this->principalUrl;
- }
-
- public function getGroupMemberSet()
- {
- return $this->groupMemberSet;
- }
-
- public function getGroupMemberShip()
- {
- return $this->groupMembership;
- }
-
- public 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
deleted file mode 100644
index 048b9f249..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL;
-
-use Sabre\DAV;
-use Sabre\HTTP;
-
-class PluginAdminTest extends \PHPUnit\Framework\TestCase
-{
- public $server;
-
- public function setup(): void
- {
- $principalBackend = new PrincipalBackend\Mock();
-
- $tree = [
- new MockACLNode('adminonly', []),
- new PrincipalCollection($principalBackend),
- ];
-
- $this->server = new DAV\Server($tree);
- $this->server->sapi = new HTTP\SapiMock();
- $plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock());
- $this->server->addPlugin($plugin);
- }
-
- public function testNoAdminAccess()
- {
- $plugin = new Plugin();
- $this->server->addPlugin($plugin);
-
- $request = HTTP\Sapi::createFromServerArray([
- 'REQUEST_METHOD' => 'OPTIONS',
- 'HTTP_DEPTH' => 1,
- 'REQUEST_URI' => '/adminonly',
- ]);
-
- $response = new HTTP\ResponseMock();
-
- $this->server->httpRequest = $request;
- $this->server->httpResponse = $response;
-
- $this->server->exec();
-
- $this->assertEquals(403, $response->status);
- }
-
- /**
- * @depends testNoAdminAccess
- */
- public function testAdminAccess()
- {
- $plugin = new Plugin();
- $plugin->adminPrincipals = [
- 'principals/admin',
- ];
- $this->server->addPlugin($plugin);
-
- $request = HTTP\Sapi::createFromServerArray([
- 'REQUEST_METHOD' => 'OPTIONS',
- 'HTTP_DEPTH' => 1,
- 'REQUEST_URI' => '/adminonly',
- ]);
-
- $response = new HTTP\ResponseMock();
-
- $this->server->httpRequest = $request;
- $this->server->httpResponse = $response;
-
- $this->server->exec();
-
- $this->assertEquals(200, $response->status);
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php
deleted file mode 100644
index 16d3e781e..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php
+++ /dev/null
@@ -1,399 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL;
-
-use Sabre\DAV;
-use Sabre\HTTP;
-
-class PluginPropertiesTest extends \PHPUnit\Framework\TestCase
-{
- public function testPrincipalCollectionSet()
- {
- $plugin = new Plugin();
- $plugin->allowUnauthenticatedAccess = false;
- $plugin->setDefaultACL([
- [
- 'principal' => '{DAV:}all',
- 'privilege' => '{DAV:}all',
- ],
- ]);
- //Anyone can do anything
- $plugin->principalCollectionSet = [
- 'principals1',
- 'principals2',
- ];
-
- $requestedProperties = [
- '{DAV:}principal-collection-set',
- ];
-
- $server = new DAV\Server(new DAV\SimpleCollection('root'));
- $server->addPlugin($plugin);
-
- $result = $server->getPropertiesForPath('', $requestedProperties);
- $result = $result[0];
-
- $this->assertEquals(1, count($result[200]));
- $this->assertArrayHasKey('{DAV:}principal-collection-set', $result[200]);
- $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}principal-collection-set']);
-
- $expected = [
- 'principals1/',
- 'principals2/',
- ];
-
- $this->assertEquals($expected, $result[200]['{DAV:}principal-collection-set']->getHrefs());
- }
-
- public function testCurrentUserPrincipal()
- {
- $fakeServer = new DAV\Server();
- $plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock());
- $fakeServer->addPlugin($plugin);
- $plugin = new Plugin();
- $plugin->setDefaultACL([
- [
- 'principal' => '{DAV:}all',
- 'privilege' => '{DAV:}all',
- ],
- ]);
- $fakeServer->addPlugin($plugin);
-
- $requestedProperties = [
- '{DAV:}current-user-principal',
- ];
-
- $result = $fakeServer->getPropertiesForPath('', $requestedProperties);
- $result = $result[0];
-
- $this->assertEquals(1, count($result[200]));
- $this->assertArrayHasKey('{DAV:}current-user-principal', $result[200]);
- $this->assertInstanceOf('Sabre\DAVACL\Xml\Property\Principal', $result[200]['{DAV:}current-user-principal']);
- $this->assertEquals(Xml\Property\Principal::UNAUTHENTICATED, $result[200]['{DAV:}current-user-principal']->getType());
-
- // This will force the login
- $fakeServer->emit('beforeMethod:PROPFIND', [$fakeServer->httpRequest, $fakeServer->httpResponse]);
-
- $result = $fakeServer->getPropertiesForPath('', $requestedProperties);
- $result = $result[0];
-
- $this->assertEquals(1, count($result[200]));
- $this->assertArrayHasKey('{DAV:}current-user-principal', $result[200]);
- $this->assertInstanceOf('Sabre\DAVACL\Xml\Property\Principal', $result[200]['{DAV:}current-user-principal']);
- $this->assertEquals(Xml\Property\Principal::HREF, $result[200]['{DAV:}current-user-principal']->getType());
- $this->assertEquals('principals/admin/', $result[200]['{DAV:}current-user-principal']->getHref());
- }
-
- public function testSupportedPrivilegeSet()
- {
- $plugin = new Plugin();
- $plugin->allowUnauthenticatedAccess = false;
- $plugin->setDefaultACL([
- [
- 'principal' => '{DAV:}all',
- 'privilege' => '{DAV:}all',
- ],
- ]);
- $server = new DAV\Server();
- $server->addPlugin($plugin);
-
- $requestedProperties = [
- '{DAV:}supported-privilege-set',
- ];
-
- $result = $server->getPropertiesForPath('', $requestedProperties);
- $result = $result[0];
-
- $this->assertEquals(1, count($result[200]));
- $this->assertArrayHasKey('{DAV:}supported-privilege-set', $result[200]);
- $this->assertInstanceOf('Sabre\\DAVACL\\Xml\\Property\\SupportedPrivilegeSet', $result[200]['{DAV:}supported-privilege-set']);
-
- $server = new DAV\Server();
-
- $prop = $result[200]['{DAV:}supported-privilege-set'];
- $result = $server->xml->write('{DAV:}root', $prop);
-
- $xpaths = [
- '/d:root' => 1,
- '/d:root/d:supported-privilege' => 1,
- '/d:root/d:supported-privilege/d:privilege' => 1,
- '/d:root/d:supported-privilege/d:privilege/d:all' => 1,
- '/d:root/d:supported-privilege/d:abstract' => 0,
- '/d:root/d:supported-privilege/d:supported-privilege' => 2,
- '/d:root/d:supported-privilege/d:supported-privilege/d:privilege' => 2,
- '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:read' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:write' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege' => 7,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege' => 7,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-acl' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-current-user-privilege-set' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-content' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-properties' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:bind' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unbind' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unlock' => 1,
- '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:abstract' => 0,
- ];
-
- // reloading because php dom sucks
- $dom2 = new \DOMDocument('1.0', 'utf-8');
- $dom2->loadXML($result);
-
- $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.' Full XML: '.$result);
- }
- }
-
- public function testACL()
- {
- $plugin = new Plugin();
- $plugin->allowUnauthenticatedAccess = false;
- $plugin->setDefaultACL([
- [
- 'principal' => '{DAV:}all',
- 'privilege' => '{DAV:}all',
- ],
- ]);
-
- $nodes = [
- new MockACLNode('foo', [
- [
- 'principal' => 'principals/admin',
- 'privilege' => '{DAV:}read',
- ],
- ]),
- new DAV\SimpleCollection('principals', [
- $principal = new MockPrincipal('admin', 'principals/admin'),
- ]),
- ];
-
- $server = new DAV\Server($nodes);
- $server->addPlugin($plugin);
- $authPlugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock());
- $server->addPlugin($authPlugin);
-
- // Force login
- $authPlugin->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response());
-
- $requestedProperties = [
- '{DAV:}acl',
- ];
-
- $result = $server->getPropertiesForPath('foo', $requestedProperties);
- $result = $result[0];
-
- $this->assertEquals(1, count($result[200]), 'The {DAV:}acl property did not return from the list. Full list: '.print_r($result, true));
- $this->assertArrayHasKey('{DAV:}acl', $result[200]);
- $this->assertInstanceOf('Sabre\\DAVACL\\Xml\Property\\Acl', $result[200]['{DAV:}acl']);
- }
-
- public function testACLRestrictions()
- {
- $plugin = new Plugin();
- $plugin->allowUnauthenticatedAccess = false;
-
- $nodes = [
- new MockACLNode('foo', [
- [
- 'principal' => 'principals/admin',
- 'privilege' => '{DAV:}read',
- ],
- ]),
- new DAV\SimpleCollection('principals', [
- $principal = new MockPrincipal('admin', 'principals/admin'),
- ]),
- ];
-
- $server = new DAV\Server($nodes);
- $server->addPlugin($plugin);
- $authPlugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock());
- $server->addPlugin($authPlugin);
-
- // Force login
- $authPlugin->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response());
-
- $requestedProperties = [
- '{DAV:}acl-restrictions',
- ];
-
- $result = $server->getPropertiesForPath('foo', $requestedProperties);
- $result = $result[0];
-
- $this->assertEquals(1, count($result[200]), 'The {DAV:}acl-restrictions property did not return from the list. Full list: '.print_r($result, true));
- $this->assertArrayHasKey('{DAV:}acl-restrictions', $result[200]);
- $this->assertInstanceOf('Sabre\\DAVACL\\Xml\\Property\\AclRestrictions', $result[200]['{DAV:}acl-restrictions']);
- }
-
- public function testAlternateUriSet()
- {
- $tree = [
- new DAV\SimpleCollection('principals', [
- $principal = new MockPrincipal('user', 'principals/user'),
- ]),
- ];
-
- $fakeServer = new DAV\Server($tree);
- //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend())
- //$fakeServer->addPlugin($plugin);
- $plugin = new Plugin();
- $plugin->allowUnauthenticatedAccess = false;
- $plugin->setDefaultACL([
- [
- 'principal' => '{DAV:}all',
- 'privilege' => '{DAV:}all',
- ],
- ]);
- $fakeServer->addPlugin($plugin);
-
- $requestedProperties = [
- '{DAV:}alternate-URI-set',
- ];
- $result = $fakeServer->getPropertiesForPath('principals/user', $requestedProperties);
- $result = $result[0];
-
- $this->assertTrue(isset($result[200]));
- $this->assertTrue(isset($result[200]['{DAV:}alternate-URI-set']));
- $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}alternate-URI-set']);
-
- $this->assertEquals([], $result[200]['{DAV:}alternate-URI-set']->getHrefs());
- }
-
- public function testPrincipalURL()
- {
- $tree = [
- new DAV\SimpleCollection('principals', [
- $principal = new MockPrincipal('user', 'principals/user'),
- ]),
- ];
-
- $fakeServer = new DAV\Server($tree);
- //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend());
- //$fakeServer->addPlugin($plugin);
- $plugin = new Plugin();
- $plugin->allowUnauthenticatedAccess = false;
- $plugin->setDefaultACL([
- [
- 'principal' => '{DAV:}all',
- 'privilege' => '{DAV:}all',
- ],
- ]);
- $fakeServer->addPlugin($plugin);
-
- $requestedProperties = [
- '{DAV:}principal-URL',
- ];
-
- $result = $fakeServer->getPropertiesForPath('principals/user', $requestedProperties);
- $result = $result[0];
-
- $this->assertTrue(isset($result[200]));
- $this->assertTrue(isset($result[200]['{DAV:}principal-URL']));
- $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}principal-URL']);
-
- $this->assertEquals('principals/user/', $result[200]['{DAV:}principal-URL']->getHref());
- }
-
- public function testGroupMemberSet()
- {
- $tree = [
- new DAV\SimpleCollection('principals', [
- $principal = new MockPrincipal('user', 'principals/user'),
- ]),
- ];
-
- $fakeServer = new DAV\Server($tree);
- //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend());
- //$fakeServer->addPlugin($plugin);
- $plugin = new Plugin();
- $plugin->allowUnauthenticatedAccess = false;
- $plugin->setDefaultACL([
- [
- 'principal' => '{DAV:}all',
- 'privilege' => '{DAV:}all',
- ],
- ]);
- $fakeServer->addPlugin($plugin);
-
- $requestedProperties = [
- '{DAV:}group-member-set',
- ];
-
- $result = $fakeServer->getPropertiesForPath('principals/user', $requestedProperties);
- $result = $result[0];
-
- $this->assertTrue(isset($result[200]));
- $this->assertTrue(isset($result[200]['{DAV:}group-member-set']));
- $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}group-member-set']);
-
- $this->assertEquals([], $result[200]['{DAV:}group-member-set']->getHrefs());
- }
-
- public function testGroupMemberShip()
- {
- $tree = [
- new DAV\SimpleCollection('principals', [
- $principal = new MockPrincipal('user', 'principals/user'),
- ]),
- ];
-
- $fakeServer = new DAV\Server($tree);
- $plugin = new Plugin();
- $plugin->allowUnauthenticatedAccess = false;
- $fakeServer->addPlugin($plugin);
- $plugin->setDefaultACL([
- [
- 'principal' => '{DAV:}all',
- 'privilege' => '{DAV:}all',
- ],
- ]);
-
- $requestedProperties = [
- '{DAV:}group-membership',
- ];
-
- $result = $fakeServer->getPropertiesForPath('principals/user', $requestedProperties);
- $result = $result[0];
-
- $this->assertTrue(isset($result[200]));
- $this->assertTrue(isset($result[200]['{DAV:}group-membership']));
- $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}group-membership']);
-
- $this->assertEquals([], $result[200]['{DAV:}group-membership']->getHrefs());
- }
-
- public function testGetDisplayName()
- {
- $tree = [
- new DAV\SimpleCollection('principals', [
- $principal = new MockPrincipal('user', 'principals/user'),
- ]),
- ];
-
- $fakeServer = new DAV\Server($tree);
- $plugin = new Plugin();
- $plugin->allowUnauthenticatedAccess = false;
- $fakeServer->addPlugin($plugin);
- $plugin->setDefaultACL([
- [
- 'principal' => '{DAV:}all',
- 'privilege' => '{DAV:}all',
- ],
- ]);
-
- $requestedProperties = [
- '{DAV:}displayname',
- ];
-
- $result = $fakeServer->getPropertiesForPath('principals/user', $requestedProperties);
- $result = $result[0];
-
- $this->assertTrue(isset($result[200]));
- $this->assertTrue(isset($result[200]['{DAV:}displayname']));
-
- $this->assertEquals('user', $result[200]['{DAV:}displayname']);
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php
deleted file mode 100644
index e6796e014..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php
+++ /dev/null
@@ -1,111 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL;
-
-use Sabre\DAV;
-
-class PluginUpdatePropertiesTest extends \PHPUnit\Framework\TestCase
-{
- public function testUpdatePropertiesPassthrough()
- {
- $tree = [
- new DAV\SimpleCollection('foo'),
- ];
- $server = new DAV\Server($tree);
- $server->addPlugin(new DAV\Auth\Plugin());
- $server->addPlugin(new Plugin());
-
- $result = $server->updateProperties('foo', [
- '{DAV:}foo' => 'bar',
- ]);
-
- $expected = [
- '{DAV:}foo' => 403,
- ];
-
- $this->assertEquals($expected, $result);
- }
-
- public function testRemoveGroupMembers()
- {
- $tree = [
- new MockPrincipal('foo', 'foo'),
- ];
- $server = new DAV\Server($tree);
- $plugin = new Plugin();
- $plugin->allowUnauthenticatedAccess = false;
- $server->addPlugin($plugin);
-
- $result = $server->updateProperties('foo', [
- '{DAV:}group-member-set' => null,
- ]);
-
- $expected = [
- '{DAV:}group-member-set' => 204,
- ];
-
- $this->assertEquals($expected, $result);
- $this->assertEquals([], $tree[0]->getGroupMemberSet());
- }
-
- public function testSetGroupMembers()
- {
- $tree = [
- new MockPrincipal('foo', 'foo'),
- ];
- $server = new DAV\Server($tree);
- $plugin = new Plugin();
- $plugin->allowUnauthenticatedAccess = false;
- $server->addPlugin($plugin);
-
- $result = $server->updateProperties('foo', [
- '{DAV:}group-member-set' => new DAV\Xml\Property\Href(['/bar', '/baz'], true),
- ]);
-
- $expected = [
- '{DAV:}group-member-set' => 200,
- ];
-
- $this->assertEquals($expected, $result);
- $this->assertEquals(['bar', 'baz'], $tree[0]->getGroupMemberSet());
- }
-
- public function testSetBadValue()
- {
- $this->expectException('Sabre\DAV\Exception');
- $tree = [
- new MockPrincipal('foo', 'foo'),
- ];
- $server = new DAV\Server($tree);
- $plugin = new Plugin();
- $plugin->allowUnauthenticatedAccess = false;
- $server->addPlugin($plugin);
-
- $result = $server->updateProperties('foo', [
- '{DAV:}group-member-set' => new \StdClass(),
- ]);
- }
-
- public function testSetBadNode()
- {
- $tree = [
- new DAV\SimpleCollection('foo'),
- ];
- $server = new DAV\Server($tree);
- $plugin = new Plugin();
- $plugin->allowUnauthenticatedAccess = false;
- $server->addPlugin($plugin);
-
- $result = $server->updateProperties('foo', [
- '{DAV:}group-member-set' => new DAV\Xml\Property\Href(['/bar', '/baz'], false),
- ]);
-
- $expected = [
- '{DAV:}group-member-set' => 403,
- ];
-
- $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
deleted file mode 100644
index b18ab9488..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php
+++ /dev/null
@@ -1,219 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL\PrincipalBackend;
-
-use Sabre\DAV;
-
-abstract class AbstractPDOTest extends \PHPUnit\Framework\TestCase
-{
- use DAV\DbTestHelperTrait;
-
- public function setup(): void
- {
- $this->dropTables(['principals', 'groupmembers']);
- $this->createSchema('principals');
-
- $pdo = $this->getPDO();
-
- $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('INSERT INTO groupmembers (principal_id,member_id) VALUES (5,4)');
- }
-
- public function testConstruct()
- {
- $pdo = $this->getPDO();
- $backend = new PDO($pdo);
- $this->assertTrue($backend instanceof PDO);
- }
-
- /**
- * @depends testConstruct
- */
- public function testGetPrincipalsByPrefix()
- {
- $pdo = $this->getPDO();
- $backend = new PDO($pdo);
-
- $expected = [
- [
- 'uri' => 'principals/admin',
- '{http://sabredav.org/ns}email-address' => 'admin@example.org',
- '{DAV:}displayname' => 'Administrator',
- ],
- [
- 'uri' => 'principals/user',
- '{http://sabredav.org/ns}email-address' => 'user@example.org',
- '{DAV:}displayname' => 'User',
- ],
- [
- 'uri' => 'principals/group',
- '{http://sabredav.org/ns}email-address' => 'group@example.org',
- '{DAV:}displayname' => 'Group',
- ],
- ];
-
- $this->assertEquals($expected, $backend->getPrincipalsByPrefix('principals'));
- $this->assertEquals([], $backend->getPrincipalsByPrefix('foo'));
- }
-
- /**
- * @depends testConstruct
- */
- public function testGetPrincipalByPath()
- {
- $pdo = $this->getPDO();
- $backend = new PDO($pdo);
-
- $expected = [
- 'id' => 4,
- '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'));
- }
-
- public function testGetGroupMemberSet()
- {
- $pdo = $this->getPDO();
- $backend = new PDO($pdo);
- $expected = ['principals/user'];
-
- $this->assertEquals($expected, $backend->getGroupMemberSet('principals/group'));
- }
-
- public function testGetGroupMembership()
- {
- $pdo = $this->getPDO();
- $backend = new PDO($pdo);
- $expected = ['principals/group'];
-
- $this->assertEquals($expected, $backend->getGroupMembership('principals/user'));
- }
-
- public function testSetGroupMemberSet()
- {
- $pdo = $this->getPDO();
-
- // Start situation
- $backend = new PDO($pdo);
- $this->assertEquals(['principals/user'], $backend->getGroupMemberSet('principals/group'));
-
- // Removing all principals
- $backend->setGroupMemberSet('principals/group', []);
- $this->assertEquals([], $backend->getGroupMemberSet('principals/group'));
-
- // Adding principals again
- $backend->setGroupMemberSet('principals/group', ['principals/user']);
- $this->assertEquals(['principals/user'], $backend->getGroupMemberSet('principals/group'));
- }
-
- public function testSearchPrincipals()
- {
- $pdo = $this->getPDO();
-
- $backend = new PDO($pdo);
-
- $result = $backend->searchPrincipals('principals', ['{DAV:}blabla' => 'foo']);
- $this->assertEquals([], $result);
-
- $result = $backend->searchPrincipals('principals', ['{DAV:}displayname' => 'ou']);
- $this->assertEquals(['principals/group'], $result);
-
- $result = $backend->searchPrincipals('principals', ['{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE']);
- $this->assertEquals(['principals/user'], $result);
-
- $result = $backend->searchPrincipals('mom', ['{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE']);
- $this->assertEquals([], $result);
- }
-
- public function testUpdatePrincipal()
- {
- $pdo = $this->getPDO();
- $backend = new PDO($pdo);
-
- $propPatch = new DAV\PropPatch([
- '{DAV:}displayname' => 'pietje',
- ]);
-
- $backend->updatePrincipal('principals/user', $propPatch);
- $result = $propPatch->commit();
-
- $this->assertTrue($result);
-
- $this->assertEquals([
- 'id' => 4,
- 'uri' => 'principals/user',
- '{DAV:}displayname' => 'pietje',
- '{http://sabredav.org/ns}email-address' => 'user@example.org',
- ], $backend->getPrincipalByPath('principals/user'));
- }
-
- public function testUpdatePrincipalUnknownField()
- {
- $pdo = $this->getPDO();
- $backend = new PDO($pdo);
-
- $propPatch = new DAV\PropPatch([
- '{DAV:}displayname' => 'pietje',
- '{DAV:}unknown' => 'foo',
- ]);
-
- $backend->updatePrincipal('principals/user', $propPatch);
- $result = $propPatch->commit();
-
- $this->assertFalse($result);
-
- $this->assertEquals([
- '{DAV:}displayname' => 424,
- '{DAV:}unknown' => 403,
- ], $propPatch->getResult());
-
- $this->assertEquals([
- 'id' => '4',
- 'uri' => 'principals/user',
- '{DAV:}displayname' => 'User',
- '{http://sabredav.org/ns}email-address' => 'user@example.org',
- ], $backend->getPrincipalByPath('principals/user'));
- }
-
- public function testFindByUriUnknownScheme()
- {
- $pdo = $this->getPDO();
- $backend = new PDO($pdo);
- $this->assertNull($backend->findByUri('http://foo', 'principals'));
- }
-
- public function testFindByUriWithMailtoAddress()
- {
- $pdo = $this->getPDO();
- $backend = new PDO($pdo);
- $this->assertEquals(
- 'principals/user',
- $backend->findByUri('mailto:user@example.org', 'principals')
- );
- }
-
- public function testFindByUriWithUri()
- {
- $pdo = $this->getPDO();
- $backend = new PDO($pdo);
- $this->assertEquals(
- 'principals/user',
- $backend->findByUri('principals/user', 'principals')
- );
- }
-
- public function testFindByUriWithUnknownUri()
- {
- $pdo = $this->getPDO();
- $backend = new PDO($pdo);
- $this->assertNull($backend->findByUri('principals/other', 'principals'));
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php
deleted file mode 100644
index 5f0434579..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php
+++ /dev/null
@@ -1,158 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL\PrincipalBackend;
-
-class Mock extends AbstractBackend
-{
- public $groupMembers = [];
- public $principals;
-
- public function __construct(array $principals = null)
- {
- $this->principals = $principals;
-
- if (is_null($principals)) {
- $this->principals = [
- [
- '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',
- ],
- [
- 'uri' => 'principals/admin',
- '{DAV:}displayname' => 'Admin',
- ],
- [
- 'uri' => 'principals/user2',
- '{DAV:}displayname' => 'User 2',
- '{http://sabredav.org/ns}email-address' => 'user2.sabredav@sabredav.org',
- ],
- ];
- }
- }
-
- public function getPrincipalsByPrefix($prefix)
- {
- $prefix = trim($prefix, '/');
- if ($prefix) {
- $prefix .= '/';
- }
- $return = [];
-
- foreach ($this->principals as $principal) {
- if ($prefix && 0 !== strpos($principal['uri'], $prefix)) {
- continue;
- }
-
- $return[] = $principal;
- }
-
- return $return;
- }
-
- public function addPrincipal(array $principal)
- {
- $this->principals[] = $principal;
- }
-
- public function getPrincipalByPath($path)
- {
- foreach ($this->getPrincipalsByPrefix('principals') as $principal) {
- if ($principal['uri'] === $path) {
- return $principal;
- }
- }
- }
-
- public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof')
- {
- $matches = [];
- foreach ($this->getPrincipalsByPrefix($prefixPath) as $principal) {
- foreach ($searchProperties as $key => $value) {
- if (!isset($principal[$key])) {
- continue 2;
- }
- if (false === mb_stripos($principal[$key], $value, 0, 'UTF-8')) {
- continue 2;
- }
-
- // We have a match for this searchProperty!
- if ('allof' === $test) {
- continue;
- } else {
- break;
- }
- }
- $matches[] = $principal['uri'];
- }
-
- return $matches;
- }
-
- public function getGroupMemberSet($path)
- {
- return isset($this->groupMembers[$path]) ? $this->groupMembers[$path] : [];
- }
-
- public function getGroupMembership($path)
- {
- $membership = [];
- foreach ($this->groupMembers as $group => $members) {
- if (in_array($path, $members)) {
- $membership[] = $group;
- }
- }
-
- return $membership;
- }
-
- public function setGroupMemberSet($path, array $members)
- {
- $this->groupMembers[$path] = $members;
- }
-
- /**
- * Updates one ore more webdav properties on a principal.
- *
- * The list of mutations is stored in a Sabre\DAV\PropPatch object.
- * To do the actual updates, you must tell this object which properties
- * you're going to process with the handle() method.
- *
- * Calling the handle method is like telling the PropPatch object "I
- * promise I can handle updating this property".
- *
- * Read the PropPatch documentation for more info and examples.
- *
- * @param string $path
- */
- public function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch)
- {
- $value = null;
- foreach ($this->principals as $principalIndex => $value) {
- if ($value['uri'] === $path) {
- $principal = $value;
- break;
- }
- }
- if (!$principal) {
- return;
- }
-
- $propPatch->handleRemaining(function ($mutations) use ($principal, $principalIndex) {
- 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
deleted file mode 100644
index 54795cf4d..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL\PrincipalBackend;
-
-class PDOMySQLTest extends AbstractPDOTest
-{
- public $driver = 'mysql';
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php
deleted file mode 100644
index 549e0bd60..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL\PrincipalBackend;
-
-class PDOSqliteTest extends AbstractPDOTest
-{
- public $driver = 'sqlite';
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php
deleted file mode 100644
index 2777281a8..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL;
-
-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
- */
- public function testGetChildrenDisable()
- {
- $this->expectException('Sabre\DAV\Exception\MethodNotAllowed');
- $backend = new PrincipalBackend\Mock();
- $pc = new PrincipalCollection($backend);
- $pc->disableListing = true;
-
- $children = $pc->getChildren();
- }
-
- public function testFindByUri()
- {
- $backend = new PrincipalBackend\Mock();
- $pc = new PrincipalCollection($backend);
- $this->assertEquals('principals/user1', $pc->findByUri('mailto:user1.sabredav@sabredav.org'));
- $this->assertNull($pc->findByUri('mailto:fake.user.sabredav@sabredav.org'));
- $this->assertNull($pc->findByUri(''));
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php
deleted file mode 100644
index 6883f25b4..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php
+++ /dev/null
@@ -1,389 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL;
-
-use Sabre\DAV;
-use Sabre\HTTP;
-
-class PrincipalPropertySearchTest extends \PHPUnit\Framework\TestCase
-{
- public function getServer()
- {
- $backend = new PrincipalBackend\Mock();
-
- $dir = new DAV\SimpleCollection('root');
- $principals = new PrincipalCollection($backend);
- $dir->addChild($principals);
-
- $fakeServer = new DAV\Server($dir);
- $fakeServer->sapi = new HTTP\SapiMock();
- $fakeServer->httpResponse = new HTTP\ResponseMock();
- $fakeServer->debugExceptions = true;
- $plugin = new MockPlugin();
- $plugin->allowAccessToNodesWithoutACL = true;
- $plugin->allowUnauthenticatedAccess = false;
-
- $this->assertTrue($plugin instanceof Plugin);
- $fakeServer->addPlugin($plugin);
- $this->assertEquals($plugin, $fakeServer->getPlugin('acl'));
-
- return $fakeServer;
- }
-
- public 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 = [
- 'REQUEST_METHOD' => 'REPORT',
- 'HTTP_DEPTH' => '1',
- 'REQUEST_URI' => '/principals',
- ];
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody($xml);
-
- $server = $this->getServer();
- $server->httpRequest = $request;
-
- $server->exec();
-
- $this->assertEquals(400, $server->httpResponse->getStatus(), $server->httpResponse->getBodyAsString());
- $this->assertEquals([
- 'X-Sabre-Version' => [DAV\Version::VERSION],
- 'Content-Type' => ['application/xml; charset=utf-8'],
- ], $server->httpResponse->getHeaders());
- }
-
- public 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 = [
- 'REQUEST_METHOD' => 'REPORT',
- 'HTTP_DEPTH' => '0',
- 'REQUEST_URI' => '/principals',
- ];
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody($xml);
-
- $server = $this->getServer();
- $server->httpRequest = $request;
-
- $server->exec();
-
- $this->assertEquals(207, $server->httpResponse->getStatus(), 'Full body: '.$server->httpResponse->getBodyAsString());
- $this->assertEquals([
- 'X-Sabre-Version' => [DAV\Version::VERSION],
- 'Content-Type' => ['application/xml; charset=utf-8'],
- 'Vary' => ['Brief,Prefer'],
- ], $server->httpResponse->getHeaders());
- }
-
- public 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 = [
- 'REQUEST_METHOD' => 'REPORT',
- 'HTTP_DEPTH' => '0',
- 'REQUEST_URI' => '/',
- ];
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody($xml);
-
- $server = $this->getServer();
- $server->httpRequest = $request;
-
- $server->exec();
-
- $bodyAsString = $server->httpResponse->getBodyAsString();
- $this->assertEquals(207, $server->httpResponse->status, $bodyAsString);
- $this->assertEquals([
- 'X-Sabre-Version' => [DAV\Version::VERSION],
- 'Content-Type' => ['application/xml; charset=utf-8'],
- 'Vary' => ['Brief,Prefer'],
- ], $server->httpResponse->getHeaders());
-
- $check = [
- '/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($bodyAsString);
- $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->getBodyAsString());
- }
- }
-
- public function testAND()
- {
- $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:property-search>
- <d:prop>
- <d:foo />
- </d:prop>
- <d:match>bar</d:match>
- </d:property-search>
- <d:prop>
- <d:displayname />
- <d:getcontentlength />
- </d:prop>
-</d:principal-property-search>';
-
- $serverVars = [
- 'REQUEST_METHOD' => 'REPORT',
- 'HTTP_DEPTH' => '0',
- 'REQUEST_URI' => '/',
- ];
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody($xml);
-
- $server = $this->getServer();
- $server->httpRequest = $request;
-
- $server->exec();
-
- $bodyAsString = $server->httpResponse->getBodyAsString();
- $this->assertEquals(207, $server->httpResponse->status, $bodyAsString);
- $this->assertEquals([
- 'X-Sabre-Version' => [DAV\Version::VERSION],
- 'Content-Type' => ['application/xml; charset=utf-8'],
- 'Vary' => ['Brief,Prefer'],
- ], $server->httpResponse->getHeaders());
-
- $check = [
- '/d:multistatus',
- '/d:multistatus/d:response' => 0,
- '/d:multistatus/d:response/d:href' => 0,
- '/d:multistatus/d:response/d:propstat' => 0,
- '/d:multistatus/d:response/d:propstat/d:prop' => 0,
- '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 0,
- '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 0,
- '/d:multistatus/d:response/d:propstat/d:status' => 0,
- ];
-
- $xml = simplexml_load_string($bodyAsString);
- $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->getBodyAsString());
- }
- }
-
- public function testOR()
- {
- $xml = '<?xml version="1.0"?>
-<d:principal-property-search xmlns:d="DAV:" test="anyof">
- <d:apply-to-principal-collection-set />
- <d:property-search>
- <d:prop>
- <d:displayname />
- </d:prop>
- <d:match>user</d:match>
- </d:property-search>
- <d:property-search>
- <d:prop>
- <d:foo />
- </d:prop>
- <d:match>bar</d:match>
- </d:property-search>
- <d:prop>
- <d:displayname />
- <d:getcontentlength />
- </d:prop>
-</d:principal-property-search>';
-
- $serverVars = [
- 'REQUEST_METHOD' => 'REPORT',
- 'HTTP_DEPTH' => '0',
- 'REQUEST_URI' => '/',
- ];
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody($xml);
-
- $server = $this->getServer();
- $server->httpRequest = $request;
-
- $server->exec();
-
- $bodyAsString = $server->httpResponse->getBodyAsString();
- $this->assertEquals(207, $server->httpResponse->status, $bodyAsString);
- $this->assertEquals([
- 'X-Sabre-Version' => [DAV\Version::VERSION],
- 'Content-Type' => ['application/xml; charset=utf-8'],
- 'Vary' => ['Brief,Prefer'],
- ], $server->httpResponse->getHeaders());
-
- $check = [
- '/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($bodyAsString);
- $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->getBodyAsString());
- }
- }
-
- public 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 = [
- 'REQUEST_METHOD' => 'REPORT',
- 'HTTP_DEPTH' => '0',
- 'REQUEST_URI' => '/',
- ];
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody($xml);
-
- $server = $this->getServer();
- $server->httpRequest = $request;
-
- $server->exec();
-
- $bodyAsString = $server->httpResponse->getBodyAsString();
- $this->assertEquals(207, $server->httpResponse->status, $bodyAsString);
- $this->assertEquals([
- 'X-Sabre-Version' => [DAV\Version::VERSION],
- 'Content-Type' => ['application/xml; charset=utf-8'],
- 'Vary' => ['Brief,Prefer'],
- ], $server->httpResponse->getHeaders());
-
- $check = [
- '/d:multistatus',
- '/d:multistatus/d:response' => 0,
- ];
-
- $xml = simplexml_load_string($bodyAsString);
- $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->getBodyAsString());
- }
- }
-}
-
-class MockPlugin extends Plugin
-{
- public function getCurrentUserPrivilegeSet($node)
- {
- return [
- '{DAV:}read',
- '{DAV:}write',
- ];
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php
deleted file mode 100644
index ec834fe1a..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php
+++ /dev/null
@@ -1,135 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL;
-
-use Sabre\DAV;
-use Sabre\HTTP;
-
-class PrincipalSearchPropertySetTest extends \PHPUnit\Framework\TestCase
-{
- public function getServer()
- {
- $backend = new PrincipalBackend\Mock();
-
- $dir = new DAV\SimpleCollection('root');
- $principals = new PrincipalCollection($backend);
- $dir->addChild($principals);
-
- $fakeServer = new DAV\Server($dir);
- $fakeServer->sapi = new HTTP\SapiMock();
- $fakeServer->httpResponse = new HTTP\ResponseMock();
- $plugin = new Plugin();
- $plugin->allowUnauthenticatedAccess = false;
- $this->assertTrue($plugin instanceof Plugin);
- $fakeServer->addPlugin($plugin);
- $this->assertEquals($plugin, $fakeServer->getPlugin('acl'));
-
- return $fakeServer;
- }
-
- public function testDepth1()
- {
- $xml = '<?xml version="1.0"?>
-<d:principal-search-property-set xmlns:d="DAV:" />';
-
- $serverVars = [
- 'REQUEST_METHOD' => 'REPORT',
- 'HTTP_DEPTH' => '1',
- 'REQUEST_URI' => '/principals',
- ];
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody($xml);
-
- $server = $this->getServer();
- $server->httpRequest = $request;
-
- $server->exec();
-
- $this->assertEquals(400, $server->httpResponse->status);
- $this->assertEquals([
- 'X-Sabre-Version' => [DAV\Version::VERSION],
- 'Content-Type' => ['application/xml; charset=utf-8'],
- ], $server->httpResponse->getHeaders());
- }
-
- public function testDepthIncorrectXML()
- {
- $xml = '<?xml version="1.0"?>
-<d:principal-search-property-set xmlns:d="DAV:"><d:ohell /></d:principal-search-property-set>';
-
- $serverVars = [
- 'REQUEST_METHOD' => 'REPORT',
- 'HTTP_DEPTH' => '0',
- 'REQUEST_URI' => '/principals',
- ];
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody($xml);
-
- $server = $this->getServer();
- $server->httpRequest = $request;
-
- $server->exec();
-
- $this->assertEquals(400, $server->httpResponse->status, $server->httpResponse->getBodyAsString());
- $this->assertEquals([
- 'X-Sabre-Version' => [DAV\Version::VERSION],
- 'Content-Type' => ['application/xml; charset=utf-8'],
- ], $server->httpResponse->getHeaders());
- }
-
- public function testCorrect()
- {
- $xml = '<?xml version="1.0"?>
-<d:principal-search-property-set xmlns:d="DAV:"/>';
-
- $serverVars = [
- 'REQUEST_METHOD' => 'REPORT',
- 'HTTP_DEPTH' => '0',
- 'REQUEST_URI' => '/principals',
- ];
-
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody($xml);
-
- $server = $this->getServer();
- $server->httpRequest = $request;
-
- $server->exec();
-
- $bodyAsString = $server->httpResponse->getBodyAsString();
- $this->assertEquals(200, $server->httpResponse->status, $bodyAsString);
- $this->assertEquals([
- 'X-Sabre-Version' => [DAV\Version::VERSION],
- 'Content-Type' => ['application/xml; charset=utf-8'],
- ], $server->httpResponse->getHeaders());
-
- $check = [
- '/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($bodyAsString);
- $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: '.$bodyAsString);
- }
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php
deleted file mode 100644
index 7e1656a15..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php
+++ /dev/null
@@ -1,192 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL;
-
-use Sabre\DAV;
-
-class PrincipalTest extends \PHPUnit\Framework\TestCase
-{
- public function testConstruct()
- {
- $principalBackend = new PrincipalBackend\Mock();
- $principal = new Principal($principalBackend, ['uri' => 'principals/admin']);
- $this->assertTrue($principal instanceof Principal);
- }
-
- public function testConstructNoUri()
- {
- $this->expectException('Sabre\DAV\Exception');
- $principalBackend = new PrincipalBackend\Mock();
- $principal = new Principal($principalBackend, []);
- }
-
- public function testGetName()
- {
- $principalBackend = new PrincipalBackend\Mock();
- $principal = new Principal($principalBackend, ['uri' => 'principals/admin']);
- $this->assertEquals('admin', $principal->getName());
- }
-
- public function testGetDisplayName()
- {
- $principalBackend = new PrincipalBackend\Mock();
- $principal = new Principal($principalBackend, ['uri' => 'principals/admin']);
- $this->assertEquals('admin', $principal->getDisplayname());
-
- $principal = new Principal($principalBackend, [
- 'uri' => 'principals/admin',
- '{DAV:}displayname' => 'Mr. Admin',
- ]);
- $this->assertEquals('Mr. Admin', $principal->getDisplayname());
- }
-
- public function testGetProperties()
- {
- $principalBackend = new PrincipalBackend\Mock();
- $principal = new Principal($principalBackend, [
- 'uri' => 'principals/admin',
- '{DAV:}displayname' => 'Mr. Admin',
- '{http://www.example.org/custom}custom' => 'Custom',
- '{http://sabredav.org/ns}email-address' => 'admin@example.org',
- ]);
-
- $keys = [
- '{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, ['uri' => 'principals/admin']);
-
- $propPatch = new DAV\PropPatch(['{DAV:}yourmom' => 'test']);
-
- $result = $principal->propPatch($propPatch);
- $result = $propPatch->commit();
- $this->assertTrue($result);
- }
-
- public function testGetPrincipalUrl()
- {
- $principalBackend = new PrincipalBackend\Mock();
- $principal = new Principal($principalBackend, ['uri' => 'principals/admin']);
- $this->assertEquals('principals/admin', $principal->getPrincipalUrl());
- }
-
- public function testGetAlternateUriSet()
- {
- $principalBackend = new PrincipalBackend\Mock();
- $principal = new Principal($principalBackend, [
- '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' => [
- 'mailto:admin+1@example.org',
- 'mailto:admin+2@example.org',
- 'mailto:admin@example.org',
- ],
- ]);
-
- $expected = [
- '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, [
- 'uri' => 'principals/admin',
- ]);
-
- $expected = [];
-
- $this->assertEquals($expected, $principal->getAlternateUriSet());
- }
-
- public function testGetGroupMemberSet()
- {
- $principalBackend = new PrincipalBackend\Mock();
- $principal = new Principal($principalBackend, ['uri' => 'principals/admin']);
- $this->assertEquals([], $principal->getGroupMemberSet());
- }
-
- public function testGetGroupMembership()
- {
- $principalBackend = new PrincipalBackend\Mock();
- $principal = new Principal($principalBackend, ['uri' => 'principals/admin']);
- $this->assertEquals([], $principal->getGroupMembership());
- }
-
- public function testSetGroupMemberSet()
- {
- $principalBackend = new PrincipalBackend\Mock();
- $principal = new Principal($principalBackend, ['uri' => 'principals/admin']);
- $principal->setGroupMemberSet(['principals/foo']);
-
- $this->assertEquals([
- 'principals/admin' => ['principals/foo'],
- ], $principalBackend->groupMembers);
- }
-
- public function testGetOwner()
- {
- $principalBackend = new PrincipalBackend\Mock();
- $principal = new Principal($principalBackend, ['uri' => 'principals/admin']);
- $this->assertEquals('principals/admin', $principal->getOwner());
- }
-
- public function testGetGroup()
- {
- $principalBackend = new PrincipalBackend\Mock();
- $principal = new Principal($principalBackend, ['uri' => 'principals/admin']);
- $this->assertNull($principal->getGroup());
- }
-
- public function testGetACl()
- {
- $principalBackend = new PrincipalBackend\Mock();
- $principal = new Principal($principalBackend, ['uri' => 'principals/admin']);
- $this->assertEquals([
- [
- 'privilege' => '{DAV:}all',
- 'principal' => '{DAV:}owner',
- 'protected' => true,
- ],
- ], $principal->getACL());
- }
-
- public function testSetACl()
- {
- $this->expectException('Sabre\DAV\Exception\Forbidden');
- $principalBackend = new PrincipalBackend\Mock();
- $principal = new Principal($principalBackend, ['uri' => 'principals/admin']);
- $principal->setACL([]);
- }
-
- public function testGetSupportedPrivilegeSet()
- {
- $principalBackend = new PrincipalBackend\Mock();
- $principal = new Principal($principalBackend, ['uri' => 'principals/admin']);
- $this->assertNull($principal->getSupportedPrivilegeSet());
- }
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php
deleted file mode 100644
index effa15838..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php
+++ /dev/null
@@ -1,302 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace Sabre\DAVACL;
-
-use Sabre\DAV;
-use Sabre\HTTP;
-
-class SimplePluginTest extends \PHPUnit\Framework\TestCase
-{
- public function testValues()
- {
- $aclPlugin = new Plugin();
- $this->assertEquals('acl', $aclPlugin->getPluginName());
- $this->assertEquals(
- ['access-control', 'calendarserver-principal-property-search'],
- $aclPlugin->getFeatures()
- );
-
- $this->assertEquals(
- [
- '{DAV:}expand-property',
- '{DAV:}principal-match',
- '{DAV:}principal-property-search',
- '{DAV:}principal-search-property-set',
- ],
- $aclPlugin->getSupportedReportSet(''));
-
- $this->assertEquals(['ACL'], $aclPlugin->getMethods(''));
-
- $this->assertEquals(
- 'acl',
- $aclPlugin->getPluginInfo()['name']
- );
- }
-
- public function testGetFlatPrivilegeSet()
- {
- $expected = [
- '{DAV:}all' => [
- 'privilege' => '{DAV:}all',
- 'abstract' => false,
- 'aggregates' => [
- '{DAV:}read',
- '{DAV:}write',
- ],
- 'concrete' => '{DAV:}all',
- ],
- '{DAV:}read' => [
- 'privilege' => '{DAV:}read',
- 'abstract' => false,
- 'aggregates' => [
- '{DAV:}read-acl',
- '{DAV:}read-current-user-privilege-set',
- ],
- 'concrete' => '{DAV:}read',
- ],
- '{DAV:}read-acl' => [
- 'privilege' => '{DAV:}read-acl',
- 'abstract' => false,
- 'aggregates' => [],
- 'concrete' => '{DAV:}read-acl',
- ],
- '{DAV:}read-current-user-privilege-set' => [
- 'privilege' => '{DAV:}read-current-user-privilege-set',
- 'abstract' => false,
- 'aggregates' => [],
- 'concrete' => '{DAV:}read-current-user-privilege-set',
- ],
- '{DAV:}write' => [
- 'privilege' => '{DAV:}write',
- 'abstract' => false,
- 'aggregates' => [
- '{DAV:}write-properties',
- '{DAV:}write-content',
- '{DAV:}unlock',
- '{DAV:}bind',
- '{DAV:}unbind',
- ],
- 'concrete' => '{DAV:}write',
- ],
- '{DAV:}write-properties' => [
- 'privilege' => '{DAV:}write-properties',
- 'abstract' => false,
- 'aggregates' => [],
- 'concrete' => '{DAV:}write-properties',
- ],
- '{DAV:}write-content' => [
- 'privilege' => '{DAV:}write-content',
- 'abstract' => false,
- 'aggregates' => [],
- 'concrete' => '{DAV:}write-content',
- ],
- '{DAV:}unlock' => [
- 'privilege' => '{DAV:}unlock',
- 'abstract' => false,
- 'aggregates' => [],
- 'concrete' => '{DAV:}unlock',
- ],
- '{DAV:}bind' => [
- 'privilege' => '{DAV:}bind',
- 'abstract' => false,
- 'aggregates' => [],
- 'concrete' => '{DAV:}bind',
- ],
- '{DAV:}unbind' => [
- 'privilege' => '{DAV:}unbind',
- 'abstract' => false,
- 'aggregates' => [],
- 'concrete' => '{DAV:}unbind',
- ],
- ];
-
- $plugin = new Plugin();
- $plugin->allowUnauthenticatedAccess = false;
- $server = new DAV\Server();
- $server->addPlugin($plugin);
- $this->assertEquals($expected, $plugin->getFlatPrivilegeSet(''));
- }
-
- public function testCurrentUserPrincipalsNotLoggedIn()
- {
- $acl = new Plugin();
- $acl->allowUnauthenticatedAccess = false;
- $server = new DAV\Server();
- $server->addPlugin($acl);
-
- $this->assertEquals([], $acl->getCurrentUserPrincipals());
- }
-
- public function testCurrentUserPrincipalsSimple()
- {
- $tree = [
- new DAV\SimpleCollection('principals', [
- new MockPrincipal('admin', 'principals/admin'),
- ]),
- ];
-
- $acl = new Plugin();
- $acl->allowUnauthenticatedAccess = false;
- $server = new DAV\Server($tree);
- $server->addPlugin($acl);
-
- $auth = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock());
- $server->addPlugin($auth);
-
- //forcing login
- $auth->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response());
-
- $this->assertEquals(['principals/admin'], $acl->getCurrentUserPrincipals());
- }
-
- public function testCurrentUserPrincipalsGroups()
- {
- $tree = [
- new DAV\SimpleCollection('principals', [
- new MockPrincipal('admin', 'principals/admin', ['principals/administrators', 'principals/everyone']),
- new MockPrincipal('administrators', 'principals/administrators', ['principals/groups'], ['principals/admin']),
- new MockPrincipal('everyone', 'principals/everyone', [], ['principals/admin']),
- new MockPrincipal('groups', 'principals/groups', [], ['principals/administrators']),
- ]),
- ];
-
- $acl = new Plugin();
- $acl->allowUnauthenticatedAccess = false;
- $server = new DAV\Server($tree);
- $server->addPlugin($acl);
-
- $auth = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock());
- $server->addPlugin($auth);
-
- //forcing login
- $auth->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response());
-
- $expected = [
- '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());
- }
-
- public function testGetACL()
- {
- $acl = [
- [
- 'principal' => 'principals/admin',
- 'privilege' => '{DAV:}read',
- ],
- [
- 'principal' => 'principals/admin',
- 'privilege' => '{DAV:}write',
- ],
- ];
-
- $tree = [
- new MockACLNode('foo', $acl),
- ];
-
- $server = new DAV\Server($tree);
- $aclPlugin = new Plugin();
- $aclPlugin->allowUnauthenticatedAccess = false;
- $server->addPlugin($aclPlugin);
-
- $this->assertEquals($acl, $aclPlugin->getACL('foo'));
- }
-
- public function testGetCurrentUserPrivilegeSet()
- {
- $acl = [
- [
- 'principal' => 'principals/admin',
- 'privilege' => '{DAV:}read',
- ],
- [
- 'principal' => 'principals/user1',
- 'privilege' => '{DAV:}read',
- ],
- [
- 'principal' => 'principals/admin',
- 'privilege' => '{DAV:}write',
- ],
- ];
-
- $tree = [
- new MockACLNode('foo', $acl),
-
- new DAV\SimpleCollection('principals', [
- new MockPrincipal('admin', 'principals/admin'),
- ]),
- ];
-
- $server = new DAV\Server($tree);
- $aclPlugin = new Plugin();
- $aclPlugin->allowUnauthenticatedAccess = false;
- $server->addPlugin($aclPlugin);
-
- $auth = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock());
- $server->addPlugin($auth);
-
- //forcing login
- $auth->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response());
-
- $expected = [
- '{DAV:}write',
- '{DAV:}write-properties',
- '{DAV:}write-content',
- '{DAV:}unlock',
- '{DAV:}write-acl',
- '{DAV:}read',
- '{DAV:}read-acl',
- '{DAV:}read-current-user-privilege-set',
- ];
-
- $this->assertEquals($expected, $aclPlugin->getCurrentUserPrivilegeSet('foo'));
- }
-
- public function testCheckPrivileges()
- {
- $acl = [
- [
- 'principal' => 'principals/admin',
- 'privilege' => '{DAV:}read',
- ],
- [
- 'principal' => 'principals/user1',
- 'privilege' => '{DAV:}read',
- ],
- [
- 'principal' => 'principals/admin',
- 'privilege' => '{DAV:}write',
- ],
- ];
-
- $tree = [
- new MockACLNode('foo', $acl),
-
- new DAV\SimpleCollection('principals', [
- new MockPrincipal('admin', 'principals/admin'),
- ]),
- ];
-
- $server = new DAV\Server($tree);
- $aclPlugin = new Plugin();
- $aclPlugin->allowUnauthenticatedAccess = false;
- $server->addPlugin($aclPlugin);
-
- $auth = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock());
- $server->addPlugin($auth);
-
- //forcing login
- //$auth->beforeMethod('GET','/');
-
- $this->assertFalse($aclPlugin->checkPrivileges('foo', ['{DAV:}read'], Plugin::R_PARENT, false));
- }
-}