diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-10-08 06:18:29 -0700 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-10-08 06:18:29 -0700 |
commit | e7e53363acd07f386a172a136ef564a6b501096b (patch) | |
tree | 0beda878412b00f0c7278646315f39e5b0a99d90 | |
parent | f49de3437322283ca9e19e301627e9af9421c4c9 (diff) | |
parent | c77f74e1defddaa277f85bc9b6242371a13fda42 (diff) | |
download | nextcloud-server-e7e53363acd07f386a172a136ef564a6b501096b.tar.gz nextcloud-server-e7e53363acd07f386a172a136ef564a6b501096b.zip |
Merge pull request #5194 from owncloud/fixing-5172-master
adding check isDeletable() on $sourcePath
-rw-r--r-- | lib/private/connector/sabre/objecttree.php | 3 | ||||
-rw-r--r-- | tests/lib/connector/sabre/objecttree.php | 32 |
2 files changed, 22 insertions, 13 deletions
diff --git a/lib/private/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php index 80c3840b99d..df8902f66e2 100644 --- a/lib/private/connector/sabre/objecttree.php +++ b/lib/private/connector/sabre/objecttree.php @@ -87,6 +87,9 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { if (!$fs->isUpdatable($destinationDir)) { throw new \Sabre_DAV_Exception_Forbidden(); } + if (!$fs->isDeletable($sourcePath)) { + throw new \Sabre_DAV_Exception_Forbidden(); + } } $renameOkay = $fs->rename($sourcePath, $destinationPath); diff --git a/tests/lib/connector/sabre/objecttree.php b/tests/lib/connector/sabre/objecttree.php index 1d76bb59676..e32f2365f95 100644 --- a/tests/lib/connector/sabre/objecttree.php +++ b/tests/lib/connector/sabre/objecttree.php @@ -15,8 +15,9 @@ use Sabre_DAV_Exception_Forbidden; class TestDoubleFileView extends \OC\Files\View{ - public function __construct($updatables, $canRename = true) { + public function __construct($updatables, $deletables, $canRename = true) { $this->updatables = $updatables; + $this->deletables = $deletables; $this->canRename = $canRename; } @@ -24,6 +25,10 @@ class TestDoubleFileView extends \OC\Files\View{ return $this->updatables[$path]; } + public function isDeletable($path) { + return $this->deletables[$path]; + } + public function rename($path1, $path2) { return $this->canRename; } @@ -35,31 +40,32 @@ class ObjectTree extends PHPUnit_Framework_TestCase { * @dataProvider moveFailedProvider * @expectedException Sabre_DAV_Exception_Forbidden */ - public function testMoveFailed($source, $dest, $updatables) { - $this->moveTest($source, $dest, $updatables); + public function testMoveFailed($source, $dest, $updatables, $deletables) { + $this->moveTest($source, $dest, $updatables, $deletables); } /** * @dataProvider moveSuccessProvider */ - public function testMoveSuccess($source, $dest, $updatables) { - $this->moveTest($source, $dest, $updatables); + public function testMoveSuccess($source, $dest, $updatables, $deletables) { + $this->moveTest($source, $dest, $updatables, $deletables); $this->assertTrue(true); } function moveFailedProvider() { return array( - array('a/b', 'a/c', array('a' => false, 'a/b' => false, 'a/c' => false)), - array('a/b', 'b/b', array('a' => false, 'a/b' => false, 'b' => false, 'b/b' => false)), - array('a/b', 'b/b', array('a' => false, 'a/b' => true, 'b' => false, 'b/b' => false)), - array('a/b', 'b/b', array('a' => true, 'a/b' => true, 'b' => false, 'b/b' => false)), + array('a/b', 'a/c', array('a' => false, 'a/b' => false, 'a/c' => false), array()), + array('a/b', 'b/b', array('a' => false, 'a/b' => false, 'b' => false, 'b/b' => false), array()), + array('a/b', 'b/b', array('a' => false, 'a/b' => true, 'b' => false, 'b/b' => false), array()), + array('a/b', 'b/b', array('a' => true, 'a/b' => true, 'b' => false, 'b/b' => false), array()), + array('a/b', 'b/b', array('a' => true, 'a/b' => true, 'b' => true, 'b/b' => false), array('a/b' => false)), ); } function moveSuccessProvider() { return array( - array('a/b', 'a/c', array('a' => false, 'a/b' => true, 'a/c' => false)), - array('a/b', 'b/b', array('a' => true, 'a/b' => true, 'b' => true, 'b/b' => false)), + array('a/b', 'a/c', array('a' => false, 'a/b' => true, 'a/c' => false), array()), + array('a/b', 'b/b', array('a' => true, 'a/b' => true, 'b' => true, 'b/b' => false), array('a/b' => true)), ); } @@ -68,7 +74,7 @@ class ObjectTree extends PHPUnit_Framework_TestCase { * @param $dest * @param $updatables */ - private function moveTest($source, $dest, $updatables) { + private function moveTest($source, $dest, $updatables, $deletables) { $rootDir = new OC_Connector_Sabre_Directory(''); $objectTree = $this->getMock('\OC\Connector\Sabre\ObjectTree', array('nodeExists', 'getNodeForPath'), @@ -80,7 +86,7 @@ class ObjectTree extends PHPUnit_Framework_TestCase { ->will($this->returnValue(false)); /** @var $objectTree \OC\Connector\Sabre\ObjectTree */ - $objectTree->fileView = new TestDoubleFileView($updatables); + $objectTree->fileView = new TestDoubleFileView($updatables, $deletables); $objectTree->move($source, $dest); } |