Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2015-10-06 16:36:54 +0300
committerRoeland Jago Douma <rullzer@owncloud.com>2015-10-07 12:58:16 +0300
commit1ee56c702de8498bdc17bc7e93ff4c24c7b5590b (patch)
tree9a09225eb2a94baadcf7f1cf2ff852c3441a517e /tests
parentcd818e7419fb39d97683ecc5803534b0ed632596 (diff)
[WEBDAV] check if delete of source is allowed on move
Fixes #5251 If we perform a move we need to make sure first that the source can be deleted. Else the dest might be cleared but the move will fail later. * Added unit tests Eventually we need more and better checking here.
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/connector/sabre/filesplugin.php61
1 files changed, 58 insertions, 3 deletions
diff --git a/tests/lib/connector/sabre/filesplugin.php b/tests/lib/connector/sabre/filesplugin.php
index a4cf9f7bfb9..0aa62cab176 100644
--- a/tests/lib/connector/sabre/filesplugin.php
+++ b/tests/lib/connector/sabre/filesplugin.php
@@ -31,13 +31,24 @@ class FilesPlugin extends \Test\TestCase {
*/
private $plugin;
+ /**
+ * @var \OC\Files\View
+ */
+ private $view;
+
public function setUp() {
parent::setUp();
- $this->server = new \Sabre\DAV\Server();
+ $this->server = $this->getMockBuilder('\Sabre\DAV\Server')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->tree = $this->getMockBuilder('\Sabre\DAV\Tree')
->disableOriginalConstructor()
->getMock();
- $this->plugin = new \OC\Connector\Sabre\FilesPlugin($this->tree);
+ $this->view = $this->getMockBuilder('\OC\Files\View')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->plugin = new \OC\Connector\Sabre\FilesPlugin($this->tree, $this->view);
$this->plugin->initialize($this->server);
}
@@ -104,7 +115,7 @@ class FilesPlugin extends \Test\TestCase {
}
public function testGetPublicPermissions() {
- $this->plugin = new \OC\Connector\Sabre\FilesPlugin($this->tree, true);
+ $this->plugin = new \OC\Connector\Sabre\FilesPlugin($this->tree, $this->view, true);
$this->plugin->initialize($this->server);
$propFind = new \Sabre\DAV\PropFind(
@@ -196,4 +207,48 @@ class FilesPlugin extends \Test\TestCase {
$this->assertEquals(200, $result[self::GETETAG_PROPERTYNAME]);
}
+ /**
+ * Testcase from https://github.com/owncloud/core/issues/5251
+ *
+ * |-FolderA
+ * |-text.txt
+ * |-test.txt
+ *
+ * FolderA is an incomming shared folder and there are no delete permissions.
+ * Thus moving /FolderA/test.txt to /test.txt should fail already on that check
+ *
+ * @expectedException \Sabre\DAV\Exception\Forbidden
+ * @expectedExceptionMessage FolderA/test.txt cannot be deleted
+ */
+ public function testMoveSrcNotDeletable() {
+ $fileInfoFolderATestTXT = $this->getMockBuilder('\OCP\Files\FileInfo')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $fileInfoFolderATestTXT->expects($this->once())
+ ->method('isDeletable')
+ ->willReturn(false);
+
+ $this->view->expects($this->once())
+ ->method('getFileInfo')
+ ->with('FolderA/test.txt')
+ ->willReturn($fileInfoFolderATestTXT);
+
+ $this->plugin->checkMove('FolderA/test.txt', 'test.txt');
+ }
+
+ public function testMoveSrcDeletable() {
+ $fileInfoFolderATestTXT = $this->getMockBuilder('\OCP\Files\FileInfo')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $fileInfoFolderATestTXT->expects($this->once())
+ ->method('isDeletable')
+ ->willReturn(true);
+
+ $this->view->expects($this->once())
+ ->method('getFileInfo')
+ ->with('FolderA/test.txt')
+ ->willReturn($fileInfoFolderATestTXT);
+
+ $this->plugin->checkMove('FolderA/test.txt', 'test.txt');
+ }
}