diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-03-31 21:25:23 +0200 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-03-31 21:25:23 +0200 |
commit | 89478a0961c70f2b8f55b6ded9103b2cac4223a1 (patch) | |
tree | fcff9274cb5d974b9c67ba74bf9253e450432008 /apps | |
parent | 5334bcce6683efc2297b742517c98716dd9d3e43 (diff) | |
download | nextcloud-server-89478a0961c70f2b8f55b6ded9103b2cac4223a1.tar.gz nextcloud-server-89478a0961c70f2b8f55b6ded9103b2cac4223a1.zip |
Fix unit tests
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/connector/sabre/node.php | 10 | ||||
-rw-r--r-- | apps/dav/tests/unit/connector/sabre/node.php | 7 |
2 files changed, 14 insertions, 3 deletions
diff --git a/apps/dav/lib/connector/sabre/node.php b/apps/dav/lib/connector/sabre/node.php index 4828cb611ed..9867fe66cd3 100644 --- a/apps/dav/lib/connector/sabre/node.php +++ b/apps/dav/lib/connector/sabre/node.php @@ -30,6 +30,7 @@ namespace OCA\DAV\Connector\Sabre; +use OC\Files\Mount\MoveableMount; use OCA\DAV\Connector\Sabre\Exception\InvalidPath; @@ -234,7 +235,14 @@ abstract class Node implements \Sabre\DAV\INode { */ $mountpoint = $this->info->getMountPoint(); if (!($mountpoint instanceof MoveableMount)) { - $permissions |= \OCP\Constants::PERMISSION_DELETE | \OCP\Constants::PERMISSION_UPDATE; + $mountpointpath = $mountpoint->getMountPoint(); + if (substr($mountpointpath, -1) === '/') { + $mountpointpath = substr($mountpointpath, 0, -1); + } + + if ($mountpointpath === $this->info->getPath()) { + $permissions |= \OCP\Constants::PERMISSION_DELETE | \OCP\Constants::PERMISSION_UPDATE; + } } /* diff --git a/apps/dav/tests/unit/connector/sabre/node.php b/apps/dav/tests/unit/connector/sabre/node.php index c9fe6e60273..cde8e746dc3 100644 --- a/apps/dav/tests/unit/connector/sabre/node.php +++ b/apps/dav/tests/unit/connector/sabre/node.php @@ -108,16 +108,19 @@ class Node extends \Test\TestCase { */ public function testSharePermissions($type, $permissions, $expected) { $storage = $this->getMock('\OCP\Files\Storage'); - $storage->method('getPermissions')->willReturn($permissions); + $mountpoint = $this->getMock('\OCP\Files\Mount\IMountPoint'); + $mountpoint->method('getMountPoint')->willReturn('myPath'); + $info = $this->getMockBuilder('\OC\Files\FileInfo') ->disableOriginalConstructor() - ->setMethods(array('getStorage', 'getType')) + ->setMethods(['getStorage', 'getType', 'getMountPoint']) ->getMock(); $info->method('getStorage')->willReturn($storage); $info->method('getType')->willReturn($type); + $info->method('getMountPoint')->willReturn($mountpoint); $view = $this->getMock('\OC\Files\View'); |