diff options
Diffstat (limited to 'apps/dav')
7 files changed, 82 insertions, 5 deletions
diff --git a/apps/dav/tests/unit/connector/sabre/requesttest/auth.php b/apps/dav/tests/unit/connector/sabre/requesttest/auth.php index 7cab4da5264..41b554d11db 100644 --- a/apps/dav/tests/unit/connector/sabre/requesttest/auth.php +++ b/apps/dav/tests/unit/connector/sabre/requesttest/auth.php @@ -6,7 +6,7 @@ * See the COPYING-README file. */ -namespace Test\Connector\Sabre\RequestTest; +namespace OCA\DAV\Tests\Unit\Connector\Sabre\RequestTest; use Sabre\DAV\Auth\Backend\BackendInterface; diff --git a/apps/dav/tests/unit/connector/sabre/requesttest/downloadtest.php b/apps/dav/tests/unit/connector/sabre/requesttest/downloadtest.php new file mode 100644 index 00000000000..245deff3b31 --- /dev/null +++ b/apps/dav/tests/unit/connector/sabre/requesttest/downloadtest.php @@ -0,0 +1,52 @@ +<?php +/** + * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCA\DAV\Tests\Unit\Connector\Sabre\RequestTest; + +use OCP\AppFramework\Http; +use OCP\Lock\ILockingProvider; + +class DownloadTest extends RequestTest { + public function testDownload() { + $user = $this->getUniqueID(); + $view = $this->setupUser($user, 'pass'); + + $view->file_put_contents('foo.txt', 'bar'); + + $response = $this->request($view, $user, 'pass', 'GET', '/foo.txt'); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); + $this->assertEquals(stream_get_contents($response->getBody()), 'bar'); + } + + /** + * @expectedException \OCA\DAV\Connector\Sabre\Exception\FileLocked + */ + public function testDownloadWriteLocked() { + $user = $this->getUniqueID(); + $view = $this->setupUser($user, 'pass'); + + $view->file_put_contents('foo.txt', 'bar'); + + $view->lockFile('/foo.txt', ILockingProvider::LOCK_EXCLUSIVE); + + $this->request($view, $user, 'pass', 'GET', '/foo.txt', 'asd'); + } + + public function testDownloadReadLocked() { + $user = $this->getUniqueID(); + $view = $this->setupUser($user, 'pass'); + + $view->file_put_contents('foo.txt', 'bar'); + + $view->lockFile('/foo.txt', ILockingProvider::LOCK_SHARED); + + $response = $this->request($view, $user, 'pass', 'GET', '/foo.txt', 'asd'); + $this->assertEquals(Http::STATUS_OK, $response->getStatus()); + $this->assertEquals(stream_get_contents($response->getBody()), 'bar'); + } +} diff --git a/apps/dav/tests/unit/connector/sabre/requesttest/encryptionuploadtest.php b/apps/dav/tests/unit/connector/sabre/requesttest/encryptionuploadtest.php new file mode 100644 index 00000000000..ed1d6046d75 --- /dev/null +++ b/apps/dav/tests/unit/connector/sabre/requesttest/encryptionuploadtest.php @@ -0,0 +1,25 @@ +<?php +/** + * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCA\DAV\Tests\Unit\Connector\Sabre\RequestTest; + +use OC\Files\View; +use Test\Traits\EncryptionTrait; + +class EncryptionUploadTest extends UploadTest { + use EncryptionTrait; + + protected function setupUser($name, $password) { + $this->createUser($name, $password); + $tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder(); + $this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]); + $this->setupForUser($name, $password); + $this->loginWithEncryption($name); + return new View('/' . $name . '/files'); + } +} diff --git a/apps/dav/tests/unit/connector/sabre/requesttest/exceptionplugin.php b/apps/dav/tests/unit/connector/sabre/requesttest/exceptionplugin.php index 606b5a27984..53cd186bbc8 100644 --- a/apps/dav/tests/unit/connector/sabre/requesttest/exceptionplugin.php +++ b/apps/dav/tests/unit/connector/sabre/requesttest/exceptionplugin.php @@ -6,7 +6,7 @@ * See the COPYING-README file. */ -namespace Test\Connector\Sabre\RequestTest; +namespace OCA\DAV\Tests\Unit\Connector\Sabre\RequestTest; use Sabre\DAV\Exception; diff --git a/apps/dav/tests/unit/connector/sabre/requesttest/requesttest.php b/apps/dav/tests/unit/connector/sabre/requesttest/requesttest.php index 4e1bc16819c..d90cf6e19bc 100644 --- a/apps/dav/tests/unit/connector/sabre/requesttest/requesttest.php +++ b/apps/dav/tests/unit/connector/sabre/requesttest/requesttest.php @@ -6,7 +6,7 @@ * See the COPYING-README file. */ -namespace Test\Connector\Sabre\RequestTest; +namespace OCA\DAV\Tests\Unit\Connector\Sabre\RequestTest; use OCA\DAV\Connector\Sabre\Server; use OCA\DAV\Connector\Sabre\ServerFactory; diff --git a/apps/dav/tests/unit/connector/sabre/requesttest/sapi.php b/apps/dav/tests/unit/connector/sabre/requesttest/sapi.php index cda9fdb70f5..3af94010288 100644 --- a/apps/dav/tests/unit/connector/sabre/requesttest/sapi.php +++ b/apps/dav/tests/unit/connector/sabre/requesttest/sapi.php @@ -6,7 +6,7 @@ * See the COPYING-README file. */ -namespace Test\Connector\Sabre\RequestTest; +namespace OCA\DAV\Tests\Unit\Connector\Sabre\RequestTest; use Sabre\HTTP\Request; use Sabre\HTTP\Response; diff --git a/apps/dav/tests/unit/connector/sabre/requesttest/uploadtest.php b/apps/dav/tests/unit/connector/sabre/requesttest/uploadtest.php index 8f39aff81b9..9a067f230a3 100644 --- a/apps/dav/tests/unit/connector/sabre/requesttest/uploadtest.php +++ b/apps/dav/tests/unit/connector/sabre/requesttest/uploadtest.php @@ -6,7 +6,7 @@ * See the COPYING-README file. */ -namespace Test\Connector\Sabre\RequestTest; +namespace OCA\DAV\Tests\Unit\Connector\Sabre\RequestTest; use OC\AppFramework\Http; |