From 10c350b8955a318d9b2e50714f22bdfab06abf87 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 24 Sep 2014 17:50:33 +0200 Subject: [PATCH] Fix dav permissions for folders without create permissions --- lib/private/connector/sabre/node.php | 2 +- tests/lib/connector/sabre/node.php | 55 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 tests/lib/connector/sabre/node.php diff --git a/lib/private/connector/sabre/node.php b/lib/private/connector/sabre/node.php index 2ac7363a15e..a22dc9c5fbe 100644 --- a/lib/private/connector/sabre/node.php +++ b/lib/private/connector/sabre/node.php @@ -264,7 +264,7 @@ abstract class OC_Connector_Sabre_Node implements \Sabre\DAV\INode, \Sabre\DAV\I $p .= 'W'; } } else { - if ($this->info->isUpdateable()) { + if ($this->info->isCreatable()) { $p .= 'CK'; } } diff --git a/tests/lib/connector/sabre/node.php b/tests/lib/connector/sabre/node.php new file mode 100644 index 00000000000..0f303457248 --- /dev/null +++ b/tests/lib/connector/sabre/node.php @@ -0,0 +1,55 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace Test\Connector\Sabre; + +use OC\Files\FileInfo; +use OC\Files\View; + +class Node extends \PHPUnit_Framework_TestCase { + public function davPermissionsProvider() { + return array( + array(\OCP\PERMISSION_ALL, 'file', false, false, 'RDNVW'), + array(\OCP\PERMISSION_ALL, 'dir', false, false, 'RDNVCK'), + array(\OCP\PERMISSION_ALL, 'file', true, false, 'SRDNVW'), + array(\OCP\PERMISSION_ALL, 'file', true, true, 'SRMDNVW'), + array(\OCP\PERMISSION_ALL - \OCP\PERMISSION_SHARE, 'file', true, false, 'SDNVW'), + array(\OCP\PERMISSION_ALL - \OCP\PERMISSION_UPDATE, 'file', false, false, 'RDNV'), + array(\OCP\PERMISSION_ALL - \OCP\PERMISSION_DELETE, 'file', false, false, 'RW'), + array(\OCP\PERMISSION_ALL - \OCP\PERMISSION_CREATE, 'file', false, false, 'RDNVW'), + array(\OCP\PERMISSION_ALL - \OCP\PERMISSION_CREATE, 'dir', false, false, 'RDNV'), + ); + } + + /** + * @dataProvider davPermissionsProvider + */ + public function testDavPermissions($permissions, $type, $shared, $mounted, $expected) { + $info = $this->getMockBuilder('\OC\Files\FileInfo') + ->disableOriginalConstructor() + ->setMethods(array('getPermissions', 'isShared', 'isMounted', 'getType')) + ->getMock(); + $info->expects($this->any()) + ->method('getPermissions') + ->will($this->returnValue($permissions)); + $info->expects($this->any()) + ->method('isShared') + ->will($this->returnValue($shared)); + $info->expects($this->any()) + ->method('isMounted') + ->will($this->returnValue($mounted)); + $info->expects($this->any()) + ->method('getType') + ->will($this->returnValue($type)); + $view = $this->getMock('\OC\Files\View'); + + $node = new \OC_Connector_Sabre_File($view, $info); + $this->assertEquals($expected, $node->getDavPermissions()); + } +} -- 2.39.5