diff options
author | Hilmar R <u02@u29lx193> | 2021-02-28 21:06:16 +0100 |
---|---|---|
committer | Hilmar R <u02@u29lx193> | 2021-03-01 18:48:11 +0100 |
commit | c26dede97f626b52b7bf8962ed55d1dbda86abe8 (patch) | |
tree | 3c8c9bc97aa09f7ce9afe9bf467cf87bbf2c7d0b /vendor/sabre/dav/tests/Sabre/DAV | |
parent | ea3390d626f85b7293a750958bfd1b5460958365 (diff) | |
download | volse-hubzilla-c26dede97f626b52b7bf8962ed55d1dbda86abe8.tar.gz volse-hubzilla-c26dede97f626b52b7bf8962ed55d1dbda86abe8.tar.bz2 volse-hubzilla-c26dede97f626b52b7bf8962ed55d1dbda86abe8.zip |
get dev
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV')
51 files changed, 0 insertions, 6805 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php b/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php deleted file mode 100644 index 49fedf062..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -use Sabre\HTTP; - -abstract class AbstractServer extends \PHPUnit\Framework\TestCase -{ - /** - * @var \Sabre\HTTP\ResponseMock - */ - protected $response; - protected $request; - /** - * @var \Sabre\DAV\Server - */ - protected $server; - protected $tempDir = SABRE_TEMPDIR; - - public function setup(): void - { - $this->response = new HTTP\ResponseMock(); - $this->server = new Server($this->getRootNode()); - $this->server->sapi = new HTTP\SapiMock(); - $this->server->httpResponse = $this->response; - $this->server->debugExceptions = true; - $this->deleteTree(SABRE_TEMPDIR, false); - file_put_contents(SABRE_TEMPDIR.'/test.txt', 'Test contents'); - mkdir(SABRE_TEMPDIR.'/dir'); - file_put_contents(SABRE_TEMPDIR.'/dir/child.txt', 'Child contents'); - } - - public function teardown(): void - { - $this->deleteTree(SABRE_TEMPDIR, false); - } - - protected function getRootNode() - { - return new FS\Directory(SABRE_TEMPDIR); - } - - private function deleteTree($path, $deleteRoot = true) - { - foreach (scandir($path) as $node) { - if ('.' == $node || '.svn' == $node || '..' == $node) { - continue; - } - $myPath = $path.'/'.$node; - if (is_file($myPath)) { - unlink($myPath); - } else { - $this->deleteTree($myPath); - } - } - if ($deleteRoot) { - rmdir($path); - } - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php deleted file mode 100644 index ebc1e3f7b..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Auth\Backend; - -use Sabre\HTTP; - -class AbstractBasicTest extends \PHPUnit\Framework\TestCase -{ - public function testCheckNoHeaders() - { - $request = new HTTP\Request('GET', '/'); - $response = new HTTP\Response(); - - $backend = new AbstractBasicMock(); - - $this->assertFalse( - $backend->check($request, $response)[0] - ); - } - - public function testCheckUnknownUser() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/', - 'PHP_AUTH_USER' => 'username', - 'PHP_AUTH_PW' => 'wrongpassword', - ]); - $response = new HTTP\Response(); - - $backend = new AbstractBasicMock(); - - $this->assertFalse( - $backend->check($request, $response)[0] - ); - } - - public function testCheckSuccess() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/', - 'PHP_AUTH_USER' => 'username', - 'PHP_AUTH_PW' => 'password', - ]); - $response = new HTTP\Response(); - - $backend = new AbstractBasicMock(); - $this->assertEquals( - [true, 'principals/username'], - $backend->check($request, $response) - ); - } - - public function testRequireAuth() - { - $request = new HTTP\Request('GET', '/'); - $response = new HTTP\Response(); - - $backend = new AbstractBasicMock(); - $backend->setRealm('writing unittests on a saturday night'); - $backend->challenge($request, $response); - - $this->assertEquals( - 'Basic realm="writing unittests on a saturday night", charset="UTF-8"', - $response->getHeader('WWW-Authenticate') - ); - } -} - -class AbstractBasicMock extends AbstractBasic -{ - /** - * Validates a username and password. - * - * This method should return true or false depending on if login - * succeeded. - * - * @param string $username - * @param string $password - * - * @return bool - */ - public function validateUserPass($username, $password) - { - return 'username' == $username && 'password' == $password; - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php deleted file mode 100644 index a751efdc2..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php +++ /dev/null @@ -1,134 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Auth\Backend; - -use Sabre\HTTP; - -class AbstractDigestTest extends \PHPUnit\Framework\TestCase -{ - public function testCheckNoHeaders() - { - $request = new HTTP\Request('GET', '/'); - $response = new HTTP\Response(); - - $backend = new AbstractDigestMock(); - $this->assertFalse( - $backend->check($request, $response)[0] - ); - } - - public function testCheckBadGetUserInfoResponse() - { - $header = 'username=null, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1'; - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/', - 'PHP_AUTH_DIGEST' => $header, - ]); - $response = new HTTP\Response(); - - $backend = new AbstractDigestMock(); - $this->assertFalse( - $backend->check($request, $response)[0] - ); - } - - public function testCheckBadGetUserInfoResponse2() - { - $this->expectException('Sabre\DAV\Exception'); - $header = 'username=array, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1'; - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/', - 'PHP_AUTH_DIGEST' => $header, - ]); - - $response = new HTTP\Response(); - - $backend = new AbstractDigestMock(); - $backend->check($request, $response); - } - - public function testCheckUnknownUser() - { - $header = 'username=false, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1'; - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/', - 'PHP_AUTH_DIGEST' => $header, - ]); - - $response = new HTTP\Response(); - - $backend = new AbstractDigestMock(); - $this->assertFalse( - $backend->check($request, $response)[0] - ); - } - - public function testCheckBadPassword() - { - $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1'; - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/', - 'PHP_AUTH_DIGEST' => $header, - ]); - - $response = new HTTP\Response(); - - $backend = new AbstractDigestMock(); - $this->assertFalse( - $backend->check($request, $response)[0] - ); - } - - public function testCheck() - { - $digestHash = md5('HELLO:12345:1:1:auth:'.md5('GET:/')); - $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response='.$digestHash.', opaque=1, qop=auth, nc=1, cnonce=1'; - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/', - 'PHP_AUTH_DIGEST' => $header, - ]); - - $response = new HTTP\Response(); - - $backend = new AbstractDigestMock(); - $this->assertEquals( - [true, 'principals/user'], - $backend->check($request, $response) - ); - } - - public function testRequireAuth() - { - $request = new HTTP\Request('GET', '/'); - $response = new HTTP\Response(); - - $backend = new AbstractDigestMock(); - $backend->setRealm('writing unittests on a saturday night'); - $backend->challenge($request, $response); - - $this->assertStringStartsWith( - 'Digest realm="writing unittests on a saturday night"', - $response->getHeader('WWW-Authenticate') - ); - } -} - -class AbstractDigestMock extends AbstractDigest -{ - public function getDigestHash($realm, $userName) - { - switch ($userName) { - case 'null': return null; - case 'false': return false; - case 'array': return []; - case 'user': return 'HELLO'; - } - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php deleted file mode 100644 index 8b874f884..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Auth\Backend; - -abstract class AbstractPDOTest extends \PHPUnit\Framework\TestCase -{ - use \Sabre\DAV\DbTestHelperTrait; - - public function setup(): void - { - $this->dropTables('users'); - $this->createSchema('users'); - - $this->getPDO()->query( - "INSERT INTO users (username,digesta1) VALUES ('user','hash')" - ); - } - - public function testConstruct() - { - $pdo = $this->getPDO(); - $backend = new PDO($pdo); - $this->assertTrue($backend instanceof PDO); - } - - /** - * @depends testConstruct - */ - public function testUserInfo() - { - $pdo = $this->getPDO(); - $backend = new PDO($pdo); - - $this->assertNull($backend->getDigestHash('realm', 'blabla')); - - $expected = 'hash'; - - $this->assertEquals($expected, $backend->getDigestHash('realm', 'user')); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php deleted file mode 100644 index a0086518f..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Auth\Backend; - -use Sabre\HTTP; - -class ApacheTest extends \PHPUnit\Framework\TestCase -{ - public function testConstruct() - { - $backend = new Apache(); - $this->assertInstanceOf('Sabre\DAV\Auth\Backend\Apache', $backend); - } - - public function testNoHeader() - { - $request = new HTTP\Request('GET', '/'); - $response = new HTTP\Response(); - $backend = new Apache(); - - $this->assertFalse( - $backend->check($request, $response)[0] - ); - } - - public function testRemoteUser() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/', - 'REMOTE_USER' => 'username', - ]); - $response = new HTTP\Response(); - $backend = new Apache(); - - $this->assertEquals( - [true, 'principals/username'], - $backend->check($request, $response) - ); - } - - public function testRedirectRemoteUser() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/', - 'REDIRECT_REMOTE_USER' => 'username', - ]); - $response = new HTTP\Response(); - $backend = new Apache(); - - $this->assertEquals( - [true, 'principals/username'], - $backend->check($request, $response) - ); - } - - public function testRequireAuth() - { - $request = new HTTP\Request('GET', '/'); - $response = new HTTP\Response(); - - $backend = new Apache(); - $backend->challenge($request, $response); - - $this->assertNull( - $response->getHeader('WWW-Authenticate') - ); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php deleted file mode 100644 index 31a86f9ed..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Auth\Backend; - -class FileTest extends \PHPUnit\Framework\TestCase -{ - public function teardown(): void - { - if (file_exists(SABRE_TEMPDIR.'/filebackend')) { - unlink(SABRE_TEMPDIR.'/filebackend'); - } - } - - public function testConstruct() - { - $file = new File(); - $this->assertTrue($file instanceof File); - } - - public function testLoadFileBroken() - { - $this->expectException('Sabre\DAV\Exception'); - file_put_contents(SABRE_TEMPDIR.'/backend', 'user:realm:hash'); - $file = new File(SABRE_TEMPDIR.'/backend'); - } - - public function testLoadFile() - { - file_put_contents(SABRE_TEMPDIR.'/backend', 'user:realm:'.md5('user:realm:password')); - $file = new File(); - $file->loadFile(SABRE_TEMPDIR.'/backend'); - - $this->assertFalse($file->getDigestHash('realm', 'blabla')); - $this->assertEquals(md5('user:realm:password'), $file->getDigestHash('realm', 'user')); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php deleted file mode 100644 index fca7f722f..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Auth\Backend; - -use Sabre\HTTP\RequestInterface; -use Sabre\HTTP\ResponseInterface; - -class Mock implements BackendInterface -{ - public $fail = false; - - public $invalidCheckResponse = false; - - public $principal = 'principals/admin'; - - public function setPrincipal($principal) - { - $this->principal = $principal; - } - - /** - * When this method is called, the backend must check if authentication was - * successful. - * - * The returned value must be one of the following - * - * [true, "principals/username"] - * [false, "reason for failure"] - * - * If authentication was successful, it's expected that the authentication - * backend returns a so-called principal url. - * - * Examples of a principal url: - * - * principals/admin - * principals/user1 - * principals/users/joe - * principals/uid/123457 - * - * If you don't use WebDAV ACL (RFC3744) we recommend that you simply - * return a string such as: - * - * principals/users/[username] - * - * @return array - */ - public function check(RequestInterface $request, ResponseInterface $response) - { - if ($this->invalidCheckResponse) { - return 'incorrect!'; - } - if ($this->fail) { - return [false, 'fail!']; - } - - return [true, $this->principal]; - } - - /** - * This method is called when a user could not be authenticated, and - * authentication was required for the current request. - * - * This gives you the oppurtunity to set authentication headers. The 401 - * status code will already be set. - * - * In this case of Basic Auth, this would for example mean that the - * following header needs to be set: - * - * $response->addHeader('WWW-Authenticate', 'Basic realm=SabreDAV'); - * - * Keep in mind that in the case of multiple authentication backends, other - * WWW-Authenticate headers may already have been set, and you'll want to - * append your own WWW-Authenticate header instead of overwriting the - * existing one. - */ - public function challenge(RequestInterface $request, ResponseInterface $response) - { - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php deleted file mode 100644 index 6ad7906c4..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Auth\Backend; - -class PDOMySQLTest extends AbstractPDOTest -{ - public $driver = 'mysql'; -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php deleted file mode 100644 index b42b40eff..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Auth\Backend; - -class PDOSqliteTest extends AbstractPDOTest -{ - public $driver = 'sqlite'; -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php deleted file mode 100644 index f4810d524..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php +++ /dev/null @@ -1,127 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Auth; - -use Sabre\DAV; -use Sabre\HTTP; - -class PluginTest extends \PHPUnit\Framework\TestCase -{ - public function testInit() - { - $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); - $plugin = new Plugin(new Backend\Mock()); - $this->assertTrue($plugin instanceof Plugin); - $fakeServer->addPlugin($plugin); - $this->assertEquals($plugin, $fakeServer->getPlugin('auth')); - $this->assertIsArray($plugin->getPluginInfo()); - } - - /** - * @depends testInit - */ - public function testAuthenticate() - { - $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); - $plugin = new Plugin(new Backend\Mock()); - $fakeServer->addPlugin($plugin); - $this->assertTrue( - $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]) - ); - } - - /** - * @depends testInit - */ - public function testAuthenticateFail() - { - $this->expectException('Sabre\DAV\Exception\NotAuthenticated'); - $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); - $backend = new Backend\Mock(); - $backend->fail = true; - - $plugin = new Plugin($backend); - $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); - } - - /** - * @depends testAuthenticateFail - */ - public function testAuthenticateFailDontAutoRequire() - { - $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); - $backend = new Backend\Mock(); - $backend->fail = true; - - $plugin = new Plugin($backend); - $plugin->autoRequireLogin = false; - $fakeServer->addPlugin($plugin); - $this->assertTrue( - $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]) - ); - $this->assertEquals(1, count($plugin->getLoginFailedReasons())); - } - - /** - * @depends testAuthenticate - */ - public function testMultipleBackend() - { - $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); - $backend1 = new Backend\Mock(); - $backend2 = new Backend\Mock(); - $backend2->fail = true; - - $plugin = new Plugin(); - $plugin->addBackend($backend1); - $plugin->addBackend($backend2); - - $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); - - $this->assertEquals('principals/admin', $plugin->getCurrentPrincipal()); - } - - /** - * @depends testInit - */ - public function testNoAuthBackend() - { - $this->expectException('Sabre\DAV\Exception'); - $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); - - $plugin = new Plugin(); - $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); - } - - /** - * @depends testInit - */ - public function testInvalidCheckResponse() - { - $this->expectException('Sabre\DAV\Exception'); - $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); - $backend = new Backend\Mock(); - $backend->invalidCheckResponse = true; - - $plugin = new Plugin($backend); - $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); - } - - /** - * @depends testAuthenticate - */ - public function testGetCurrentPrincipal() - { - $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); - $plugin = new Plugin(new Backend\Mock()); - $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); - $this->assertEquals('principals/admin', $plugin->getCurrentPrincipal()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php deleted file mode 100644 index e9a8eddad..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php +++ /dev/null @@ -1,124 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -class BasicNodeTest extends \PHPUnit\Framework\TestCase -{ - public function testPut() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $file = new FileMock(); - $file->put('hi'); - } - - public function testGet() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $file = new FileMock(); - $file->get(); - } - - public function testGetSize() - { - $file = new FileMock(); - $this->assertEquals(0, $file->getSize()); - } - - public function testGetETag() - { - $file = new FileMock(); - $this->assertNull($file->getETag()); - } - - public function testGetContentType() - { - $file = new FileMock(); - $this->assertNull($file->getContentType()); - } - - public function testDelete() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $file = new FileMock(); - $file->delete(); - } - - public function testSetName() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $file = new FileMock(); - $file->setName('hi'); - } - - public function testGetLastModified() - { - $file = new FileMock(); - // checking if lastmod is within the range of a few seconds - $lastMod = $file->getLastModified(); - $compareTime = ($lastMod + 1) - time(); - $this->assertTrue($compareTime < 3); - } - - public function testGetChild() - { - $dir = new DirectoryMock(); - $file = $dir->getChild('mockfile'); - $this->assertTrue($file instanceof FileMock); - } - - public function testChildExists() - { - $dir = new DirectoryMock(); - $this->assertTrue($dir->childExists('mockfile')); - } - - public function testChildExistsFalse() - { - $dir = new DirectoryMock(); - $this->assertFalse($dir->childExists('mockfile2')); - } - - public function testGetChild404() - { - $this->expectException('Sabre\DAV\Exception\NotFound'); - $dir = new DirectoryMock(); - $file = $dir->getChild('blabla'); - } - - public function testCreateFile() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $dir = new DirectoryMock(); - $dir->createFile('hello', 'data'); - } - - public function testCreateDirectory() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $dir = new DirectoryMock(); - $dir->createDirectory('hello'); - } -} - -class DirectoryMock extends Collection -{ - public function getName() - { - return 'mockdir'; - } - - public function getChildren() - { - return [new FileMock()]; - } -} - -class FileMock extends File -{ - public function getName() - { - return 'mockfile'; - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php deleted file mode 100644 index cb4d3ce03..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Browser; - -use Sabre\DAV; - -class GuessContentTypeTest extends DAV\AbstractServer -{ - public function setUp(): void - { - parent::setUp(); - \Sabre\TestUtil::clearTempDir(); - file_put_contents(SABRE_TEMPDIR.'/somefile.jpg', 'blabla'); - file_put_contents(SABRE_TEMPDIR.'/somefile.hoi', 'blabla'); - } - - public function tearDown(): void - { - \Sabre\TestUtil::clearTempDir(); - parent::tearDown(); - } - - public function testGetProperties() - { - $properties = [ - '{DAV:}getcontenttype', - ]; - $result = $this->server->getPropertiesForPath('/somefile.jpg', $properties); - $this->assertArrayHasKey(0, $result); - $this->assertArrayHasKey(404, $result[0]); - $this->assertArrayHasKey('{DAV:}getcontenttype', $result[0][404]); - } - - /** - * @depends testGetProperties - */ - public function testGetPropertiesPluginEnabled() - { - $this->server->addPlugin(new GuessContentType()); - $properties = [ - '{DAV:}getcontenttype', - ]; - $result = $this->server->getPropertiesForPath('/somefile.jpg', $properties); - $this->assertArrayHasKey(0, $result); - $this->assertArrayHasKey(200, $result[0], 'We received: '.print_r($result, true)); - $this->assertArrayHasKey('{DAV:}getcontenttype', $result[0][200]); - $this->assertEquals('image/jpeg', $result[0][200]['{DAV:}getcontenttype']); - } - - /** - * @depends testGetPropertiesPluginEnabled - */ - public function testGetPropertiesUnknown() - { - $this->server->addPlugin(new GuessContentType()); - $properties = [ - '{DAV:}getcontenttype', - ]; - $result = $this->server->getPropertiesForPath('/somefile.hoi', $properties); - $this->assertArrayHasKey(0, $result); - $this->assertArrayHasKey(200, $result[0]); - $this->assertArrayHasKey('{DAV:}getcontenttype', $result[0][200]); - $this->assertEquals('application/octet-stream', $result[0][200]['{DAV:}getcontenttype']); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php deleted file mode 100644 index 00b2661ac..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Browser; - -use Sabre\DAV; -use Sabre\HTTP; - -class MapGetToPropFindTest extends DAV\AbstractServer -{ - public function setUp(): void - { - parent::setUp(); - $this->server->addPlugin(new MapGetToPropFind()); - } - - public function testCollectionGet() - { - $serverVars = [ - 'REQUEST_URI' => '/', - 'REQUEST_METHOD' => 'GET', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody(''); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals(207, $this->response->status, 'Incorrect status response received. Full response body: '.$this->response->getBodyAsString()); - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'DAV' => ['1, 3, extended-mkcol'], - 'Vary' => ['Brief,Prefer'], - ], - $this->response->getHeaders() - ); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php deleted file mode 100644 index a987525c0..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php +++ /dev/null @@ -1,176 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Browser; - -use Sabre\DAV; -use Sabre\HTTP; - -class PluginTest extends DAV\AbstractServer -{ - protected $plugin; - - public function setUp(): void - { - parent::setUp(); - $this->server->addPlugin($this->plugin = new Plugin()); - $this->server->tree->getNodeForPath('')->createDirectory('dir2'); - } - - public function testCollectionGet() - { - $request = new HTTP\Request('GET', '/dir'); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(200, $this->response->getStatus(), 'Incorrect status received. Full response body: '.$this->response->getBodyAsString()); - $this->assertEquals( - [ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['text/html; charset=utf-8'], - 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"], - ], - $this->response->getHeaders() - ); - - $body = $this->response->getBodyAsString(); - $this->assertTrue(false !== strpos($body, '<title>dir'), $body); - $this->assertTrue(false !== strpos($body, '<a href="/dir/child.txt">')); - } - - /** - * Adding the If-None-Match should have 0 effect, but it threw an error. - */ - public function testCollectionGetIfNoneMatch() - { - $request = new HTTP\Request('GET', '/dir'); - $request->setHeader('If-None-Match', '"foo-bar"'); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(200, $this->response->getStatus(), 'Incorrect status received. Full response body: '.$this->response->getBodyAsString()); - $this->assertEquals( - [ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['text/html; charset=utf-8'], - 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"], - ], - $this->response->getHeaders() - ); - - $body = $this->response->getBodyAsString(); - $this->assertTrue(false !== strpos($body, '<title>dir'), $body); - $this->assertTrue(false !== strpos($body, '<a href="/dir/child.txt">')); - } - - public function testCollectionGetRoot() - { - $request = new HTTP\Request('GET', '/'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals(200, $this->response->status, 'Incorrect status received. Full response body: '.$this->response->getBodyAsString()); - $this->assertEquals( - [ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['text/html; charset=utf-8'], - 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"], - ], - $this->response->getHeaders() - ); - - $body = $this->response->getBodyAsString(); - $this->assertTrue(false !== strpos($body, '<title>/'), $body); - $this->assertTrue(false !== strpos($body, '<a href="/dir/">')); - $this->assertTrue(false !== strpos($body, '<span class="btn disabled">')); - } - - public function testGETPassthru() - { - $request = new HTTP\Request('GET', '/random'); - $response = new HTTP\Response(); - $this->assertNull( - $this->plugin->httpGet($request, $response) - ); - } - - public function testPostOtherContentType() - { - $request = new HTTP\Request('POST', '/', ['Content-Type' => 'text/xml']); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(501, $this->response->status); - } - - public function testPostNoSabreAction() - { - $request = new HTTP\Request('POST', '/', ['Content-Type' => 'application/x-www-form-urlencoded']); - $request->setPostData([]); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(501, $this->response->status); - } - - public function testPostMkCol() - { - $serverVars = [ - 'REQUEST_URI' => '/', - 'REQUEST_METHOD' => 'POST', - 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', - ]; - $postVars = [ - 'sabreAction' => 'mkcol', - 'name' => 'new_collection', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setPostData($postVars); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(302, $this->response->status); - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Location' => ['/'], - ], $this->response->getHeaders()); - - $this->assertTrue(is_dir(SABRE_TEMPDIR.'/new_collection')); - } - - public function testGetAsset() - { - $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=favicon.ico'); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(200, $this->response->getStatus(), 'Error: '.$this->response->getBodyAsString()); - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['image/vnd.microsoft.icon'], - 'Content-Length' => ['4286'], - 'Cache-Control' => ['public, max-age=1209600'], - 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"], - ], $this->response->getHeaders()); - } - - public function testGetAsset404() - { - $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=flavicon.ico'); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(404, $this->response->getStatus(), 'Error: '.$this->response->getBodyAsString()); - } - - public function testGetAssetEscapeBasePath() - { - $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=./../assets/favicon.ico'); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(404, $this->response->getStatus(), 'Error: '.$this->response->getBodyAsString()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php b/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php deleted file mode 100644 index 7d787744a..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -use Sabre\HTTP\RequestInterface; -use Sabre\HTTP\ResponseInterface; - -class ClientMock extends Client -{ - public $request; - public $response; - - public $url; - public $curlSettings; - - /** - * Just making this method public. - * - * @param string $url - * - * @return string - */ - public function getAbsoluteUrl($url) - { - return parent::getAbsoluteUrl($url); - } - - public function doRequest(RequestInterface $request): ResponseInterface - { - $this->request = $request; - - return $this->response; - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ClientTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ClientTest.php deleted file mode 100644 index 85a95c90e..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/ClientTest.php +++ /dev/null @@ -1,285 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -use Sabre\HTTP\Response; - -class ClientTest extends \PHPUnit\Framework\TestCase -{ - public function setup(): void - { - if (!function_exists('curl_init')) { - $this->markTestSkipped('CURL must be installed to test the client'); - } - } - - public function testConstruct() - { - $client = new ClientMock([ - 'baseUri' => '/', - ]); - $this->assertInstanceOf('Sabre\DAV\ClientMock', $client); - } - - public function testConstructNoBaseUri() - { - $this->expectException('InvalidArgumentException'); - $client = new ClientMock([]); - } - - public function testAuth() - { - $client = new ClientMock([ - 'baseUri' => '/', - 'userName' => 'foo', - 'password' => 'bar', - ]); - - $this->assertEquals('foo:bar', $client->curlSettings[CURLOPT_USERPWD]); - $this->assertEquals(CURLAUTH_BASIC | CURLAUTH_DIGEST, $client->curlSettings[CURLOPT_HTTPAUTH]); - } - - public function testBasicAuth() - { - $client = new ClientMock([ - 'baseUri' => '/', - 'userName' => 'foo', - 'password' => 'bar', - 'authType' => Client::AUTH_BASIC, - ]); - - $this->assertEquals('foo:bar', $client->curlSettings[CURLOPT_USERPWD]); - $this->assertEquals(CURLAUTH_BASIC, $client->curlSettings[CURLOPT_HTTPAUTH]); - } - - public function testDigestAuth() - { - $client = new ClientMock([ - 'baseUri' => '/', - 'userName' => 'foo', - 'password' => 'bar', - 'authType' => Client::AUTH_DIGEST, - ]); - - $this->assertEquals('foo:bar', $client->curlSettings[CURLOPT_USERPWD]); - $this->assertEquals(CURLAUTH_DIGEST, $client->curlSettings[CURLOPT_HTTPAUTH]); - } - - public function testNTLMAuth() - { - $client = new ClientMock([ - 'baseUri' => '/', - 'userName' => 'foo', - 'password' => 'bar', - 'authType' => Client::AUTH_NTLM, - ]); - - $this->assertEquals('foo:bar', $client->curlSettings[CURLOPT_USERPWD]); - $this->assertEquals(CURLAUTH_NTLM, $client->curlSettings[CURLOPT_HTTPAUTH]); - } - - public function testProxy() - { - $client = new ClientMock([ - 'baseUri' => '/', - 'proxy' => 'localhost:8888', - ]); - - $this->assertEquals('localhost:8888', $client->curlSettings[CURLOPT_PROXY]); - } - - public function testEncoding() - { - $client = new ClientMock([ - 'baseUri' => '/', - 'encoding' => Client::ENCODING_IDENTITY | Client::ENCODING_GZIP | Client::ENCODING_DEFLATE, - ]); - - $this->assertEquals('identity,deflate,gzip', $client->curlSettings[CURLOPT_ENCODING]); - } - - public function testPropFind() - { - $client = new ClientMock([ - 'baseUri' => '/', - ]); - - $responseBody = <<<XML -<?xml version="1.0"?> -<multistatus xmlns="DAV:"> - <response> - <href>/foo</href> - <propstat> - <prop> - <displayname>bar</displayname> - </prop> - <status>HTTP/1.1 200 OK</status> - </propstat> - </response> -</multistatus> -XML; - - $client->response = new Response(207, [], $responseBody); - $result = $client->propFind('foo', ['{DAV:}displayname', '{urn:zim}gir']); - - $this->assertEquals(['{DAV:}displayname' => 'bar'], $result); - - $request = $client->request; - $this->assertEquals('PROPFIND', $request->getMethod()); - $this->assertEquals('/foo', $request->getUrl()); - $this->assertEquals([ - 'Depth' => ['0'], - 'Content-Type' => ['application/xml'], - ], $request->getHeaders()); - } - - public function testPropFindError() - { - $this->expectException('Sabre\HTTP\ClientHttpException'); - $client = new ClientMock([ - 'baseUri' => '/', - ]); - - $client->response = new Response(405, []); - $client->propFind('foo', ['{DAV:}displayname', '{urn:zim}gir']); - } - - public function testPropFindDepth1() - { - $client = new ClientMock([ - 'baseUri' => '/', - ]); - - $responseBody = <<<XML -<?xml version="1.0"?> -<multistatus xmlns="DAV:"> - <response> - <href>/foo</href> - <propstat> - <prop> - <displayname>bar</displayname> - </prop> - <status>HTTP/1.1 200 OK</status> - </propstat> - </response> -</multistatus> -XML; - - $client->response = new Response(207, [], $responseBody); - $result = $client->propFind('foo', ['{DAV:}displayname', '{urn:zim}gir'], 1); - - $this->assertEquals([ - '/foo' => [ - '{DAV:}displayname' => 'bar', - ], - ], $result); - - $request = $client->request; - $this->assertEquals('PROPFIND', $request->getMethod()); - $this->assertEquals('/foo', $request->getUrl()); - $this->assertEquals([ - 'Depth' => ['1'], - 'Content-Type' => ['application/xml'], - ], $request->getHeaders()); - } - - public function testPropPatch() - { - $client = new ClientMock([ - 'baseUri' => '/', - ]); - - $responseBody = <<<XML -<?xml version="1.0"?> -<multistatus xmlns="DAV:"> - <response> - <href>/foo</href> - <propstat> - <prop> - <displayname>bar</displayname> - </prop> - <status>HTTP/1.1 200 OK</status> - </propstat> - </response> -</multistatus> -XML; - - $client->response = new Response(207, [], $responseBody); - $result = $client->propPatch('foo', ['{DAV:}displayname' => 'hi', '{urn:zim}gir' => null]); - $this->assertTrue($result); - $request = $client->request; - $this->assertEquals('PROPPATCH', $request->getMethod()); - $this->assertEquals('/foo', $request->getUrl()); - $this->assertEquals([ - 'Content-Type' => ['application/xml'], - ], $request->getHeaders()); - } - - /** - * @depends testPropPatch - */ - public function testPropPatchHTTPError() - { - $this->expectException('Sabre\HTTP\ClientHttpException'); - $client = new ClientMock([ - 'baseUri' => '/', - ]); - - $client->response = new Response(403, [], ''); - $client->propPatch('foo', ['{DAV:}displayname' => 'hi', '{urn:zim}gir' => null]); - } - - /** - * @depends testPropPatch - */ - public function testPropPatchMultiStatusError() - { - $this->expectException('Sabre\HTTP\ClientException'); - $client = new ClientMock([ - 'baseUri' => '/', - ]); - - $responseBody = <<<XML -<?xml version="1.0"?> -<multistatus xmlns="DAV:"> -<response> - <href>/foo</href> - <propstat> - <prop> - <displayname /> - </prop> - <status>HTTP/1.1 403 Forbidden</status> - </propstat> -</response> -</multistatus> -XML; - - $client->response = new Response(207, [], $responseBody); - $client->propPatch('foo', ['{DAV:}displayname' => 'hi', '{urn:zim}gir' => null]); - } - - public function testOPTIONS() - { - $client = new ClientMock([ - 'baseUri' => '/', - ]); - - $client->response = new Response(207, [ - 'DAV' => 'calendar-access, extended-mkcol', - ]); - $result = $client->options(); - - $this->assertEquals( - ['calendar-access', 'extended-mkcol'], - $result - ); - - $request = $client->request; - $this->assertEquals('OPTIONS', $request->getMethod()); - $this->assertEquals('/', $request->getUrl()); - $this->assertEquals([ - ], $request->getHeaders()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php deleted file mode 100644 index 5fc271587..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Exception; - -use DOMDocument; -use Sabre\DAV; - -class LockedTest extends \PHPUnit\Framework\TestCase -{ - public function testSerialize() - { - $dom = new DOMDocument('1.0'); - $dom->formatOutput = true; - $root = $dom->createElement('d:root'); - - $dom->appendChild($root); - $root->setAttribute('xmlns:d', 'DAV:'); - - $lockInfo = new DAV\Locks\LockInfo(); - $lockInfo->uri = '/foo'; - $locked = new Locked($lockInfo); - - $locked->serialize(new DAV\Server(), $root); - - $output = $dom->saveXML(); - - $expected = '<?xml version="1.0"?> -<d:root xmlns:d="DAV:"> - <d:lock-token-submitted xmlns:d="DAV:"> - <d:href>/foo</d:href> - </d:lock-token-submitted> -</d:root> -'; - - $this->assertEquals($expected, $output); - } - - public function testSerializeAmpersand() - { - $dom = new DOMDocument('1.0'); - $dom->formatOutput = true; - $root = $dom->createElement('d:root'); - - $dom->appendChild($root); - $root->setAttribute('xmlns:d', 'DAV:'); - - $lockInfo = new DAV\Locks\LockInfo(); - $lockInfo->uri = '/foo&bar'; - $locked = new Locked($lockInfo); - - $locked->serialize(new DAV\Server(), $root); - - $output = $dom->saveXML(); - - $expected = '<?xml version="1.0"?> -<d:root xmlns:d="DAV:"> - <d:lock-token-submitted xmlns:d="DAV:"> - <d:href>/foo&bar</d:href> - </d:lock-token-submitted> -</d:root> -'; - - $this->assertEquals($expected, $output); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Exception/PaymentRequiredTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Exception/PaymentRequiredTest.php deleted file mode 100644 index 42775a313..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Exception/PaymentRequiredTest.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Exception; - -class PaymentRequiredTest extends \PHPUnit\Framework\TestCase -{ - public function testGetHTTPCode() - { - $ex = new PaymentRequired(); - $this->assertEquals(402, $ex->getHTTPCode()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php deleted file mode 100644 index 7237aea0d..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -class ExceptionTest extends \PHPUnit\Framework\TestCase -{ - public function testStatus() - { - $e = new Exception(); - $this->assertEquals(500, $e->getHTTPCode()); - } - - public function testExceptionStatuses() - { - $c = [ - 'Sabre\\DAV\\Exception\\NotAuthenticated' => 401, - 'Sabre\\DAV\\Exception\\InsufficientStorage' => 507, - ]; - - foreach ($c as $class => $status) { - $obj = new $class(); - $this->assertEquals($status, $obj->getHTTPCode()); - } - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php deleted file mode 100644 index 2b759e5d0..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\FSExt; - -class FileTest extends \PHPUnit\Framework\TestCase -{ - public function setup(): void - { - file_put_contents(SABRE_TEMPDIR.'/file.txt', 'Contents'); - } - - public function teardown(): void - { - \Sabre\TestUtil::clearTempDir(); - } - - public function testPut() - { - $filename = SABRE_TEMPDIR.'/file.txt'; - $file = new File($filename); - $result = $file->put('New contents'); - - $this->assertEquals('New contents', file_get_contents(SABRE_TEMPDIR.'/file.txt')); - $this->assertEquals( - '"'. - sha1( - fileinode($filename). - filesize($filename). - filemtime($filename) - ).'"', - $result - ); - } - - public function testRange() - { - $file = new File(SABRE_TEMPDIR.'/file.txt'); - $file->put('0000000'); - $file->patch('111', 2, 3); - - $this->assertEquals('0001110', file_get_contents(SABRE_TEMPDIR.'/file.txt')); - } - - public function testRangeStream() - { - $stream = fopen('php://memory', 'r+'); - fwrite($stream, '222'); - rewind($stream); - - $file = new File(SABRE_TEMPDIR.'/file.txt'); - $file->put('0000000'); - $file->patch($stream, 2, 3); - - $this->assertEquals('0002220', file_get_contents(SABRE_TEMPDIR.'/file.txt')); - } - - public function testGet() - { - $file = new File(SABRE_TEMPDIR.'/file.txt'); - $this->assertEquals('Contents', stream_get_contents($file->get())); - } - - public function testDelete() - { - $file = new File(SABRE_TEMPDIR.'/file.txt'); - $file->delete(); - - $this->assertFalse(file_exists(SABRE_TEMPDIR.'/file.txt')); - } - - public function testGetETag() - { - $filename = SABRE_TEMPDIR.'/file.txt'; - $file = new File($filename); - $this->assertEquals( - '"'. - sha1( - fileinode($filename). - filesize($filename). - filemtime($filename) - ).'"', - $file->getETag() - ); - } - - public function testGetContentType() - { - $file = new File(SABRE_TEMPDIR.'/file.txt'); - $this->assertNull($file->getContentType()); - } - - public function testGetSize() - { - $file = new File(SABRE_TEMPDIR.'/file.txt'); - $this->assertEquals(8, $file->getSize()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php deleted file mode 100644 index 79ffb0186..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php +++ /dev/null @@ -1,252 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\FSExt; - -use Sabre\DAV; -use Sabre\HTTP; - -class ServerTest extends DAV\AbstractServer -{ - protected function getRootNode() - { - return new Directory($this->tempDir); - } - - public function testGet() - { - $request = new HTTP\Request('GET', '/test.txt'); - $filename = $this->tempDir.'/test.txt'; - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(200, $this->response->getStatus(), 'Invalid status code received.'); - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [13], - 'Last-Modified' => [HTTP\toDate(new \DateTime('@'.filemtime($filename)))], - 'ETag' => ['"'.sha1(fileinode($filename).filesize($filename).filemtime($filename)).'"'], - ], - $this->response->getHeaders() - ); - - $this->assertEquals('Test contents', $this->response->getBodyAsString()); - } - - public function testHEAD() - { - $request = new HTTP\Request('HEAD', '/test.txt'); - $filename = $this->tempDir.'/test.txt'; - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [13], - 'Last-Modified' => [HTTP\toDate(new \DateTime('@'.filemtime($this->tempDir.'/test.txt')))], - 'ETag' => ['"'.sha1(fileinode($filename).filesize($filename).filemtime($filename)).'"'], - ], - $this->response->getHeaders() - ); - - $this->assertEquals(200, $this->response->status); - $this->assertEquals('', $this->response->getBodyAsString()); - } - - public function testPut() - { - $request = new HTTP\Request('PUT', '/testput.txt'); - $filename = $this->tempDir.'/testput.txt'; - $request->setBody('Testing new file'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"'.sha1(fileinode($filename).filesize($filename).filemtime($filename)).'"'], - ], $this->response->getHeaders()); - - $this->assertEquals(201, $this->response->status); - $this->assertEquals('', $this->response->getBodyAsString()); - $this->assertEquals('Testing new file', file_get_contents($filename)); - } - - public function testPutAlreadyExists() - { - $request = new HTTP\Request('PUT', '/test.txt', ['If-None-Match' => '*']); - $request->setBody('Testing new file'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ], $this->response->getHeaders()); - - $this->assertEquals(412, $this->response->status); - $this->assertNotEquals('Testing new file', file_get_contents($this->tempDir.'/test.txt')); - } - - public function testMkcol() - { - $request = new HTTP\Request('MKCOL', '/testcol'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], - ], $this->response->getHeaders()); - - $this->assertEquals(201, $this->response->status); - $this->assertEquals('', $this->response->getBodyAsString()); - $this->assertTrue(is_dir($this->tempDir.'/testcol')); - } - - public function testPutUpdate() - { - $request = new HTTP\Request('PUT', '/test.txt'); - $request->setBody('Testing updated file'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals('0', $this->response->getHeader('Content-Length')); - - $this->assertEquals(204, $this->response->status); - $this->assertEquals('', $this->response->getBodyAsString()); - $this->assertEquals('Testing updated file', file_get_contents($this->tempDir.'/test.txt')); - } - - public function testDelete() - { - $request = new HTTP\Request('DELETE', '/test.txt'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], - ], $this->response->getHeaders()); - - $this->assertEquals(204, $this->response->status); - $this->assertEquals('', $this->response->getBodyAsString()); - $this->assertFalse(file_exists($this->tempDir.'/test.txt')); - } - - public function testDeleteDirectory() - { - mkdir($this->tempDir.'/testcol'); - file_put_contents($this->tempDir.'/testcol/test.txt', 'Hi! I\'m a file with a short lifespan'); - - $request = new HTTP\Request('DELETE', '/testcol'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], - ], $this->response->getHeaders()); - $this->assertEquals(204, $this->response->status); - $this->assertEquals('', $this->response->getBodyAsString()); - $this->assertFalse(file_exists($this->tempDir.'/testcol')); - } - - public function testOptions() - { - $request = new HTTP\Request('OPTIONS', '/'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'DAV' => ['1, 3, extended-mkcol'], - 'MS-Author-Via' => ['DAV'], - 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'], - 'Accept-Ranges' => ['bytes'], - 'Content-Length' => ['0'], - 'X-Sabre-Version' => [DAV\Version::VERSION], - ], $this->response->getHeaders()); - - $this->assertEquals(200, $this->response->status); - $this->assertEquals('', $this->response->getBodyAsString()); - } - - public function testMove() - { - mkdir($this->tempDir.'/testcol'); - - $request = new HTTP\Request('MOVE', '/test.txt', ['Destination' => '/testcol/test2.txt']); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals(201, $this->response->status); - $this->assertEquals('', $this->response->getBodyAsString()); - - $this->assertEquals([ - 'Content-Length' => ['0'], - 'X-Sabre-Version' => [DAV\Version::VERSION], - ], $this->response->getHeaders()); - - $this->assertTrue( - is_file($this->tempDir.'/testcol/test2.txt') - ); - } - - /** - * This test checks if it's possible to move a non-FSExt collection into a - * FSExt collection. - * - * The moveInto function *should* ignore the object and let sabredav itself - * execute the slow move. - */ - public function testMoveOtherObject() - { - mkdir($this->tempDir.'/tree1'); - mkdir($this->tempDir.'/tree2'); - - $tree = new DAV\Tree(new DAV\SimpleCollection('root', [ - new DAV\FS\Directory($this->tempDir.'/tree1'), - new DAV\FSExt\Directory($this->tempDir.'/tree2'), - ])); - $this->server->tree = $tree; - - $request = new HTTP\Request('MOVE', '/tree1', ['Destination' => '/tree2/tree1']); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals(201, $this->response->status); - $this->assertEquals('', $this->response->getBodyAsString()); - - $this->assertEquals([ - 'Content-Length' => ['0'], - 'X-Sabre-Version' => [DAV\Version::VERSION], - ], $this->response->getHeaders()); - - $this->assertTrue( - is_dir($this->tempDir.'/tree2/tree1') - ); - } - - public function testCopy() - { - mkdir($this->tempDir.'/testcol'); - - $request = new HTTP\Request('COPY', '/test.txt', ['Destination' => '/testcol/test2.txt']); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals(201, $this->response->status); - $this->assertEquals('', $this->response->getBodyAsString()); - - $this->assertEquals([ - 'Content-Length' => ['0'], - 'X-Sabre-Version' => [DAV\Version::VERSION], - ], $this->response->getHeaders()); - - $this->assertTrue(is_file($this->tempDir.'/test.txt')); - $this->assertTrue(is_file($this->tempDir.'/testcol/test2.txt')); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php b/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php deleted file mode 100644 index 7d6825612..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php +++ /dev/null @@ -1,175 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -use Sabre\HTTP; - -class HTTPPreferParsingTest extends \Sabre\DAVServerTest -{ - public function assertParseResult($input, $expected) - { - $httpRequest = new HTTP\Request('GET', '/foo', [ - 'Prefer' => $input, - ]); - - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals( - $expected, - $server->getHTTPPrefer() - ); - } - - public function testParseSimple() - { - $this->assertParseResult( - 'return-asynch', - [ - 'respond-async' => true, - 'return' => null, - 'handling' => null, - 'wait' => null, - ] - ); - } - - public function testParseValue() - { - $this->assertParseResult( - 'wait=10', - [ - 'respond-async' => false, - 'return' => null, - 'handling' => null, - 'wait' => '10', - ] - ); - } - - public function testParseMultiple() - { - $this->assertParseResult( - 'return-minimal, strict,lenient', - [ - 'respond-async' => false, - 'return' => 'minimal', - 'handling' => 'lenient', - 'wait' => null, - ] - ); - } - - public function testParseWeirdValue() - { - $this->assertParseResult( - 'BOOOH', - [ - 'respond-async' => false, - 'return' => null, - 'handling' => null, - 'wait' => null, - 'boooh' => true, - ] - ); - } - - public function testBrief() - { - $httpRequest = new HTTP\Request('GET', '/foo', [ - 'Brief' => 't', - ]); - - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals([ - 'respond-async' => false, - 'return' => 'minimal', - 'handling' => null, - 'wait' => null, - ], $server->getHTTPPrefer()); - } - - /** - * propfindMinimal. - */ - public function testpropfindMinimal() - { - $request = new HTTP\Request('PROPFIND', '/', [ - 'Prefer' => 'return-minimal', - ]); - $request->setBody(<<<BLA -<?xml version="1.0"?> -<d:propfind xmlns:d="DAV:"> - <d:prop> - <d:something /> - <d:resourcetype /> - </d:prop> -</d:propfind> -BLA - ); - - $response = $this->request($request); - - $body = $response->getBodyAsString(); - - $this->assertEquals(207, $response->getStatus(), $body); - - $this->assertTrue(false !== strpos($body, 'resourcetype'), $body); - $this->assertTrue(false === strpos($body, 'something'), $body); - } - - public function testproppatchMinimal() - { - $request = new HTTP\Request('PROPPATCH', '/', ['Prefer' => 'return-minimal']); - $request->setBody(<<<BLA -<?xml version="1.0"?> -<d:propertyupdate xmlns:d="DAV:"> - <d:set> - <d:prop> - <d:something>nope!</d:something> - </d:prop> - </d:set> -</d:propertyupdate> -BLA - ); - - $this->server->on('propPatch', function ($path, PropPatch $propPatch) { - $propPatch->handle('{DAV:}something', function ($props) { - return true; - }); - }); - - $response = $this->request($request); - - $this->assertEquals('', $response->getBodyAsString(), 'Expected empty body: '.$response->getBodyAsString()); - $this->assertEquals(204, $response->status); - } - - public function testproppatchMinimalError() - { - $request = new HTTP\Request('PROPPATCH', '/', ['Prefer' => 'return-minimal']); - $request->setBody(<<<BLA -<?xml version="1.0"?> -<d:propertyupdate xmlns:d="DAV:"> - <d:set> - <d:prop> - <d:something>nope!</d:something> - </d:prop> - </d:set> -</d:propertyupdate> -BLA - ); - - $response = $this->request($request); - - $body = $response->getBodyAsString(); - - $this->assertEquals(207, $response->status); - $this->assertTrue(false !== strpos($body, 'something')); - $this->assertTrue(false !== strpos($body, '403 Forbidden'), $body); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php b/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php deleted file mode 100644 index f70febabd..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php +++ /dev/null @@ -1,131 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -use Sabre\DAVServerTest; -use Sabre\HTTP; - -/** - * Tests related to the PUT request. - * - * @copyright Copyright (C) fruux GmbH (https://fruux.com/) - * @author Evert Pot (http://evertpot.com/) - * @license http://sabre.io/license/ Modified BSD License - */ -class HttpDeleteTest extends DAVServerTest -{ - /** - * Sets up the DAV tree. - */ - public function setUpTree() - { - $this->tree = new Mock\Collection('root', [ - 'file1' => 'foo', - 'dir' => [ - 'subfile' => 'bar', - 'subfile2' => 'baz', - ], - ]); - } - - /** - * A successful DELETE. - */ - public function testDelete() - { - $request = new HTTP\Request('DELETE', '/file1'); - - $response = $this->request($request); - - $this->assertEquals( - 204, - $response->getStatus(), - 'Incorrect status code. Response body: '.$response->getBodyAsString() - ); - - $this->assertEquals( - [ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - ], - $response->getHeaders() - ); - } - - /** - * Deleting a Directory. - */ - public function testDeleteDirectory() - { - $request = new HTTP\Request('DELETE', '/dir'); - - $response = $this->request($request); - - $this->assertEquals( - 204, - $response->getStatus(), - 'Incorrect status code. Response body: '.$response->getBodyAsString() - ); - - $this->assertEquals( - [ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - ], - $response->getHeaders() - ); - } - - /** - * DELETE on a node that does not exist. - */ - public function testDeleteNotFound() - { - $request = new HTTP\Request('DELETE', '/file2'); - $response = $this->request($request); - - $this->assertEquals( - 404, - $response->getStatus(), - 'Incorrect status code. Response body: '.$response->getBodyAsString() - ); - } - - /** - * DELETE with preconditions. - */ - public function testDeletePreconditions() - { - $request = new HTTP\Request('DELETE', '/file1', [ - 'If-Match' => '"'.md5('foo').'"', - ]); - - $response = $this->request($request); - - $this->assertEquals( - 204, - $response->getStatus(), - 'Incorrect status code. Response body: '.$response->getBodyAsString() - ); - } - - /** - * DELETE with incorrect preconditions. - */ - public function testDeletePreconditionsFailed() - { - $request = new HTTP\Request('DELETE', '/file1', [ - 'If-Match' => '"'.md5('bar').'"', - ]); - - $response = $this->request($request); - - $this->assertEquals( - 412, - $response->getStatus(), - 'Incorrect status code. Response body: '.$response->getBodyAsString() - ); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/HttpPutTest.php b/vendor/sabre/dav/tests/Sabre/DAV/HttpPutTest.php deleted file mode 100644 index 543ec652a..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/HttpPutTest.php +++ /dev/null @@ -1,354 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -use Sabre\DAVServerTest; -use Sabre\HTTP; - -/** - * Tests related to the PUT request. - * - * @copyright Copyright (C) fruux GmbH (https://fruux.com/) - * @author Evert Pot (http://evertpot.com/) - * @license http://sabre.io/license/ Modified BSD License - */ -class HttpPutTest extends DAVServerTest -{ - /** - * Sets up the DAV tree. - */ - public function setUpTree() - { - $this->tree = new Mock\Collection('root', [ - 'file1' => 'foo', - ]); - } - - /** - * A successful PUT of a new file. - */ - public function testPut() - { - $request = new HTTP\Request('PUT', '/file2', [], 'hello'); - - $response = $this->request($request); - - $this->assertEquals(201, $response->getStatus(), 'Incorrect status code received. Full response body:'.$response->getBodyAsString()); - - $this->assertEquals( - 'hello', - $this->server->tree->getNodeForPath('file2')->get() - ); - - $this->assertEquals( - [ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"'.md5('hello').'"'], - ], - $response->getHeaders() - ); - } - - /** - * A successful PUT on an existing file. - * - * @depends testPut - */ - public function testPutExisting() - { - $request = new HTTP\Request('PUT', '/file1', [], 'bar'); - - $response = $this->request($request); - - $this->assertEquals(204, $response->getStatus()); - - $this->assertEquals( - 'bar', - $this->server->tree->getNodeForPath('file1')->get() - ); - - $this->assertEquals( - [ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"'.md5('bar').'"'], - ], - $response->getHeaders() - ); - } - - /** - * PUT on existing file with If-Match: *. - * - * @depends testPutExisting - */ - public function testPutExistingIfMatchStar() - { - $request = new HTTP\Request( - 'PUT', - '/file1', - ['If-Match' => '*'], - 'hello' - ); - - $response = $this->request($request); - - $this->assertEquals(204, $response->getStatus()); - - $this->assertEquals( - 'hello', - $this->server->tree->getNodeForPath('file1')->get() - ); - - $this->assertEquals( - [ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"'.md5('hello').'"'], - ], - $response->getHeaders() - ); - } - - /** - * PUT on existing file with If-Match: with a correct etag. - * - * @depends testPutExisting - */ - public function testPutExistingIfMatchCorrect() - { - $request = new HTTP\Request( - 'PUT', - '/file1', - ['If-Match' => '"'.md5('foo').'"'], - 'hello' - ); - - $response = $this->request($request); - - $this->assertEquals(204, $response->status); - - $this->assertEquals( - 'hello', - $this->server->tree->getNodeForPath('file1')->get() - ); - - $this->assertEquals( - [ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"'.md5('hello').'"'], - ], - $response->getHeaders() - ); - } - - /** - * PUT with Content-Range should be rejected. - * - * @depends testPut - */ - public function testPutContentRange() - { - $request = new HTTP\Request( - 'PUT', - '/file2', - ['Content-Range' => 'bytes/100-200'], - 'hello' - ); - - $response = $this->request($request); - $this->assertEquals(400, $response->getStatus()); - } - - /** - * PUT on non-existing file with If-None-Match: * should work. - * - * @depends testPut - */ - public function testPutIfNoneMatchStar() - { - $request = new HTTP\Request( - 'PUT', - '/file2', - ['If-None-Match' => '*'], - 'hello' - ); - - $response = $this->request($request); - - $this->assertEquals(201, $response->getStatus()); - - $this->assertEquals( - 'hello', - $this->server->tree->getNodeForPath('file2')->get() - ); - - $this->assertEquals( - [ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"'.md5('hello').'"'], - ], - $response->getHeaders() - ); - } - - /** - * PUT on non-existing file with If-Match: * should fail. - * - * @depends testPut - */ - public function testPutIfMatchStar() - { - $request = new HTTP\Request( - 'PUT', - '/file2', - ['If-Match' => '*'], - 'hello' - ); - - $response = $this->request($request); - - $this->assertEquals(412, $response->getStatus()); - } - - /** - * PUT on existing file with If-None-Match: * should fail. - * - * @depends testPut - */ - public function testPutExistingIfNoneMatchStar() - { - $request = new HTTP\Request( - 'PUT', - '/file1', - ['If-None-Match' => '*'], - 'hello' - ); - $request->setBody('hello'); - - $response = $this->request($request); - - $this->assertEquals(412, $response->getStatus()); - } - - /** - * PUT thats created in a non-collection should be rejected. - * - * @depends testPut - */ - public function testPutParentIsNotCollection() - { - $request = new HTTP\Request( - 'PUT', - '/file1/file2', - [], - 'hello' - ); - - $response = $this->request($request); - $this->assertEquals(409, $response->getStatus()); - } - - /** - * PUT thats created in a non-existent collection should be rejected. - * - * @depends testPut - */ - public function testPutParentCollectionDoesNotExist() - { - $request = new HTTP\Request( - 'PUT', - '/non-existent-collection/file2', - [], - 'hello' - ); - - $response = $this->request($request); - $this->assertEquals(409, $response->getStatus()); - } - - /** - * Finder may sometimes make a request, which gets its content-body - * stripped. We can't always prevent this from happening, but in some cases - * we can detected this and return an error instead. - * - * @depends testPut - */ - public function testFinderPutSuccess() - { - $request = new HTTP\Request( - 'PUT', - '/file2', - ['X-Expected-Entity-Length' => '5'], - 'hello' - ); - $response = $this->request($request); - - $this->assertEquals(201, $response->getStatus()); - - $this->assertEquals( - 'hello', - $this->server->tree->getNodeForPath('file2')->get() - ); - - $this->assertEquals( - [ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"'.md5('hello').'"'], - ], - $response->getHeaders() - ); - } - - /** - * Same as the last one, but in this case we're mimicing a failed request. - * - * @depends testFinderPutSuccess - */ - public function testFinderPutFail() - { - $request = new HTTP\Request( - 'PUT', - '/file2', - ['X-Expected-Entity-Length' => '5'], - '' - ); - - $response = $this->request($request); - - $this->assertEquals(403, $response->getStatus()); - } - - /** - * Plugins can intercept PUT. We need to make sure that works. - * - * @depends testPut - */ - public function testPutIntercept() - { - $this->server->on('beforeBind', function ($uri) { - $this->server->httpResponse->setStatus(418); - - return false; - }); - - $request = new HTTP\Request('PUT', '/file2', [], 'hello'); - $response = $this->request($request); - - $this->assertEquals(418, $response->getStatus(), 'Incorrect status code received. Full response body: '.$response->getBodyAsString()); - - $this->assertFalse( - $this->server->tree->nodeExists('file2') - ); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - ], $response->getHeaders()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php b/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php deleted file mode 100644 index 36b182c44..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php +++ /dev/null @@ -1,93 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -use Sabre\HTTP; - -class Issue33Test extends \PHPUnit\Framework\TestCase -{ - public function setup(): void - { - \Sabre\TestUtil::clearTempDir(); - } - - public function testCopyMoveInfo() - { - $bar = new SimpleCollection('bar'); - $root = new SimpleCollection('webdav', [$bar]); - - $server = new Server($root); - $server->setBaseUri('/webdav/'); - - $request = new HTTP\Request('GET', '/webdav/bar', [ - 'Destination' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', - 'Overwrite' => 'F', - ]); - - $server->httpRequest = $request; - - $info = $server->getCopyAndMoveInfo($request); - - $this->assertEquals('%C3%A0fo%C3%B3', urlencode($info['destination'])); - $this->assertFalse($info['destinationExists']); - $this->assertFalse($info['destinationNode']); - } - - public function testTreeMove() - { - mkdir(SABRE_TEMPDIR.'/issue33'); - $dir = new FS\Directory(SABRE_TEMPDIR.'/issue33'); - - $dir->createDirectory('bar'); - - $tree = new Tree($dir); - $tree->move('bar', urldecode('%C3%A0fo%C3%B3')); - - $node = $tree->getNodeForPath(urldecode('%C3%A0fo%C3%B3')); - $this->assertEquals(urldecode('%C3%A0fo%C3%B3'), $node->getName()); - } - - public function testDirName() - { - $dirname1 = 'bar'; - $dirname2 = urlencode('%C3%A0fo%C3%B3'); - - $this->assertTrue(dirname($dirname1) == dirname($dirname2)); - } - - /** - * @depends testTreeMove - * @depends testCopyMoveInfo - */ - public function testEverything() - { - $request = new HTTP\Request('MOVE', '/webdav/bar', [ - 'Destination' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', - 'Overwrite' => 'F', - ]); - - $request->setBody(''); - - $response = new HTTP\ResponseMock(); - - // Server setup - mkdir(SABRE_TEMPDIR.'/issue33'); - $dir = new FS\Directory(SABRE_TEMPDIR.'/issue33'); - - $dir->createDirectory('bar'); - - $tree = new Tree($dir); - - $server = new Server($tree); - $server->setBaseUri('/webdav/'); - - $server->httpRequest = $request; - $server->httpResponse = $response; - $server->sapi = new HTTP\SapiMock(); - $server->exec(); - - $this->assertTrue(file_exists(SABRE_TEMPDIR.'/issue33/'.urldecode('%C3%A0fo%C3%B3'))); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php deleted file mode 100644 index d1cd1799c..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php +++ /dev/null @@ -1,189 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Locks\Backend; - -use Sabre\DAV; - -abstract class AbstractTest extends \PHPUnit\Framework\TestCase -{ - /** - * @abstract - * - * @return AbstractBackend - */ - abstract public function getBackend(); - - public function testSetup() - { - $backend = $this->getBackend(); - $this->assertInstanceOf('Sabre\\DAV\\Locks\\Backend\\AbstractBackend', $backend); - } - - /** - * @depends testSetup - */ - public function testGetLocks() - { - $backend = $this->getBackend(); - - $lock = new DAV\Locks\LockInfo(); - $lock->owner = 'Sinterklaas'; - $lock->timeout = 60; - $lock->created = time(); - $lock->token = 'MY-UNIQUE-TOKEN'; - $lock->uri = 'someuri'; - - $this->assertTrue($backend->lock('someuri', $lock)); - - $locks = $backend->getLocks('someuri', false); - - $this->assertEquals(1, count($locks)); - $this->assertEquals('Sinterklaas', $locks[0]->owner); - $this->assertEquals('someuri', $locks[0]->uri); - } - - /** - * @depends testGetLocks - */ - public function testGetLocksParent() - { - $backend = $this->getBackend(); - - $lock = new DAV\Locks\LockInfo(); - $lock->owner = 'Sinterklaas'; - $lock->timeout = 60; - $lock->created = time(); - $lock->depth = DAV\Server::DEPTH_INFINITY; - $lock->token = 'MY-UNIQUE-TOKEN'; - - $this->assertTrue($backend->lock('someuri', $lock)); - - $locks = $backend->getLocks('someuri/child', false); - - $this->assertEquals(1, count($locks)); - $this->assertEquals('Sinterklaas', $locks[0]->owner); - $this->assertEquals('someuri', $locks[0]->uri); - } - - /** - * @depends testGetLocks - */ - public function testGetLocksParentDepth0() - { - $backend = $this->getBackend(); - - $lock = new DAV\Locks\LockInfo(); - $lock->owner = 'Sinterklaas'; - $lock->timeout = 60; - $lock->created = time(); - $lock->depth = 0; - $lock->token = 'MY-UNIQUE-TOKEN'; - - $this->assertTrue($backend->lock('someuri', $lock)); - - $locks = $backend->getLocks('someuri/child', false); - - $this->assertEquals(0, count($locks)); - } - - public function testGetLocksChildren() - { - $backend = $this->getBackend(); - - $lock = new DAV\Locks\LockInfo(); - $lock->owner = 'Sinterklaas'; - $lock->timeout = 60; - $lock->created = time(); - $lock->depth = 0; - $lock->token = 'MY-UNIQUE-TOKEN'; - - $this->assertTrue($backend->lock('someuri/child', $lock)); - - $locks = $backend->getLocks('someuri/child', false); - $this->assertEquals(1, count($locks)); - - $locks = $backend->getLocks('someuri', false); - $this->assertEquals(0, count($locks)); - - $locks = $backend->getLocks('someuri', true); - $this->assertEquals(1, count($locks)); - } - - /** - * @depends testGetLocks - */ - public function testLockRefresh() - { - $backend = $this->getBackend(); - - $lock = new DAV\Locks\LockInfo(); - $lock->owner = 'Sinterklaas'; - $lock->timeout = 60; - $lock->created = time(); - $lock->token = 'MY-UNIQUE-TOKEN'; - - $this->assertTrue($backend->lock('someuri', $lock)); - /* Second time */ - - $lock->owner = 'Santa Clause'; - $this->assertTrue($backend->lock('someuri', $lock)); - - $locks = $backend->getLocks('someuri', false); - - $this->assertEquals(1, count($locks)); - - $this->assertEquals('Santa Clause', $locks[0]->owner); - $this->assertEquals('someuri', $locks[0]->uri); - } - - /** - * @depends testGetLocks - */ - public function testUnlock() - { - $backend = $this->getBackend(); - - $lock = new DAV\Locks\LockInfo(); - $lock->owner = 'Sinterklaas'; - $lock->timeout = 60; - $lock->created = time(); - $lock->token = 'MY-UNIQUE-TOKEN'; - - $this->assertTrue($backend->lock('someuri', $lock)); - - $locks = $backend->getLocks('someuri', false); - $this->assertEquals(1, count($locks)); - - $this->assertTrue($backend->unlock('someuri', $lock)); - - $locks = $backend->getLocks('someuri', false); - $this->assertEquals(0, count($locks)); - } - - /** - * @depends testUnlock - */ - public function testUnlockUnknownToken() - { - $backend = $this->getBackend(); - - $lock = new DAV\Locks\LockInfo(); - $lock->owner = 'Sinterklaas'; - $lock->timeout = 60; - $lock->created = time(); - $lock->token = 'MY-UNIQUE-TOKEN'; - - $this->assertTrue($backend->lock('someuri', $lock)); - - $locks = $backend->getLocks('someuri', false); - $this->assertEquals(1, count($locks)); - - $lock->token = 'SOME-OTHER-TOKEN'; - $this->assertFalse($backend->unlock('someuri', $lock)); - - $locks = $backend->getLocks('someuri', false); - $this->assertEquals(1, count($locks)); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FileTest.php deleted file mode 100644 index 57a3255c7..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FileTest.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Locks\Backend; - -class FileTest extends AbstractTest -{ - public function getBackend() - { - \Sabre\TestUtil::clearTempDir(); - $backend = new File(SABRE_TEMPDIR.'/lockdb'); - - return $backend; - } - - public function teardown(): void - { - \Sabre\TestUtil::clearTempDir(); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php deleted file mode 100644 index 86ffc0bb3..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Locks\Backend; - -class PDOMySQLTest extends PDOTest -{ - public $driver = 'mysql'; -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php deleted file mode 100644 index f5ed98f50..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Locks\Backend; - -abstract class PDOTest extends AbstractTest -{ - use \Sabre\DAV\DbTestHelperTrait; - - public function getBackend() - { - $this->dropTables('locks'); - $this->createSchema('locks'); - - $pdo = $this->getPDO(); - - return new PDO($pdo); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php deleted file mode 100644 index 02c3d39ba..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Locks; - -use Sabre\DAV; -use Sabre\HTTP; - -class MSWordTest extends \PHPUnit\Framework\TestCase -{ - public function teardown(): void - { - \Sabre\TestUtil::clearTempDir(); - } - - public function testLockEtc() - { - mkdir(SABRE_TEMPDIR.'/mstest'); - $tree = new DAV\FS\Directory(SABRE_TEMPDIR.'/mstest'); - - $server = new DAV\Server($tree); - $server->debugExceptions = true; - $locksBackend = new Backend\File(SABRE_TEMPDIR.'/locksdb'); - $locksPlugin = new Plugin($locksBackend); - $server->addPlugin($locksPlugin); - - $response1 = new HTTP\ResponseMock(); - - $server->httpRequest = $this->getLockRequest(); - $server->httpResponse = $response1; - $server->sapi = new HTTP\SapiMock(); - $server->exec(); - - $this->assertEquals(201, $server->httpResponse->getStatus(), 'Full response body:'.$response1->getBodyAsString()); - $this->assertTrue((bool) $server->httpResponse->getHeaders('Lock-Token')); - $lockToken = $server->httpResponse->getHeader('Lock-Token'); - - //sleep(10); - - $response2 = new HTTP\ResponseMock(); - - $server->httpRequest = $this->getLockRequest2(); - $server->httpResponse = $response2; - $server->exec(); - - $this->assertEquals(201, $server->httpResponse->status); - $this->assertTrue((bool) $server->httpResponse->getHeaders('Lock-Token')); - - //sleep(10); - - $response3 = new HTTP\ResponseMock(); - $server->httpRequest = $this->getPutRequest($lockToken); - $server->httpResponse = $response3; - $server->exec(); - - $this->assertEquals(204, $server->httpResponse->status); - } - - public function getLockRequest() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'LOCK', - 'HTTP_CONTENT_TYPE' => 'application/xml', - 'HTTP_TIMEOUT' => 'Second-3600', - 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', - ]); - - $request->setBody('<D:lockinfo xmlns:D="DAV:"> - <D:lockscope> - <D:exclusive /> - </D:lockscope> - <D:locktype> - <D:write /> - </D:locktype> - <D:owner> - <D:href>PC-Vista\User</D:href> - </D:owner> -</D:lockinfo>'); - - return $request; - } - - public function getLockRequest2() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'LOCK', - 'HTTP_CONTENT_TYPE' => 'application/xml', - 'HTTP_TIMEOUT' => 'Second-3600', - 'REQUEST_URI' => '/~$Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', - ]); - - $request->setBody('<D:lockinfo xmlns:D="DAV:"> - <D:lockscope> - <D:exclusive /> - </D:lockscope> - <D:locktype> - <D:write /> - </D:locktype> - <D:owner> - <D:href>PC-Vista\User</D:href> - </D:owner> -</D:lockinfo>'); - - return $request; - } - - public function getPutRequest($lockToken) - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', - 'HTTP_IF' => 'If: ('.$lockToken.')', - ]); - $request->setBody('FAKE BODY'); - - return $request; - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php deleted file mode 100644 index 9279afb5a..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php +++ /dev/null @@ -1,886 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Locks; - -use Sabre\DAV; -use Sabre\HTTP; - -class PluginTest extends DAV\AbstractServer -{ - /** - * @var Plugin - */ - protected $locksPlugin; - - public function setup(): void - { - parent::setUp(); - $locksBackend = new Backend\File(SABRE_TEMPDIR.'/locksdb'); - $locksPlugin = new Plugin($locksBackend); - $this->server->addPlugin($locksPlugin); - $this->locksPlugin = $locksPlugin; - } - - public function testGetInfo() - { - $this->assertArrayHasKey( - 'name', - $this->locksPlugin->getPluginInfo() - ); - } - - public function testGetFeatures() - { - $this->assertEquals([2], $this->locksPlugin->getFeatures()); - } - - public function testGetHTTPMethods() - { - $this->assertEquals(['LOCK', 'UNLOCK'], $this->locksPlugin->getHTTPMethods('')); - } - - public function testLockNoBody() - { - $request = new HTTP\Request('LOCK', '/test.txt'); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ], - $this->response->getHeaders() - ); - - $this->assertEquals(400, $this->response->status); - } - - public function testLock() - { - $request = new HTTP\Request('LOCK', '/test.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(200, $this->response->status, 'Got an incorrect status back. Response body: '.$this->response->getBodyAsString()); - - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->getBodyAsString()); - $xml = simplexml_load_string($body); - $xml->registerXPathNamespace('d', 'urn:DAV'); - - $elements = [ - '/d:prop', - '/d:prop/d:lockdiscovery', - '/d:prop/d:lockdiscovery/d:activelock', - '/d:prop/d:lockdiscovery/d:activelock/d:locktype', - '/d:prop/d:lockdiscovery/d:activelock/d:lockroot', - '/d:prop/d:lockdiscovery/d:activelock/d:lockroot/d:href', - '/d:prop/d:lockdiscovery/d:activelock/d:locktype/d:write', - '/d:prop/d:lockdiscovery/d:activelock/d:lockscope', - '/d:prop/d:lockdiscovery/d:activelock/d:lockscope/d:exclusive', - '/d:prop/d:lockdiscovery/d:activelock/d:depth', - '/d:prop/d:lockdiscovery/d:activelock/d:owner', - '/d:prop/d:lockdiscovery/d:activelock/d:timeout', - '/d:prop/d:lockdiscovery/d:activelock/d:locktoken', - '/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d:href', - ]; - - foreach ($elements as $elem) { - $data = $xml->xpath($elem); - $this->assertEquals(1, count($data), 'We expected 1 match for the xpath expression "'.$elem.'". '.count($data).' were found. Full response body: '.$this->response->getBodyAsString()); - } - - $depth = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:depth'); - $this->assertEquals('infinity', (string) $depth[0]); - - $token = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d:href'); - $this->assertEquals($this->response->getHeader('Lock-Token'), '<'.(string) $token[0].'>', 'Token in response body didn\'t match token in response header.'); - } - - public function testLockWithContext() - { - $request = new HTTP\Request('LOCK', '/baseuri/test.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->setBaseUri('baseuri'); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(200, $this->response->status, 'Got an incorrect status back. Response body: '.$this->response->getBodyAsString()); - - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->getBodyAsString()); - $xml = simplexml_load_string($body); - $xml->registerXPathNamespace('d', 'urn:DAV'); - - $lockRoot = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:lockroot/d:href'); - $this->assertEquals('baseuri/test.txt', (string) $lockRoot[0]); - } - - /** - * @depends testLock - */ - public function testDoubleLock() - { - $request = new HTTP\Request('LOCK', '/test.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->response = new HTTP\ResponseMock(); - $this->server->httpResponse = $this->response; - - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - - $this->assertEquals(423, $this->response->status, 'Full response: '.$this->response->getBodyAsString()); - } - - /** - * @depends testLock - */ - public function testLockRefresh() - { - $request = new HTTP\Request('LOCK', '/test.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $lockToken = $this->response->getHeader('Lock-Token'); - - $this->response = new HTTP\ResponseMock(); - $this->server->httpResponse = $this->response; - - $request = new HTTP\Request('LOCK', '/test.txt', ['If' => '('.$lockToken.')']); - $request->setBody(''); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - - $this->assertEquals(200, $this->response->status, 'We received an incorrect status code. Full response body: '.$this->response->getBody()); - } - - /** - * @depends testLock - */ - public function testLockRefreshBadToken() - { - $request = new HTTP\Request('LOCK', '/test.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $lockToken = $this->response->getHeader('Lock-Token'); - - $this->response = new HTTP\ResponseMock(); - $this->server->httpResponse = $this->response; - - $request = new HTTP\Request('LOCK', '/test.txt', ['If' => '('.$lockToken.'foobar) (<opaquelocktoken:anotherbadtoken>)']); - $request->setBody(''); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - - $this->assertEquals(423, $this->response->getStatus(), 'We received an incorrect status code. Full response body: '.$this->response->getBody()); - } - - /** - * @depends testLock - */ - public function testLockNoFile() - { - $request = new HTTP\Request('LOCK', '/notfound.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(201, $this->response->status); - } - - /** - * @depends testLock - */ - public function testUnlockNoToken() - { - $request = new HTTP\Request('UNLOCK', '/test.txt'); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ], - $this->response->getHeaders() - ); - - $this->assertEquals(400, $this->response->status); - } - - /** - * @depends testLock - */ - public function testUnlockBadToken() - { - $request = new HTTP\Request('UNLOCK', '/test.txt', ['Lock-Token' => '<opaquelocktoken:blablabla>']); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ], - $this->response->getHeaders() - ); - - $this->assertEquals(409, $this->response->status, 'Got an incorrect status code. Full response body: '.$this->response->getBodyAsString()); - } - - /** - * @depends testLock - */ - public function testLockPutNoToken() - { - $request = new HTTP\Request('LOCK', '/test.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(200, $this->response->status); - - $request = new HTTP\Request('PUT', '/test.txt'); - $request->setBody('newbody'); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(423, $this->response->status); - } - - /** - * @depends testLock - */ - public function testUnlock() - { - $request = new HTTP\Request('LOCK', '/test.txt'); - $this->server->httpRequest = $request; - - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->invokeMethod($request, $this->server->httpResponse); - $lockToken = $this->server->httpResponse->getHeader('Lock-Token'); - - $request = new HTTP\Request('UNLOCK', '/test.txt', ['Lock-Token' => $lockToken]); - $this->server->httpRequest = $request; - $this->server->httpResponse = new HTTP\ResponseMock(); - $this->server->invokeMethod($request, $this->server->httpResponse); - - $this->assertEquals(204, $this->server->httpResponse->status, 'Got an incorrect status code. Full response body: '.$this->response->getBodyAsString()); - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], - ], - $this->server->httpResponse->getHeaders() - ); - } - - /** - * @depends testLock - */ - public function testUnlockWindowsBug() - { - $request = new HTTP\Request('LOCK', '/test.txt'); - $this->server->httpRequest = $request; - - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->invokeMethod($request, $this->server->httpResponse); - $lockToken = $this->server->httpResponse->getHeader('Lock-Token'); - - // See Issue 123 - $lockToken = trim($lockToken, '<>'); - - $request = new HTTP\Request('UNLOCK', '/test.txt', ['Lock-Token' => $lockToken]); - $this->server->httpRequest = $request; - $this->server->httpResponse = new HTTP\ResponseMock(); - $this->server->invokeMethod($request, $this->server->httpResponse); - - $this->assertEquals(204, $this->server->httpResponse->status, 'Got an incorrect status code. Full response body: '.$this->response->getBodyAsString()); - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], - ], - $this->server->httpResponse->getHeaders() - ); - } - - /** - * @depends testLock - */ - public function testLockRetainOwner() - { - $request = new HTTP\Request('LOCK', '/test.txt'); - $this->server->httpRequest = $request; - - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner>Evert</D:owner> -</D:lockinfo>'); - - $this->server->invokeMethod($request, $this->server->httpResponse); - $lockToken = $this->server->httpResponse->getHeader('Lock-Token'); - - $locks = $this->locksPlugin->getLocks('test.txt'); - $this->assertEquals(1, count($locks)); - $this->assertEquals('Evert', $locks[0]->owner); - } - - /** - * @depends testLock - */ - public function testLockPutBadToken() - { - $request = new HTTP\Request('LOCK', '/test.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(200, $this->response->status); - - $request = new HTTP\Request('PUT', '/test.txt', [ - 'If' => '(<opaquelocktoken:token1>)', - ]); - $request->setBody('newbody'); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - // $this->assertEquals('412 Precondition failed',$this->response->status); - $this->assertEquals(423, $this->response->status); - } - - /** - * @depends testLock - */ - public function testLockDeleteParent() - { - $request = new HTTP\Request('LOCK', '/dir/child.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(200, $this->response->status); - - $request = new HTTP\Request('DELETE', '/dir'); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(423, $this->response->status); - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } - - /** - * @depends testLock - */ - public function testLockDeleteSucceed() - { - $request = new HTTP\Request('LOCK', '/dir/child.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(200, $this->response->status); - - $request = new HTTP\Request('DELETE', '/dir/child.txt', [ - 'If' => '('.$this->response->getHeader('Lock-Token').')', - ]); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(204, $this->response->status); - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } - - /** - * @depends testLock - */ - public function testLockCopyLockSource() - { - $request = new HTTP\Request('LOCK', '/dir/child.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(200, $this->response->status); - - $request = new HTTP\Request('COPY', '/dir/child.txt', [ - 'Destination' => '/dir/child2.txt', - ]); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(201, $this->response->status, 'Copy must succeed if only the source is locked, but not the destination'); - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } - - /** - * @depends testLock - */ - public function testLockCopyLockDestination() - { - $request = new HTTP\Request('LOCK', '/dir/child2.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(201, $this->response->status); - - $request = new HTTP\Request('COPY', '/dir/child.txt', [ - 'Destination' => '/dir/child2.txt', - ]); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(423, $this->response->status, 'Copy must succeed if only the source is locked, but not the destination'); - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } - - /** - * @depends testLock - */ - public function testLockMoveLockSourceLocked() - { - $request = new HTTP\Request('LOCK', '/dir/child.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(200, $this->response->status); - - $request = new HTTP\Request('MOVE', '/dir/child.txt', [ - 'Destination' => '/dir/child2.txt', - ]); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(423, $this->response->status, 'Copy must succeed if only the source is locked, but not the destination'); - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } - - /** - * @depends testLock - */ - public function testLockMoveLockSourceSucceed() - { - $request = new HTTP\Request('LOCK', '/dir/child.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(200, $this->response->status); - - $request = new HTTP\Request('MOVE', '/dir/child.txt', [ - 'Destination' => '/dir/child2.txt', - 'If' => '('.$this->response->getHeader('Lock-Token').')', - ]); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(201, $this->response->status, 'A valid lock-token was provided for the source, so this MOVE operation must succeed. Full response body: '.$this->response->getBodyAsString()); - } - - /** - * @depends testLock - */ - public function testLockMoveLockDestination() - { - $request = new HTTP\Request('LOCK', '/dir/child2.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(201, $this->response->status); - - $request = new HTTP\Request('MOVE', '/dir/child.txt', [ - 'Destination' => '/dir/child2.txt', - ]); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(423, $this->response->status, 'Copy must succeed if only the source is locked, but not the destination'); - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } - - /** - * @depends testLock - */ - public function testLockMoveLockParent() - { - $request = new HTTP\Request('LOCK', '/dir', [ - 'Depth' => 'infinite', - ]); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(200, $this->response->status); - - $request = new HTTP\Request('MOVE', '/dir/child.txt', [ - 'Destination' => '/dir/child2.txt', - 'If' => '</dir> ('.$this->response->getHeader('Lock-Token').')', - ]); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(201, $this->response->status, 'We locked the parent of both the source and destination, but the move didn\'t succeed.'); - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } - - /** - * @depends testLock - */ - public function testLockPutGoodToken() - { - $request = new HTTP\Request('LOCK', '/test.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(200, $this->response->status); - - $request = new HTTP\Request('PUT', '/test.txt', [ - 'If' => '('.$this->response->getHeader('Lock-Token').')', - ]); - $request->setBody('newbody'); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(204, $this->response->status); - } - - /** - * @depends testLock - */ - public function testLockPutUnrelatedToken() - { - $request = new HTTP\Request('LOCK', '/unrelated.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(201, $this->response->getStatus()); - - $request = new HTTP\Request( - 'PUT', - '/test.txt', - ['If' => '</unrelated.txt> ('.$this->response->getHeader('Lock-Token').')'] - ); - $request->setBody('newbody'); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - - $this->assertEquals(204, $this->response->status); - } - - public function testPutWithIncorrectETag() - { - $request = new HTTP\Request('PUT', '/test.txt', [ - 'If' => '(["etag1"])', - ]); - $request->setBody('newbody'); - $this->server->httpRequest = $request; - $this->server->exec(); - $this->assertEquals(412, $this->response->status); - } - - /** - * @depends testPutWithIncorrectETag - */ - public function testPutWithCorrectETag() - { - // We need an ETag-enabled file node. - $tree = new DAV\Tree(new DAV\FSExt\Directory(SABRE_TEMPDIR)); - $this->server->tree = $tree; - - $filename = SABRE_TEMPDIR.'/test.txt'; - $etag = sha1( - fileinode($filename). - filesize($filename). - filemtime($filename) - ); - - $request = new HTTP\Request('PUT', '/test.txt', [ - 'If' => '(["'.$etag.'"])', - ]); - $request->setBody('newbody'); - - $this->server->httpRequest = $request; - $this->server->exec(); - $this->assertEquals(204, $this->response->status, 'Incorrect status received. Full response body:'.$this->response->getBodyAsString()); - } - - public function testDeleteWithETagOnCollection() - { - $request = new HTTP\Request('DELETE', '/dir', [ - 'If' => '(["etag1"])', - ]); - - $this->server->httpRequest = $request; - $this->server->exec(); - $this->assertEquals(412, $this->response->status); - } - - public function testGetTimeoutHeader() - { - $request = new HTTP\Request('LOCK', '/foo/bar', [ - 'Timeout' => 'second-100', - ]); - - $this->server->httpRequest = $request; - $this->assertEquals(100, $this->locksPlugin->getTimeoutHeader()); - } - - public function testGetTimeoutHeaderTwoItems() - { - $request = new HTTP\Request('LOCK', '/foo/bar', [ - 'Timeout' => 'second-5, infinite', - ]); - $this->server->httpRequest = $request; - $this->assertEquals(5, $this->locksPlugin->getTimeoutHeader()); - } - - public function testGetTimeoutHeaderInfinite() - { - $request = new HTTP\Request('LOCK', '/foo/bar', [ - 'Timeout' => 'infinite, second-5', - ]); - $this->server->httpRequest = $request; - $this->assertEquals(LockInfo::TIMEOUT_INFINITE, $this->locksPlugin->getTimeoutHeader()); - } - - public function testGetTimeoutHeaderInvalid() - { - $this->expectException('Sabre\DAV\Exception\BadRequest'); - $request = new HTTP\Request('GET', '/', ['Timeout' => 'yourmom']); - - $this->server->httpRequest = $request; - $this->locksPlugin->getTimeoutHeader(); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php b/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php deleted file mode 100644 index 041274706..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php +++ /dev/null @@ -1,157 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Mock; - -use Sabre\DAV; - -/** - * Mock Collection. - * - * This collection quickly allows you to create trees of nodes. - * Children are specified as an array. - * - * Every key a filename, every array value is either: - * * an array, for a sub-collection - * * a string, for a file - * * An instance of \Sabre\DAV\INode. - * - * @copyright Copyright (C) fruux GmbH (https://fruux.com/) - * @author Evert Pot (http://evertpot.com/) - * @license http://sabre.io/license/ Modified BSD License - */ -class Collection extends DAV\Collection -{ - protected $name; - protected $children; - protected $parent; - - /** - * Creates the object. - * - * @param string $name - * @param Collection $parent - */ - public function __construct($name, array $children = [], Collection $parent = null) - { - $this->name = $name; - foreach ($children as $key => $value) { - if (is_string($value)) { - $this->children[] = new File($key, $value, $this); - } elseif (is_array($value)) { - $this->children[] = new self($key, $value, $this); - } elseif ($value instanceof \Sabre\DAV\INode) { - $this->children[] = $value; - } else { - throw new \InvalidArgumentException('Unknown value passed in $children'); - } - } - $this->parent = $parent; - } - - /** - * Returns the name of the node. - * - * This is used to generate the url. - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Creates a new file in the directory. - * - * Data will either be supplied as a stream resource, or in certain cases - * as a string. Keep in mind that you may have to support either. - * - * After successful creation of the file, you may choose to return the ETag - * of the new file here. - * - * The returned ETag must be surrounded by double-quotes (The quotes should - * be part of the actual string). - * - * If you cannot accurately determine the ETag, you should not return it. - * If you don't store the file exactly as-is (you're transforming it - * somehow) you should also not return an ETag. - * - * This means that if a subsequent GET to this new file does not exactly - * return the same contents of what was submitted here, you are strongly - * recommended to omit the ETag. - * - * @param string $name Name of the file - * @param resource|string $data Initial payload - * - * @return string|null - */ - public function createFile($name, $data = null) - { - if (null === $data) { - $data = ''; - } - if (is_resource($data)) { - $data = stream_get_contents($data); - } - $this->children[] = new File($name, $data, $this); - - return '"'.md5($data).'"'; - } - - /** - * Creates a new subdirectory. - * - * @param string $name - */ - public function createDirectory($name) - { - $this->children[] = new self($name); - } - - /** - * Returns an array with all the child nodes. - * - * @return \Sabre\DAV\INode[] - */ - public function getChildren() - { - return $this->children; - } - - /** - * Adds an already existing node to this collection. - */ - public function addNode(\Sabre\DAV\INode $node) - { - $this->children[] = $node; - } - - /** - * Removes a childnode from this node. - * - * @param string $name - */ - public function deleteChild($name) - { - foreach ($this->children as $key => $value) { - if ($value->getName() == $name) { - unset($this->children[$key]); - - return; - } - } - } - - /** - * Deletes this collection and all its children,. - */ - public function delete() - { - foreach ($this->getChildren() as $child) { - $this->deleteChild($child->getName()); - } - $this->parent->deleteChild($this->getName()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php b/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php deleted file mode 100644 index d48ddaa92..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php +++ /dev/null @@ -1,151 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Mock; - -use Sabre\DAV; - -/** - * Mock File. - * - * See the Collection in this directory for more details. - * - * @copyright Copyright (C) fruux GmbH (https://fruux.com/) - * @author Evert Pot (http://evertpot.com/) - * @license http://sabre.io/license/ Modified BSD License - */ -class File extends DAV\File -{ - protected $name; - protected $contents; - protected $parent; - protected $lastModified; - - /** - * Creates the object. - * - * @param string $name - * @param resource $contents - * @param Collection $parent - * @param int $lastModified - */ - public function __construct($name, $contents, Collection $parent = null, $lastModified = -1) - { - $this->name = $name; - $this->put($contents); - $this->parent = $parent; - - if (-1 === $lastModified) { - $lastModified = time(); - } - - $this->lastModified = $lastModified; - } - - /** - * Returns the name of the node. - * - * This is used to generate the url. - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Changes the name of the node. - * - * @param string $name - */ - public function setName($name) - { - $this->name = $name; - } - - /** - * Updates the data. - * - * The data argument is a readable stream resource. - * - * After a successful put operation, you may choose to return an ETag. The - * etag must always be surrounded by double-quotes. These quotes must - * appear in the actual string you're returning. - * - * Clients may use the ETag from a PUT request to later on make sure that - * when they update the file, the contents haven't changed in the mean - * time. - * - * If you don't plan to store the file byte-by-byte, and you return a - * different object on a subsequent GET you are strongly recommended to not - * return an ETag, and just return null. - * - * @param resource $data - * - * @return string|null - */ - public function put($data) - { - if (is_resource($data)) { - $data = stream_get_contents($data); - } - $this->contents = $data; - - return '"'.md5($data).'"'; - } - - /** - * Returns the data. - * - * This method may either return a string or a readable stream resource - * - * @return mixed - */ - public function get() - { - return $this->contents; - } - - /** - * Returns the ETag for a file. - * - * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. - * - * Return null if the ETag can not effectively be determined - */ - public function getETag() - { - return '"'.md5($this->contents).'"'; - } - - /** - * Returns the size of the node, in bytes. - * - * @return int - */ - public function getSize() - { - return strlen($this->contents); - } - - /** - * Delete the node. - */ - public function delete() - { - $this->parent->deleteChild($this->name); - } - - /** - * Returns the last modification time as a unix timestamp. - * If the information is not available, return null. - * - * @return int - */ - public function getLastModified() - { - return $this->lastModified; - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php deleted file mode 100644 index 54f7e4cb4..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\Mount; - -use Sabre\DAV; -use Sabre\HTTP; - -class PluginTest extends DAV\AbstractServer -{ - public function setup(): void - { - parent::setUp(); - $this->server->addPlugin(new Plugin()); - } - - public function testPassThrough() - { - $serverVars = [ - 'REQUEST_URI' => '/', - 'REQUEST_METHOD' => 'GET', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals(501, $this->response->status, 'We expected GET to not be implemented for Directories. Response body: '.$this->response->getBodyAsString()); - } - - public function testMountResponse() - { - $serverVars = [ - 'REQUEST_URI' => '/?mount', - 'REQUEST_METHOD' => 'GET', - 'QUERY_STRING' => 'mount', - 'HTTP_HOST' => 'example.org', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals(200, $this->response->status); - - $xml = simplexml_load_string($this->response->getBodyAsString()); - $this->assertInstanceOf('SimpleXMLElement', $xml, 'Response was not a valid xml document. The list of errors:'.print_r(libxml_get_errors(), true).'. xml body: '.$this->response->getBodyAsString().'. What type we got: '.gettype($xml).' class, if object: '.get_class($xml)); - - $xml->registerXPathNamespace('dm', 'http://purl.org/NET/webdav/mount'); - $url = $xml->xpath('//dm:url'); - $this->assertEquals('http://example.org/', (string) $url[0]); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php deleted file mode 100644 index 7066c49fc..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -class ObjectTreeTest extends \PHPUnit\Framework\TestCase -{ - protected $tree; - - public function setup(): void - { - \Sabre\TestUtil::clearTempDir(); - mkdir(SABRE_TEMPDIR.'/root'); - mkdir(SABRE_TEMPDIR.'/root/subdir'); - file_put_contents(SABRE_TEMPDIR.'/root/file.txt', 'contents'); - file_put_contents(SABRE_TEMPDIR.'/root/subdir/subfile.txt', 'subcontents'); - $rootNode = new FSExt\Directory(SABRE_TEMPDIR.'/root'); - $this->tree = new Tree($rootNode); - } - - public function teardown(): void - { - \Sabre\TestUtil::clearTempDir(); - } - - public function testGetRootNode() - { - $root = $this->tree->getNodeForPath(''); - $this->assertInstanceOf('Sabre\\DAV\\FSExt\\Directory', $root); - } - - public function testGetSubDir() - { - $root = $this->tree->getNodeForPath('subdir'); - $this->assertInstanceOf('Sabre\\DAV\\FSExt\\Directory', $root); - } - - public function testCopyFile() - { - $this->tree->copy('file.txt', 'file2.txt'); - $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/file2.txt')); - $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR.'/root/file2.txt')); - } - - /** - * @depends testCopyFile - */ - public function testCopyDirectory() - { - $this->tree->copy('subdir', 'subdir2'); - $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2')); - $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); - $this->assertEquals('subcontents', file_get_contents(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); - } - - /** - * @depends testCopyFile - */ - public function testMoveFile() - { - $this->tree->move('file.txt', 'file2.txt'); - $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/file2.txt')); - $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/file.txt')); - $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR.'/root/file2.txt')); - } - - /** - * @depends testMoveFile - */ - public function testMoveFileNewParent() - { - $this->tree->move('file.txt', 'subdir/file2.txt'); - $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir/file2.txt')); - $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/file.txt')); - $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR.'/root/subdir/file2.txt')); - } - - /** - * @depends testCopyDirectory - */ - public function testMoveDirectory() - { - $this->tree->move('subdir', 'subdir2'); - $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2')); - $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); - $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/subdir')); - $this->assertEquals('subcontents', file_get_contents(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php deleted file mode 100644 index 72fdb5ec8..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\PartialUpdate; - -use Sabre\DAV; - -class FileMock implements IPatchSupport -{ - protected $data = ''; - - public function put($str) - { - if (is_resource($str)) { - $str = stream_get_contents($str); - } - $this->data = $str; - } - - /** - * Updates the file based on a range specification. - * - * The first argument is the data, which is either a readable stream - * resource or a string. - * - * The second argument is the type of update we're doing. - * This is either: - * * 1. append - * * 2. update based on a start byte - * * 3. update based on an end byte - *; - * The third argument is the start or end byte. - * - * After a successful put operation, you may choose to return an ETag. The - * etag must always be surrounded by double-quotes. These quotes must - * appear in the actual string you're returning. - * - * Clients may use the ETag from a PUT request to later on make sure that - * when they update the file, the contents haven't changed in the mean - * time. - * - * @param resource|string $data - * @param int $rangeType - * @param int $offset - * - * @return string|null - */ - public function patch($data, $rangeType, $offset = null) - { - if (is_resource($data)) { - $data = stream_get_contents($data); - } - - switch ($rangeType) { - case 1: - $this->data .= $data; - break; - case 3: - // Turn the offset into an offset-offset. - $offset = strlen($this->data) - $offset; - // no break is intentional - case 2: - $this->data = - substr($this->data, 0, $offset). - $data. - substr($this->data, $offset + strlen($data)); - break; - } - } - - public function get() - { - return $this->data; - } - - public function getContentType() - { - return 'text/plain'; - } - - public function getSize() - { - return strlen($this->data); - } - - public function getETag() - { - return '"'.$this->data.'"'; - } - - public function delete() - { - throw new DAV\Exception\MethodNotAllowed(); - } - - public function setName($name) - { - throw new DAV\Exception\MethodNotAllowed(); - } - - public function getName() - { - return 'partial'; - } - - public function getLastModified() - { - return null; - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php deleted file mode 100644 index 4d99aee7d..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php +++ /dev/null @@ -1,122 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\PartialUpdate; - -use Sabre\HTTP; - -class PluginTest extends \Sabre\DAVServerTest -{ - protected $node; - protected $plugin; - - public function setup(): void - { - $this->node = new FileMock(); - $this->tree[] = $this->node; - - parent::setUp(); - - $this->plugin = new Plugin(); - $this->server->addPlugin($this->plugin); - } - - public function testInit() - { - $this->assertEquals('partialupdate', $this->plugin->getPluginName()); - $this->assertEquals(['sabredav-partialupdate'], $this->plugin->getFeatures()); - $this->assertEquals([ - 'PATCH', - ], $this->plugin->getHTTPMethods('partial')); - $this->assertEquals([ - ], $this->plugin->getHTTPMethods('')); - } - - public function testPatchNoRange() - { - $this->node->put('aaaaaaaa'); - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PATCH', - 'REQUEST_URI' => '/partial', - ]); - $response = $this->request($request); - - $this->assertEquals(400, $response->status, 'Full response body:'.$response->getBodyAsString()); - } - - public function testPatchNotSupported() - { - $this->node->put('aaaaaaaa'); - $request = new HTTP\Request('PATCH', '/', ['X-Update-Range' => '3-4']); - $request->setBody( - 'bbb' - ); - $response = $this->request($request); - - $this->assertEquals(405, $response->status, 'Full response body:'.$response->getBodyAsString()); - } - - public function testPatchNoContentType() - { - $this->node->put('aaaaaaaa'); - $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-4']); - $request->setBody( - 'bbb' - ); - $response = $this->request($request); - - $this->assertEquals(415, $response->status, 'Full response body:'.$response->getBodyAsString()); - } - - public function testPatchBadRange() - { - $this->node->put('aaaaaaaa'); - $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-4', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => '3']); - $request->setBody( - 'bbb' - ); - $response = $this->request($request); - - $this->assertEquals(416, $response->status, 'Full response body:'.$response->getBodyAsString()); - } - - public function testPatchNoLength() - { - $this->node->put('aaaaaaaa'); - $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-5', 'Content-Type' => 'application/x-sabredav-partialupdate']); - $request->setBody( - 'bbb' - ); - $response = $this->request($request); - - $this->assertEquals(411, $response->status, 'Full response body:'.$response->getBodyAsString()); - } - - public function testPatchSuccess() - { - $this->node->put('aaaaaaaa'); - $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-5', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => 3]); - $request->setBody( - 'bbb' - ); - $response = $this->request($request); - - $this->assertEquals(204, $response->status, 'Full response body:'.$response->getBodyAsString()); - $this->assertEquals('aaabbbaa', $this->node->get()); - } - - public function testPatchNoEndRange() - { - $this->node->put('aaaaa'); - $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => '3']); - $request->setBody( - 'bbb' - ); - - $response = $this->request($request); - - $this->assertEquals(204, $response->getStatus(), 'Full response body:'.$response->getBodyAsString()); - $this->assertEquals('aaabbb', $this->node->get()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php deleted file mode 100644 index a727a13e2..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV\PartialUpdate; - -use Sabre\DAV\FSExt\File; -use Sabre\DAV\Server; -use Sabre\HTTP; - -/** - * This test is an end-to-end sabredav test that goes through all - * the cases in the specification. - * - * See: http://sabre.io/dav/http-patch/ - */ -class SpecificationTest extends \PHPUnit\Framework\TestCase -{ - protected $server; - - public function setup(): void - { - $tree = [ - new File(SABRE_TEMPDIR.'/foobar.txt'), - ]; - $server = new Server($tree); - $server->debugExceptions = true; - $server->addPlugin(new Plugin()); - - $tree[0]->put('1234567890'); - - $this->server = $server; - } - - public function teardown(): void - { - \Sabre\TestUtil::clearTempDir(); - } - - /** - * @param string $headerValue - * @param string $httpStatus - * @param string $endResult - * @param int $contentLength - * - * @dataProvider data - */ - public function testUpdateRange($headerValue, $httpStatus, $endResult, $contentLength = 4) - { - $headers = [ - 'Content-Type' => 'application/x-sabredav-partialupdate', - 'X-Update-Range' => $headerValue, - ]; - - if ($contentLength) { - $headers['Content-Length'] = (string) $contentLength; - } - - $request = new HTTP\Request('PATCH', '/foobar.txt', $headers, '----'); - - $request->setBody('----'); - $this->server->httpRequest = $request; - $this->server->httpResponse = new HTTP\ResponseMock(); - $this->server->sapi = new HTTP\SapiMock(); - $this->server->exec(); - - $this->assertEquals($httpStatus, $this->server->httpResponse->status, 'Incorrect http status received: '.$this->server->httpResponse->body); - if (!is_null($endResult)) { - $this->assertEquals($endResult, file_get_contents(SABRE_TEMPDIR.'/foobar.txt')); - } - } - - public function data() - { - return [ - // Problems - ['foo', 400, null], - ['bytes=0-3', 411, null, 0], - ['bytes=4-1', 416, null], - - ['bytes=0-3', 204, '----567890'], - ['bytes=1-4', 204, '1----67890'], - ['bytes=0-', 204, '----567890'], - ['bytes=-4', 204, '123456----'], - ['bytes=-2', 204, '12345678----'], - ['bytes=2-', 204, '12----7890'], - ['append', 204, '1234567890----'], - ]; - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php deleted file mode 100644 index b1f6754ea..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php +++ /dev/null @@ -1,114 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -use Sabre\HTTP; - -class ServerEventsTest extends AbstractServer -{ - private $tempPath; - - private $exception; - - public function testAfterBind() - { - $this->server->on('afterBind', [$this, 'afterBindHandler']); - $newPath = 'afterBind'; - - $this->tempPath = ''; - $this->server->createFile($newPath, 'body'); - $this->assertEquals($newPath, $this->tempPath); - } - - public function afterBindHandler($path) - { - $this->tempPath = $path; - } - - public function testAfterResponse() - { - $mock = $this->getMockBuilder('stdClass') - ->setMethods(['afterResponseCallback']) - ->getMock(); - $mock->expects($this->once())->method('afterResponseCallback'); - - $this->server->on('afterResponse', [$mock, 'afterResponseCallback']); - - $this->server->httpRequest = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/test.txt', - ]); - - $this->server->exec(); - } - - public function testBeforeBindCancel() - { - $this->server->on('beforeBind', [$this, 'beforeBindCancelHandler']); - $this->assertFalse($this->server->createFile('bla', 'body')); - - // Also testing put() - $req = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/barbar', - ]); - - $this->server->httpRequest = $req; - $this->server->exec(); - - $this->assertEquals(500, $this->server->httpResponse->getStatus()); - } - - public function beforeBindCancelHandler($path) - { - return false; - } - - public function testException() - { - $this->server->on('exception', [$this, 'exceptionHandler']); - - $req = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/not/exisitng', - ]); - $this->server->httpRequest = $req; - $this->server->exec(); - - $this->assertInstanceOf('Sabre\\DAV\\Exception\\NotFound', $this->exception); - } - - public function exceptionHandler(Exception $exception) - { - $this->exception = $exception; - } - - public function testMethod() - { - $k = 1; - $this->server->on('method:*', function ($request, $response) use (&$k) { - ++$k; - - return false; - }); - $this->server->on('method:*', function ($request, $response) use (&$k) { - $k += 2; - - return false; - }); - - try { - $this->server->invokeMethod( - new HTTP\Request('BLABLA', '/'), - new HTTP\Response(), - false - ); - } catch (Exception $e) { - } - - // Fun fact, PHP 7.1 changes the order when sorting-by-callback. - $this->assertTrue($k >= 2 && $k <= 3); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php deleted file mode 100644 index 02c6a4633..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php +++ /dev/null @@ -1,354 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -use Sabre\HTTP; - -class ServerMKCOLTest extends AbstractServer -{ - public function testMkcol() - { - $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody(''); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - ], $this->response->getHeaders()); - - $this->assertEquals(201, $this->response->status); - $this->assertEquals('', $this->response->getBodyAsString()); - $this->assertTrue(is_dir($this->tempDir.'/testcol')); - } - - /** - * @depends testMkcol - */ - public function testMKCOLUnknownBody() - { - $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody('Hello'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ], $this->response->getHeaders()); - - $this->assertEquals(415, $this->response->status); - } - - /** - * @depends testMkcol - */ - public function testMKCOLBrokenXML() - { - $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', - 'HTTP_CONTENT_TYPE' => 'application/xml', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody('Hello'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ], $this->response->getHeaders()); - - $this->assertEquals(400, $this->response->getStatus(), $this->response->getBodyAsString()); - } - - /** - * @depends testMkcol - */ - public function testMKCOLUnknownXML() - { - $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', - 'HTTP_CONTENT_TYPE' => 'application/xml', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody('<?xml version="1.0"?><html></html>'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ], $this->response->getHeaders()); - - $this->assertEquals(400, $this->response->getStatus()); - } - - /** - * @depends testMkcol - */ - public function testMKCOLNoResourceType() - { - $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', - 'HTTP_CONTENT_TYPE' => 'application/xml', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody('<?xml version="1.0"?> -<mkcol xmlns="DAV:"> - <set> - <prop> - <displayname>Evert</displayname> - </prop> - </set> -</mkcol>'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ], $this->response->getHeaders()); - - $this->assertEquals(400, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->getBodyAsString()); - } - - /** - * @depends testMkcol - */ - public function testMKCOLIncorrectResourceType() - { - $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', - 'HTTP_CONTENT_TYPE' => 'application/xml', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody('<?xml version="1.0"?> -<mkcol xmlns="DAV:"> - <set> - <prop> - <resourcetype><collection /><blabla /></resourcetype> - </prop> - </set> -</mkcol>'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ], $this->response->getHeaders()); - - $this->assertEquals(403, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->getBodyAsString()); - } - - /** - * @depends testMKCOLIncorrectResourceType - */ - public function testMKCOLSuccess() - { - $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', - 'HTTP_CONTENT_TYPE' => 'application/xml', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody('<?xml version="1.0"?> -<mkcol xmlns="DAV:"> - <set> - <prop> - <resourcetype><collection /></resourcetype> - </prop> - </set> -</mkcol>'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - ], $this->response->getHeaders()); - - $this->assertEquals(201, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->getBodyAsString()); - } - - /** - * @depends testMKCOLIncorrectResourceType - */ - public function testMKCOLWhiteSpaceResourceType() - { - $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', - 'HTTP_CONTENT_TYPE' => 'application/xml', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody('<?xml version="1.0"?> -<mkcol xmlns="DAV:"> - <set> - <prop> - <resourcetype> - <collection /> - </resourcetype> - </prop> - </set> -</mkcol>'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - ], $this->response->getHeaders()); - - $this->assertEquals(201, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->getBodyAsString()); - } - - /** - * @depends testMKCOLIncorrectResourceType - */ - public function testMKCOLNoParent() - { - $serverVars = [ - 'REQUEST_URI' => '/testnoparent/409me', - 'REQUEST_METHOD' => 'MKCOL', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody(''); - - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ], $this->response->getHeaders()); - - $this->assertEquals(409, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->getBodyAsString()); - } - - /** - * @depends testMKCOLIncorrectResourceType - */ - public function testMKCOLParentIsNoCollection() - { - $serverVars = [ - 'REQUEST_URI' => '/test.txt/409me', - 'REQUEST_METHOD' => 'MKCOL', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody(''); - - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ], $this->response->getHeaders()); - - $this->assertEquals(409, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->getBodyAsString()); - } - - /** - * @depends testMKCOLIncorrectResourceType - */ - public function testMKCOLAlreadyExists() - { - $serverVars = [ - 'REQUEST_URI' => '/test.txt', - 'REQUEST_METHOD' => 'MKCOL', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody(''); - - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'], - ], $this->response->getHeaders()); - - $this->assertEquals(405, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->getBodyAsString()); - } - - /** - * @depends testMKCOLSuccess - * @depends testMKCOLAlreadyExists - */ - public function testMKCOLAndProps() - { - $request = new HTTP\Request( - 'MKCOL', - '/testcol', - ['Content-Type' => 'application/xml'] - ); - $request->setBody('<?xml version="1.0"?> -<mkcol xmlns="DAV:"> - <set> - <prop> - <resourcetype><collection /></resourcetype> - <displayname>my new collection</displayname> - </prop> - </set> -</mkcol>'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $bodyAsString = $this->response->getBodyAsString(); - $this->assertEquals(207, $this->response->status, 'Wrong statuscode received. Full response body: '.$bodyAsString); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ], $this->response->getHeaders()); - - $expected = <<<XML -<?xml version="1.0"?> -<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"> - <d:response> - <d:href>/testcol</d:href> - <d:propstat> - <d:prop> - <d:displayname /> - </d:prop> - <d:status>HTTP/1.1 403 Forbidden</d:status> - </d:propstat> - </d:response> -</d:multistatus> -XML; - - $this->assertXmlStringEqualsXmlString( - $expected, - $bodyAsString - ); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php deleted file mode 100644 index 47e1e6b4c..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -use Sabre\HTTP; - -class ServerPluginTest extends AbstractServer -{ - /** - * @var Sabre\DAV\TestPlugin - */ - protected $testPlugin; - - public function setup(): void - { - parent::setUp(); - - $testPlugin = new TestPlugin(); - $this->server->addPlugin($testPlugin); - $this->testPlugin = $testPlugin; - } - - public function testBaseClass() - { - $p = new ServerPluginMock(); - $this->assertEquals([], $p->getFeatures()); - $this->assertEquals([], $p->getHTTPMethods('')); - $this->assertEquals( - [ - 'name' => 'Sabre\DAV\ServerPluginMock', - 'description' => null, - 'link' => null, - ], $p->getPluginInfo() - ); - } - - public function testOptions() - { - $serverVars = [ - 'REQUEST_URI' => '/', - 'REQUEST_METHOD' => 'OPTIONS', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'DAV' => ['1, 3, extended-mkcol, drinking'], - 'MS-Author-Via' => ['DAV'], - 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, BEER, WINE'], - 'Accept-Ranges' => ['bytes'], - 'Content-Length' => ['0'], - 'X-Sabre-Version' => [Version::VERSION], - ], $this->response->getHeaders()); - - $this->assertEquals(200, $this->response->status); - $this->assertEquals('', $this->response->getBodyAsString()); - $this->assertEquals('OPTIONS', $this->testPlugin->beforeMethod); - } - - public function testGetPlugin() - { - $this->assertEquals($this->testPlugin, $this->server->getPlugin(get_class($this->testPlugin))); - } - - public function testUnknownPlugin() - { - $this->assertNull($this->server->getPlugin('SomeRandomClassName')); - } - - public function testGetSupportedReportSet() - { - $this->assertEquals([], $this->testPlugin->getSupportedReportSet('/')); - } - - public function testGetPlugins() - { - $this->assertEquals( - [ - get_class($this->testPlugin) => $this->testPlugin, - 'core' => $this->server->getPlugin('core'), - ], - $this->server->getPlugins() - ); - } -} - -class ServerPluginMock extends ServerPlugin -{ - public function initialize(Server $s) - { - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerPropsTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerPropsTest.php deleted file mode 100644 index cd1ccfa53..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerPropsTest.php +++ /dev/null @@ -1,194 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -use Sabre\HTTP; - -class ServerPropsTest extends AbstractServer -{ - protected function getRootNode() - { - return new FSExt\Directory(SABRE_TEMPDIR); - } - - public function setup(): void - { - if (file_exists(SABRE_TEMPDIR.'../.sabredav')) { - unlink(SABRE_TEMPDIR.'../.sabredav'); - } - parent::setUp(); - file_put_contents(SABRE_TEMPDIR.'/test2.txt', 'Test contents2'); - mkdir(SABRE_TEMPDIR.'/col'); - file_put_contents(SABRE_TEMPDIR.'col/test.txt', 'Test contents'); - $this->server->addPlugin(new Locks\Plugin(new Locks\Backend\File(SABRE_TEMPDIR.'/.locksdb'))); - } - - public function teardown(): void - { - parent::tearDown(); - if (file_exists(SABRE_TEMPDIR.'../.locksdb')) { - unlink(SABRE_TEMPDIR.'../.locksdb'); - } - } - - private function sendRequest($body, $path = '/', $headers = ['Depth' => '0']) - { - $request = new HTTP\Request('PROPFIND', $path, $headers, $body); - - $this->server->httpRequest = $request; - $this->server->exec(); - } - - public function testPropFindEmptyBody() - { - $this->sendRequest(''); - $this->assertEquals(207, $this->response->status); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'DAV' => ['1, 3, extended-mkcol, 2'], - 'Vary' => ['Brief,Prefer'], - ], - $this->response->getHeaders() - ); - - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->getBodyAsString()); - $xml = simplexml_load_string($body); - $xml->registerXPathNamespace('d', 'urn:DAV'); - - list($data) = $xml->xpath('/d:multistatus/d:response/d:href'); - $this->assertEquals('/', (string) $data, 'href element should have been /'); - - $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype'); - $this->assertEquals(1, count($data)); - } - - public function testPropFindEmptyBodyFile() - { - $this->sendRequest('', '/test2.txt', []); - $this->assertEquals(207, $this->response->status); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'DAV' => ['1, 3, extended-mkcol, 2'], - 'Vary' => ['Brief,Prefer'], - ], - $this->response->getHeaders() - ); - - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->getBodyAsString()); - $xml = simplexml_load_string($body); - $xml->registerXPathNamespace('d', 'urn:DAV'); - - list($data) = $xml->xpath('/d:multistatus/d:response/d:href'); - $this->assertEquals('/test2.txt', (string) $data, 'href element should have been /test2.txt'); - - $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength'); - $this->assertEquals(1, count($data)); - } - - public function testSupportedLocks() - { - $xml = '<?xml version="1.0"?> -<d:propfind xmlns:d="DAV:"> - <d:prop> - <d:supportedlock /> - </d:prop> -</d:propfind>'; - - $this->sendRequest($xml); - - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->getBodyAsString()); - $xml = simplexml_load_string($body); - $xml->registerXPathNamespace('d', 'urn:DAV'); - - $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry'); - $this->assertEquals(2, count($data), 'We expected two \'d:lockentry\' tags'); - - $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope'); - $this->assertEquals(2, count($data), 'We expected two \'d:lockscope\' tags'); - - $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:locktype'); - $this->assertEquals(2, count($data), 'We expected two \'d:locktype\' tags'); - - $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope/d:shared'); - $this->assertEquals(1, count($data), 'We expected a \'d:shared\' tag'); - - $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope/d:exclusive'); - $this->assertEquals(1, count($data), 'We expected a \'d:exclusive\' tag'); - - $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:locktype/d:write'); - $this->assertEquals(2, count($data), 'We expected two \'d:write\' tags'); - } - - public function testLockDiscovery() - { - $xml = '<?xml version="1.0"?> -<d:propfind xmlns:d="DAV:"> - <d:prop> - <d:lockdiscovery /> - </d:prop> -</d:propfind>'; - - $this->sendRequest($xml); - - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->getBodyAsString()); - $xml = simplexml_load_string($body); - $xml->registerXPathNamespace('d', 'urn:DAV'); - - $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:lockdiscovery'); - $this->assertEquals(1, count($data), 'We expected a \'d:lockdiscovery\' tag'); - } - - public function testUnknownProperty() - { - $xml = '<?xml version="1.0"?> -<d:propfind xmlns:d="DAV:"> - <d:prop> - <d:macaroni /> - </d:prop> -</d:propfind>'; - - $this->sendRequest($xml); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->getBodyAsString()); - $xml = simplexml_load_string($body); - $xml->registerXPathNamespace('d', 'urn:DAV'); - $pathTests = [ - '/d:multistatus', - '/d:multistatus/d:response', - '/d:multistatus/d:response/d:propstat', - '/d:multistatus/d:response/d:propstat/d:status', - '/d:multistatus/d:response/d:propstat/d:prop', - '/d:multistatus/d:response/d:propstat/d:prop/d:macaroni', - ]; - foreach ($pathTests as $test) { - $this->assertTrue(true == count($xml->xpath($test)), 'We expected the '.$test.' element to appear in the response, we got: '.$body); - } - - $val = $xml->xpath('/d:multistatus/d:response/d:propstat/d:status'); - $this->assertEquals(1, count($val), $body); - $this->assertEquals('HTTP/1.1 404 Not Found', (string) $val[0]); - } - - public function testParsePropPatchRequest() - { - $body = '<?xml version="1.0"?> -<d:propertyupdate xmlns:d="DAV:" xmlns:s="http://sabredav.org/NS/test"> - <d:set><d:prop><s:someprop>somevalue</s:someprop></d:prop></d:set> - <d:remove><d:prop><s:someprop2 /></d:prop></d:remove> - <d:set><d:prop><s:someprop3>removeme</s:someprop3></d:prop></d:set> - <d:remove><d:prop><s:someprop3 /></d:prop></d:remove> -</d:propertyupdate>'; - - $result = $this->server->xml->parse($body); - $this->assertEquals([ - '{http://sabredav.org/NS/test}someprop' => 'somevalue', - '{http://sabredav.org/NS/test}someprop2' => null, - '{http://sabredav.org/NS/test}someprop3' => null, - ], $result->properties); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php deleted file mode 100644 index 6d5be4608..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php +++ /dev/null @@ -1,252 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -use DateTime; -use Sabre\HTTP; - -/** - * This file tests HTTP requests that use the Range: header. - * - * @copyright Copyright (C) fruux GmbH. (https://fruux.com/) - * @author Evert Pot (http://evertpot.com/) - * @license http://sabre.io/license/ Modified BSD License - */ -class ServerRangeTest extends \Sabre\DAVServerTest -{ - protected $setupFiles = true; - - /** - * We need this string a lot. - */ - protected $lastModified; - - public function setup(): void - { - parent::setUp(); - $this->server->createFile('files/test.txt', 'Test contents'); - - $this->lastModified = HTTP\toDate( - new DateTime('@'.$this->server->tree->getNodeForPath('files/test.txt')->getLastModified()) - ); - - $stream = popen('echo "Test contents"', 'r'); - $streamingFile = new Mock\StreamingFile( - 'no-seeking.txt', - $stream - ); - $streamingFile->setSize(12); - $this->server->tree->getNodeForPath('files')->addNode($streamingFile); - } - - public function testRange() - { - $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=2-5']); - $response = $this->request($request); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [4], - 'Content-Range' => ['bytes 2-5/13'], - 'ETag' => ['"'.md5('Test contents').'"'], - 'Last-Modified' => [$this->lastModified], - ], - $response->getHeaders() - ); - $this->assertEquals(206, $response->getStatus()); - $this->assertEquals('st c', $response->getBodyAsString()); - } - - /** - * @depends testRange - */ - public function testStartRange() - { - $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=2-']); - $response = $this->request($request); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [11], - 'Content-Range' => ['bytes 2-12/13'], - 'ETag' => ['"'.md5('Test contents').'"'], - 'Last-Modified' => [$this->lastModified], - ], - $response->getHeaders() - ); - - $this->assertEquals(206, $response->getStatus()); - $this->assertEquals('st contents', $response->getBodyAsString()); - } - - /** - * @depends testRange - */ - public function testEndRange() - { - $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=-8']); - $response = $this->request($request); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [8], - 'Content-Range' => ['bytes 5-12/13'], - 'ETag' => ['"'.md5('Test contents').'"'], - 'Last-Modified' => [$this->lastModified], - ], - $response->getHeaders() - ); - - $this->assertEquals(206, $response->getStatus()); - $this->assertEquals('contents', $response->getBodyAsString()); - } - - /** - * @depends testRange - */ - public function testTooHighRange() - { - $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=100-200']); - $response = $this->request($request); - - $this->assertEquals(416, $response->getStatus()); - } - - /** - * @depends testRange - */ - public function testCrazyRange() - { - $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=8-4']); - $response = $this->request($request); - - $this->assertEquals(416, $response->getStatus()); - } - - public function testNonSeekableStream() - { - $request = new HTTP\Request('GET', '/files/no-seeking.txt', ['Range' => 'bytes=2-5']); - $response = $this->request($request); - - $this->assertEquals(206, $response->getStatus()); - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [4], - 'Content-Range' => ['bytes 2-5/12'], - // 'ETag' => ['"' . md5('Test contents') . '"'], - 'Last-Modified' => [$this->lastModified], - ], - $response->getHeaders() - ); - - $this->assertEquals('st c', $response->getBodyAsString()); - } - - /** - * @depends testRange - */ - public function testIfRangeEtag() - { - $request = new HTTP\Request('GET', '/files/test.txt', [ - 'Range' => 'bytes=2-5', - 'If-Range' => '"'.md5('Test contents').'"', - ]); - $response = $this->request($request); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [4], - 'Content-Range' => ['bytes 2-5/13'], - 'ETag' => ['"'.md5('Test contents').'"'], - 'Last-Modified' => [$this->lastModified], - ], - $response->getHeaders() - ); - - $this->assertEquals(206, $response->getStatus()); - $this->assertEquals('st c', $response->getBodyAsString()); - } - - /** - * @depends testIfRangeEtag - */ - public function testIfRangeEtagIncorrect() - { - $request = new HTTP\Request('GET', '/files/test.txt', [ - 'Range' => 'bytes=2-5', - 'If-Range' => '"foobar"', - ]); - $response = $this->request($request); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [13], - 'ETag' => ['"'.md5('Test contents').'"'], - 'Last-Modified' => [$this->lastModified], - ], - $response->getHeaders() - ); - - $this->assertEquals(200, $response->getStatus()); - $this->assertEquals('Test contents', $response->getBodyAsString()); - } - - /** - * @depends testIfRangeEtag - */ - public function testIfRangeModificationDate() - { - $request = new HTTP\Request('GET', '/files/test.txt', [ - 'Range' => 'bytes=2-5', - 'If-Range' => 'tomorrow', - ]); - $response = $this->request($request); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [4], - 'Content-Range' => ['bytes 2-5/13'], - 'ETag' => ['"'.md5('Test contents').'"'], - 'Last-Modified' => [$this->lastModified], - ], - $response->getHeaders() - ); - - $this->assertEquals(206, $response->getStatus()); - $this->assertEquals('st c', $response->getBodyAsString()); - } - - /** - * @depends testIfRangeModificationDate - */ - public function testIfRangeModificationDateModified() - { - $request = new HTTP\Request('GET', '/files/test.txt', [ - 'Range' => 'bytes=2-5', - 'If-Range' => '-2 years', - ]); - $response = $this->request($request); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [13], - 'ETag' => ['"'.md5('Test contents').'"'], - 'Last-Modified' => [$this->lastModified], - ], - $response->getHeaders() - ); - - $this->assertEquals(200, $response->getStatus()); - $this->assertEquals('Test contents', $response->getBodyAsString()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php deleted file mode 100644 index e4dd3cdb6..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php +++ /dev/null @@ -1,433 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -use Sabre\HTTP; - -class ServerSimpleTest extends AbstractServer -{ - public function testConstructArray() - { - $nodes = [ - new SimpleCollection('hello'), - ]; - - $server = new Server($nodes); - $this->assertEquals($nodes[0], $server->tree->getNodeForPath('hello')); - } - - public function testConstructInvalidArg() - { - $this->expectException('Sabre\DAV\Exception'); - $server = new Server(1); - } - - public function testOptions() - { - $request = new HTTP\Request('OPTIONS', '/'); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals([ - 'DAV' => ['1, 3, extended-mkcol'], - 'MS-Author-Via' => ['DAV'], - 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'], - 'Accept-Ranges' => ['bytes'], - 'Content-Length' => ['0'], - 'X-Sabre-Version' => [Version::VERSION], - ], $this->response->getHeaders()); - - $this->assertEquals(200, $this->response->status); - $this->assertEquals('', $this->response->getBodyAsString()); - } - - public function testOptionsUnmapped() - { - $request = new HTTP\Request('OPTIONS', '/unmapped'); - $this->server->httpRequest = $request; - - $this->server->exec(); - - $this->assertEquals([ - 'DAV' => ['1, 3, extended-mkcol'], - 'MS-Author-Via' => ['DAV'], - 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, MKCOL'], - 'Accept-Ranges' => ['bytes'], - 'Content-Length' => ['0'], - 'X-Sabre-Version' => [Version::VERSION], - ], $this->response->getHeaders()); - - $this->assertEquals(200, $this->response->status); - $this->assertEquals('', $this->response->getBodyAsString()); - } - - public function testNonExistantMethod() - { - $serverVars = [ - 'REQUEST_URI' => '/', - 'REQUEST_METHOD' => 'BLABLA', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ], $this->response->getHeaders()); - - $this->assertEquals(501, $this->response->status); - } - - public function testBaseUri() - { - $serverVars = [ - 'REQUEST_URI' => '/blabla/test.txt', - 'REQUEST_METHOD' => 'GET', - ]; - $filename = $this->tempDir.'/test.txt'; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $this->server->setBaseUri('/blabla/'); - $this->assertEquals('/blabla/', $this->server->getBaseUri()); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [13], - 'Last-Modified' => [HTTP\toDate(new \DateTime('@'.filemtime($filename)))], - 'ETag' => ['"'.sha1(fileinode($filename).filesize($filename).filemtime($filename)).'"'], - ], - $this->response->getHeaders() - ); - - $this->assertEquals(200, $this->response->status); - $this->assertEquals('Test contents', stream_get_contents($this->response->body)); - } - - public function testBaseUriAddSlash() - { - $tests = [ - '/' => '/', - '/foo' => '/foo/', - '/foo/' => '/foo/', - '/foo/bar' => '/foo/bar/', - '/foo/bar/' => '/foo/bar/', - ]; - - foreach ($tests as $test => $result) { - $this->server->setBaseUri($test); - - $this->assertEquals($result, $this->server->getBaseUri()); - } - } - - public function testCalculateUri() - { - $uris = [ - 'http://www.example.org/root/somepath', - '/root/somepath', - '/root/somepath/', - '//root/somepath/', - '///root///somepath///', - ]; - - $this->server->setBaseUri('/root/'); - - foreach ($uris as $uri) { - $this->assertEquals('somepath', $this->server->calculateUri($uri)); - } - - $this->server->setBaseUri('/root'); - - foreach ($uris as $uri) { - $this->assertEquals('somepath', $this->server->calculateUri($uri)); - } - - $this->assertEquals('', $this->server->calculateUri('/root')); - - $this->server->setBaseUri('/'); - - foreach ($uris as $uri) { - $this->assertEquals('root/somepath', $this->server->calculateUri($uri)); - } - - $this->assertEquals('', $this->server->calculateUri('')); - } - - public function testCalculateUriSpecialChars() - { - $uris = [ - 'http://www.example.org/root/%C3%A0fo%C3%B3', - '/root/%C3%A0fo%C3%B3', - '/root/%C3%A0fo%C3%B3/', - ]; - - $this->server->setBaseUri('/root/'); - - foreach ($uris as $uri) { - $this->assertEquals("\xc3\xa0fo\xc3\xb3", $this->server->calculateUri($uri)); - } - - $this->server->setBaseUri('/root'); - - foreach ($uris as $uri) { - $this->assertEquals("\xc3\xa0fo\xc3\xb3", $this->server->calculateUri($uri)); - } - - $this->server->setBaseUri('/'); - - foreach ($uris as $uri) { - $this->assertEquals("root/\xc3\xa0fo\xc3\xb3", $this->server->calculateUri($uri)); - } - } - - public function testCalculateUriBreakout() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $uri = '/path1/'; - - $this->server->setBaseUri('/path2/'); - $this->server->calculateUri($uri); - } - - public function testGuessBaseUri() - { - $serverVars = [ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/index.php/root', - 'PATH_INFO' => '/root', - ]; - - $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals('/index.php/', $server->guessBaseUri()); - } - - /** - * @depends testGuessBaseUri - */ - public function testGuessBaseUriPercentEncoding() - { - $serverVars = [ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/index.php/dir/path2/path%20with%20spaces', - 'PATH_INFO' => '/dir/path2/path with spaces', - ]; - - $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals('/index.php/', $server->guessBaseUri()); - } - - /** - * @depends testGuessBaseUri - */ - /* - function testGuessBaseUriPercentEncoding2() { - - $this->markTestIncomplete('This behaviour is not yet implemented'); - $serverVars = [ - 'REQUEST_URI' => '/some%20directory+mixed/index.php/dir/path2/path%20with%20spaces', - 'PATH_INFO' => '/dir/path2/path with spaces', - ]; - - $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals('/some%20directory+mixed/index.php/', $server->guessBaseUri()); - - }*/ - - public function testGuessBaseUri2() - { - $serverVars = [ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/index.php/root/', - 'PATH_INFO' => '/root/', - ]; - - $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals('/index.php/', $server->guessBaseUri()); - } - - public function testGuessBaseUriNoPathInfo() - { - $serverVars = [ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/index.php/root', - ]; - - $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals('/', $server->guessBaseUri()); - } - - public function testGuessBaseUriNoPathInfo2() - { - $httpRequest = new HTTP\Request('GET', '/a/b/c/test.php'); - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals('/', $server->guessBaseUri()); - } - - /** - * @depends testGuessBaseUri - */ - public function testGuessBaseUriQueryString() - { - $serverVars = [ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/index.php/root?query_string=blabla', - 'PATH_INFO' => '/root', - ]; - - $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals('/index.php/', $server->guessBaseUri()); - } - - /** - * @depends testGuessBaseUri - */ - public function testGuessBaseUriBadConfig() - { - $this->expectException('Sabre\DAV\Exception'); - $serverVars = [ - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/index.php/root/heyyy', - 'PATH_INFO' => '/root', - ]; - - $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); - $server = new Server(); - $server->httpRequest = $httpRequest; - - $server->guessBaseUri(); - } - - public function testTriggerException() - { - $serverVars = [ - 'REQUEST_URI' => '/', - 'REQUEST_METHOD' => 'FOO', - ]; - - $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); - $this->server->httpRequest = $httpRequest; - $this->server->on('beforeMethod:*', [$this, 'exceptionTrigger']); - $this->server->exec(); - - $this->assertEquals([ - 'Content-Type' => ['application/xml; charset=utf-8'], - ], $this->response->getHeaders()); - - $this->assertEquals(500, $this->response->status); - } - - public function exceptionTrigger($request, $response) - { - throw new Exception('Hola'); - } - - public function testReportNotFound() - { - $serverVars = [ - 'REQUEST_URI' => '/', - 'REQUEST_METHOD' => 'REPORT', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $this->server->httpRequest = ($request); - $this->server->httpRequest->setBody('<?xml version="1.0"?><bla:myreport xmlns:bla="http://www.rooftopsolutions.nl/NS"></bla:myreport>'); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ], - $this->response->getHeaders() - ); - - $this->assertEquals(415, $this->response->status, 'We got an incorrect status back. Full response body follows: '.$this->response->getBodyAsString()); - } - - public function testReportIntercepted() - { - $serverVars = [ - 'REQUEST_URI' => '/', - 'REQUEST_METHOD' => 'REPORT', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); - $this->server->httpRequest = ($request); - $this->server->httpRequest->setBody('<?xml version="1.0"?><bla:myreport xmlns:bla="http://www.rooftopsolutions.nl/NS"></bla:myreport>'); - $this->server->on('report', [$this, 'reportHandler']); - $this->server->exec(); - - $this->assertEquals([ - 'X-Sabre-Version' => [Version::VERSION], - 'testheader' => ['testvalue'], - ], - $this->response->getHeaders() - ); - - $this->assertEquals(418, $this->response->status, 'We got an incorrect status back. Full response body follows: '.$this->response->getBodyAsString()); - } - - public function reportHandler($reportName, $result, $path) - { - if ('{http://www.rooftopsolutions.nl/NS}myreport' == $reportName) { - $this->server->httpResponse->setStatus(418); - $this->server->httpResponse->setHeader('testheader', 'testvalue'); - - return false; - } else { - return; - } - } - - public function testGetPropertiesForChildren() - { - $result = $this->server->getPropertiesForChildren('', [ - '{DAV:}getcontentlength', - ]); - - $expected = [ - 'test.txt' => ['{DAV:}getcontentlength' => 13], - 'dir/' => [], - ]; - - $this->assertEquals($expected, $result); - } - - /** - * There are certain cases where no HTTP status may be set. We need to - * intercept these and set it to a default error message. - */ - public function testNoHTTPStatusSet() - { - $this->server->on('method:GET', function () { return false; }, 1); - $this->server->httpRequest = new HTTP\Request('GET', '/'); - $this->server->exec(); - $this->assertEquals(500, $this->response->getStatus()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php deleted file mode 100644 index cb8a4ab32..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php +++ /dev/null @@ -1,97 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -class ServerUpdatePropertiesTest extends \PHPUnit\Framework\TestCase -{ - public function testUpdatePropertiesFail() - { - $tree = [ - new SimpleCollection('foo'), - ]; - $server = new Server($tree); - - $result = $server->updateProperties('foo', [ - '{DAV:}foo' => 'bar', - ]); - - $expected = [ - '{DAV:}foo' => 403, - ]; - $this->assertEquals($expected, $result); - } - - public function testUpdatePropertiesProtected() - { - $tree = [ - new SimpleCollection('foo'), - ]; - $server = new Server($tree); - - $server->on('propPatch', function ($path, PropPatch $propPatch) { - $propPatch->handleRemaining(function () { return true; }); - }); - $result = $server->updateProperties('foo', [ - '{DAV:}getetag' => 'bla', - '{DAV:}foo' => 'bar', - ]); - - $expected = [ - '{DAV:}getetag' => 403, - '{DAV:}foo' => 424, - ]; - $this->assertEquals($expected, $result); - } - - public function testUpdatePropertiesEventFail() - { - $tree = [ - new SimpleCollection('foo'), - ]; - $server = new Server($tree); - $server->on('propPatch', function ($path, PropPatch $propPatch) { - $propPatch->setResultCode('{DAV:}foo', 404); - $propPatch->handleRemaining(function () { return true; }); - }); - - $result = $server->updateProperties('foo', [ - '{DAV:}foo' => 'bar', - '{DAV:}foo2' => 'bla', - ]); - - $expected = [ - '{DAV:}foo' => 404, - '{DAV:}foo2' => 424, - ]; - $this->assertEquals($expected, $result); - } - - public function testUpdatePropertiesEventSuccess() - { - $tree = [ - new SimpleCollection('foo'), - ]; - $server = new Server($tree); - $server->on('propPatch', function ($path, PropPatch $propPatch) { - $propPatch->handle(['{DAV:}foo', '{DAV:}foo2'], function () { - return [ - '{DAV:}foo' => 200, - '{DAV:}foo2' => 201, - ]; - }); - }); - - $result = $server->updateProperties('foo', [ - '{DAV:}foo' => 'bar', - '{DAV:}foo2' => 'bla', - ]); - - $expected = [ - '{DAV:}foo' => 200, - '{DAV:}foo2' => 201, - ]; - $this->assertEquals($expected, $result); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php deleted file mode 100644 index 6edca5ecc..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php +++ /dev/null @@ -1,19 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -class SimpleFileTest extends \PHPUnit\Framework\TestCase -{ - public function testAll() - { - $file = new SimpleFile('filename.txt', 'contents', 'text/plain'); - - $this->assertEquals('filename.txt', $file->getName()); - $this->assertEquals('contents', $file->get()); - $this->assertEquals(8, $file->getSize()); - $this->assertEquals('"'.sha1('contents').'"', $file->getETag()); - $this->assertEquals('text/plain', $file->getContentType()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php b/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php deleted file mode 100644 index bc36c6b78..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -class StringUtilTest extends \PHPUnit\Framework\TestCase -{ - /** - * @param string $haystack - * @param string $needle - * @param string $collation - * @param string $matchType - * @param string $result - * - * @throws Exception\BadRequest - * - * @dataProvider dataset - */ - public function testTextMatch($haystack, $needle, $collation, $matchType, $result) - { - $this->assertEquals($result, StringUtil::textMatch($haystack, $needle, $collation, $matchType)); - } - - public function dataset() - { - return [ - ['FOOBAR', 'FOO', 'i;octet', 'contains', true], - ['FOOBAR', 'foo', 'i;octet', 'contains', false], - ['FÖÖBAR', 'FÖÖ', 'i;octet', 'contains', true], - ['FÖÖBAR', 'föö', 'i;octet', 'contains', false], - ['FOOBAR', 'FOOBAR', 'i;octet', 'equals', true], - ['FOOBAR', 'fooBAR', 'i;octet', 'equals', false], - ['FOOBAR', 'FOO', 'i;octet', 'starts-with', true], - ['FOOBAR', 'foo', 'i;octet', 'starts-with', false], - ['FOOBAR', 'BAR', 'i;octet', 'starts-with', false], - ['FOOBAR', 'bar', 'i;octet', 'starts-with', false], - ['FOOBAR', 'FOO', 'i;octet', 'ends-with', false], - ['FOOBAR', 'foo', 'i;octet', 'ends-with', false], - ['FOOBAR', 'BAR', 'i;octet', 'ends-with', true], - ['FOOBAR', 'bar', 'i;octet', 'ends-with', false], - - ['FOOBAR', 'FOO', 'i;ascii-casemap', 'contains', true], - ['FOOBAR', 'foo', 'i;ascii-casemap', 'contains', true], - ['FÖÖBAR', 'FÖÖ', 'i;ascii-casemap', 'contains', true], - ['FÖÖBAR', 'föö', 'i;ascii-casemap', 'contains', false], - ['FOOBAR', 'FOOBAR', 'i;ascii-casemap', 'equals', true], - ['FOOBAR', 'fooBAR', 'i;ascii-casemap', 'equals', true], - ['FOOBAR', 'FOO', 'i;ascii-casemap', 'starts-with', true], - ['FOOBAR', 'foo', 'i;ascii-casemap', 'starts-with', true], - ['FOOBAR', 'BAR', 'i;ascii-casemap', 'starts-with', false], - ['FOOBAR', 'bar', 'i;ascii-casemap', 'starts-with', false], - ['FOOBAR', 'FOO', 'i;ascii-casemap', 'ends-with', false], - ['FOOBAR', 'foo', 'i;ascii-casemap', 'ends-with', false], - ['FOOBAR', 'BAR', 'i;ascii-casemap', 'ends-with', true], - ['FOOBAR', 'bar', 'i;ascii-casemap', 'ends-with', true], - - ['FOOBAR', 'FOO', 'i;unicode-casemap', 'contains', true], - ['FOOBAR', 'foo', 'i;unicode-casemap', 'contains', true], - ['FÖÖBAR', 'FÖÖ', 'i;unicode-casemap', 'contains', true], - ['FÖÖBAR', 'föö', 'i;unicode-casemap', 'contains', true], - ['FOOBAR', 'FOOBAR', 'i;unicode-casemap', 'equals', true], - ['FOOBAR', 'fooBAR', 'i;unicode-casemap', 'equals', true], - ['FOOBAR', 'FOO', 'i;unicode-casemap', 'starts-with', true], - ['FOOBAR', 'foo', 'i;unicode-casemap', 'starts-with', true], - ['FOOBAR', 'BAR', 'i;unicode-casemap', 'starts-with', false], - ['FOOBAR', 'bar', 'i;unicode-casemap', 'starts-with', false], - ['FOOBAR', 'FOO', 'i;unicode-casemap', 'ends-with', false], - ['FOOBAR', 'foo', 'i;unicode-casemap', 'ends-with', false], - ['FOOBAR', 'BAR', 'i;unicode-casemap', 'ends-with', true], - ['FOOBAR', 'bar', 'i;unicode-casemap', 'ends-with', true], - ]; - } - - public function testBadCollation() - { - $this->expectException('Sabre\DAV\Exception\BadRequest'); - StringUtil::textMatch('foobar', 'foo', 'blabla', 'contains'); - } - - public function testBadMatchType() - { - $this->expectException('Sabre\DAV\Exception\BadRequest'); - StringUtil::textMatch('foobar', 'foo', 'i;octet', 'booh'); - } - - public function testEnsureUTF8_ascii() - { - $inputString = 'harkema'; - $outputString = 'harkema'; - - $this->assertEquals( - $outputString, - StringUtil::ensureUTF8($inputString) - ); - } - - public function testEnsureUTF8_latin1() - { - $inputString = "m\xfcnster"; - $outputString = 'münster'; - - $this->assertEquals( - $outputString, - StringUtil::ensureUTF8($inputString) - ); - } - - public function testEnsureUTF8_utf8() - { - $inputString = "m\xc3\xbcnster"; - $outputString = 'münster'; - - $this->assertEquals( - $outputString, - StringUtil::ensureUTF8($inputString) - ); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php b/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php deleted file mode 100644 index 951078bf0..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php +++ /dev/null @@ -1,204 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -use Sabre\HTTP; - -class TemporaryFileFilterTest extends AbstractServer -{ - public function setup(): void - { - parent::setUp(); - $plugin = new TemporaryFileFilterPlugin(SABRE_TEMPDIR.'/tff'); - $this->server->addPlugin($plugin); - } - - public function testPutNormal() - { - $request = new HTTP\Request('PUT', '/testput.txt', [], 'Testing new file'); - - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals('', $this->response->getBodyAsString()); - $this->assertEquals(201, $this->response->status); - $this->assertEquals('0', $this->response->getHeader('Content-Length')); - - $this->assertEquals('Testing new file', file_get_contents(SABRE_TEMPDIR.'/testput.txt')); - } - - public function testPutTemp() - { - // mimicking an OS/X resource fork - $request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file'); - - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals('', $this->response->getBodyAsString()); - $this->assertEquals(201, $this->response->status); - $this->assertEquals([ - 'X-Sabre-Temp' => ['true'], - ], $this->response->getHeaders()); - - $this->assertFalse(file_exists(SABRE_TEMPDIR.'/._testput.txt'), '._testput.txt should not exist in the regular file structure.'); - } - - public function testPutTempIfNoneMatch() - { - // mimicking an OS/X resource fork - $request = new HTTP\Request('PUT', '/._testput.txt', ['If-None-Match' => '*'], 'Testing new file'); - - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals('', $this->response->getBodyAsString()); - $this->assertEquals(201, $this->response->status); - $this->assertEquals([ - 'X-Sabre-Temp' => ['true'], - ], $this->response->getHeaders()); - - $this->assertFalse(file_exists(SABRE_TEMPDIR.'/._testput.txt'), '._testput.txt should not exist in the regular file structure.'); - - $this->server->exec(); - - $this->assertEquals(412, $this->response->status); - $this->assertEquals([ - 'X-Sabre-Temp' => ['true'], - 'Content-Type' => ['application/xml; charset=utf-8'], - ], $this->response->getHeaders()); - } - - public function testPutGet() - { - // mimicking an OS/X resource fork - $request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals('', $this->response->getBodyAsString()); - $this->assertEquals(201, $this->response->status); - $this->assertEquals([ - 'X-Sabre-Temp' => ['true'], - ], $this->response->getHeaders()); - - $request = new HTTP\Request('GET', '/._testput.txt'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(200, $this->response->status); - $this->assertEquals([ - 'X-Sabre-Temp' => ['true'], - 'Content-Length' => [16], - 'Content-Type' => ['application/octet-stream'], - ], $this->response->getHeaders()); - - $this->assertEquals('Testing new file', stream_get_contents($this->response->body)); - } - - public function testGetWithBrowserPlugin() - { - $this->server->addPlugin(new Browser\Plugin()); - $request = new HTTP\Request('GET', '/'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(200, $this->response->status); - } - - public function testLockNonExistant() - { - mkdir(SABRE_TEMPDIR.'/locksdir'); - $locksBackend = new Locks\Backend\File(SABRE_TEMPDIR.'/locks'); - $locksPlugin = new Locks\Plugin($locksBackend); - $this->server->addPlugin($locksPlugin); - - // mimicking an OS/X resource fork - $request = new HTTP\Request('LOCK', '/._testput.txt'); - $request->setBody('<?xml version="1.0"?> -<D:lockinfo xmlns:D="DAV:"> - <D:lockscope><D:exclusive/></D:lockscope> - <D:locktype><D:write/></D:locktype> - <D:owner> - <D:href>http://example.org/~ejw/contact.html</D:href> - </D:owner> -</D:lockinfo>'); - - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals(201, $this->response->status); - $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - $this->assertEquals('true', $this->response->getHeader('X-Sabre-Temp')); - - $this->assertFalse(file_exists(SABRE_TEMPDIR.'/._testlock.txt'), '._testlock.txt should not exist in the regular file structure.'); - } - - public function testPutDelete() - { - // mimicking an OS/X resource fork - $request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals('', $this->response->getBodyAsString()); - $this->assertEquals(201, $this->response->status); - $this->assertEquals([ - 'X-Sabre-Temp' => ['true'], - ], $this->response->getHeaders()); - - $request = new HTTP\Request('DELETE', '/._testput.txt'); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(204, $this->response->status, "Incorrect status code received. Full body:\n".$this->response->getBodyAsString()); - $this->assertEquals([ - 'X-Sabre-Temp' => ['true'], - ], $this->response->getHeaders()); - - $this->assertEquals('', $this->response->getBodyAsString()); - } - - public function testPutPropfind() - { - // mimicking an OS/X resource fork - $request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file'); - $this->server->httpRequest = $request; - $this->server->exec(); - - $bodyAsString = $this->response->getBodyAsString(); - $this->assertEquals('', $bodyAsString); - $this->assertEquals(201, $this->response->status); - $this->assertEquals([ - 'X-Sabre-Temp' => ['true'], - ], $this->response->getHeaders()); - - $request = new HTTP\Request('PROPFIND', '/._testput.txt'); - - $this->server->httpRequest = ($request); - $this->server->exec(); - - $bodyAsString = $this->response->getBodyAsString(); - $this->assertEquals(207, $this->response->status, 'Incorrect status code returned. Body: '.$bodyAsString); - $this->assertEquals([ - 'X-Sabre-Temp' => ['true'], - 'Content-Type' => ['application/xml; charset=utf-8'], - ], $this->response->getHeaders()); - - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $bodyAsString); - $xml = simplexml_load_string($body); - $xml->registerXPathNamespace('d', 'urn:DAV'); - - list($data) = $xml->xpath('/d:multistatus/d:response/d:href'); - $this->assertEquals('/._testput.txt', (string) $data, 'href element should have been /._testput.txt'); - - $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype'); - $this->assertEquals(1, count($data)); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php b/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php deleted file mode 100644 index 3bfe3b3b0..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -use Sabre\HTTP\RequestInterface; -use Sabre\HTTP\ResponseInterface; - -class TestPlugin extends ServerPlugin -{ - public $beforeMethod; - - public function getFeatures() - { - return ['drinking']; - } - - public function getHTTPMethods($uri) - { - return ['BEER', 'WINE']; - } - - public function initialize(Server $server) - { - $server->on('beforeMethod:*', [$this, 'beforeMethod']); - } - - public function beforeMethod(RequestInterface $request, ResponseInterface $response) - { - $this->beforeMethod = $request->getMethod(); - - return true; - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php deleted file mode 100644 index e3f04ea3a..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php +++ /dev/null @@ -1,238 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -class TreeTest extends \PHPUnit\Framework\TestCase -{ - public function testNodeExists() - { - $tree = new TreeMock(); - - $this->assertTrue($tree->nodeExists('hi')); - $this->assertFalse($tree->nodeExists('hello')); - } - - public function testCopy() - { - $tree = new TreeMock(); - $tree->copy('hi', 'hi2'); - - $this->assertArrayHasKey('hi2', $tree->getNodeForPath('')->newDirectories); - $this->assertEquals('foobar', $tree->getNodeForPath('hi/file')->get()); - $this->assertEquals(['test1' => 'value'], $tree->getNodeForPath('hi/file')->getProperties([])); - } - - public function testCopyFile() - { - $tree = new TreeMock(); - $tree->copy('hi/file', 'hi/newfile'); - - $this->assertArrayHasKey('newfile', $tree->getNodeForPath('hi')->newFiles); - } - - public function testCopyFile0() - { - $tree = new TreeMock(); - $tree->copy('hi/file', 'hi/0'); - - $this->assertArrayHasKey('0', $tree->getNodeForPath('hi')->newFiles); - } - - public function testMove() - { - $tree = new TreeMock(); - $tree->move('hi', 'hi2'); - - $this->assertEquals('hi2', $tree->getNodeForPath('hi')->getName()); - $this->assertTrue($tree->getNodeForPath('hi')->isRenamed); - } - - public function testDeepMove() - { - $tree = new TreeMock(); - $tree->move('hi/sub', 'hi2'); - - $this->assertArrayHasKey('hi2', $tree->getNodeForPath('')->newDirectories); - $this->assertTrue($tree->getNodeForPath('hi/sub')->isDeleted); - } - - public function testDelete() - { - $tree = new TreeMock(); - $tree->delete('hi'); - $this->assertTrue($tree->getNodeForPath('hi')->isDeleted); - } - - public function testGetChildren() - { - $tree = new TreeMock(); - $children = $tree->getChildren(''); - $firstChild = $children->current(); - $this->assertEquals('hi', $firstChild->getName()); - } - - public function testGetMultipleNodes() - { - $tree = new TreeMock(); - $result = $tree->getMultipleNodes(['hi/sub', 'hi/file']); - $this->assertArrayHasKey('hi/sub', $result); - $this->assertArrayHasKey('hi/file', $result); - - $this->assertEquals('sub', $result['hi/sub']->getName()); - $this->assertEquals('file', $result['hi/file']->getName()); - } - - public function testGetMultipleNodes2() - { - $tree = new TreeMock(); - $result = $tree->getMultipleNodes(['multi/1', 'multi/2']); - $this->assertArrayHasKey('multi/1', $result); - $this->assertArrayHasKey('multi/2', $result); - } -} - -class TreeMock extends Tree -{ - private $nodes = []; - - public function __construct() - { - $file = new TreeFileTester('file'); - $file->properties = ['test1' => 'value']; - $file->data = 'foobar'; - - parent::__construct( - new TreeDirectoryTester('root', [ - new TreeDirectoryTester('hi', [ - new TreeDirectoryTester('sub'), - $file, - ]), - new TreeMultiGetTester('multi', [ - new TreeFileTester('1'), - new TreeFileTester('2'), - new TreeFileTester('3'), - ]), - ]) - ); - } -} - -class TreeDirectoryTester extends SimpleCollection -{ - public $newDirectories = []; - public $newFiles = []; - public $isDeleted = false; - public $isRenamed = false; - - public function createDirectory($name) - { - $this->newDirectories[$name] = true; - } - - public function createFile($name, $data = null) - { - $this->newFiles[$name] = $data; - } - - public function getChild($name) - { - if (isset($this->newDirectories[$name])) { - return new self($name); - } - if (isset($this->newFiles[$name])) { - return new TreeFileTester($name, $this->newFiles[$name]); - } - - return parent::getChild($name); - } - - public function childExists($name) - { - return (bool) $this->getChild($name); - } - - public function delete() - { - $this->isDeleted = true; - } - - public function setName($name) - { - $this->isRenamed = true; - $this->name = $name; - } -} - -class TreeFileTester extends File implements IProperties -{ - public $name; - public $data; - public $properties; - - public function __construct($name, $data = null) - { - $this->name = $name; - if (is_null($data)) { - $data = 'bla'; - } - $this->data = $data; - } - - public function getName() - { - return $this->name; - } - - public function get() - { - return $this->data; - } - - public function getProperties($properties) - { - return $this->properties; - } - - /** - * Updates properties on this node. - * - * This method received a PropPatch object, which contains all the - * information about the update. - * - * To update specific properties, call the 'handle' method on this object. - * Read the PropPatch documentation for more information. - */ - public function propPatch(PropPatch $propPatch) - { - $this->properties = $propPatch->getMutations(); - $propPatch->setRemainingResultCode(200); - } -} - -class TreeMultiGetTester extends TreeDirectoryTester implements IMultiGet -{ - /** - * This method receives a list of paths in it's first argument. - * It must return an array with Node objects. - * - * If any children are not found, you do not have to return them. - * - * @return array - */ - public function getMultipleChildren(array $paths) - { - $result = []; - foreach ($paths as $path) { - try { - $child = $this->getChild($path); - $result[] = $child; - } catch (Exception\NotFound $e) { - // Do nothing - } - } - - return $result; - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAV/UUIDUtilTest.php b/vendor/sabre/dav/tests/Sabre/DAV/UUIDUtilTest.php deleted file mode 100644 index d7ef9bec9..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAV/UUIDUtilTest.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAV; - -class UUIDUtilTest extends \PHPUnit\Framework\TestCase -{ - public function testValidateUUID() - { - $this->assertTrue( - UUIDUtil::validateUUID('11111111-2222-3333-4444-555555555555') - ); - $this->assertFalse( - UUIDUtil::validateUUID(' 11111111-2222-3333-4444-555555555555') - ); - $this->assertTrue( - UUIDUtil::validateUUID('ffffffff-2222-3333-4444-555555555555') - ); - $this->assertFalse( - UUIDUtil::validateUUID('fffffffg-2222-3333-4444-555555555555') - ); - } -} |