summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-04-01 17:02:59 +0200
committerRoeland Jago Douma <rullzer@owncloud.com>2016-04-08 14:17:05 +0200
commitbd3bde2f3bccb8550f1dbe3c8b254052e8b38865 (patch)
treef447d2e8aeda717e389a1e9f9c92ce82d4da01f5 /tests
parent6eefea1bb65897b0a1cf8668b15998a12ae197b9 (diff)
downloadnextcloud-server-bd3bde2f3bccb8550f1dbe3c8b254052e8b38865.tar.gz
nextcloud-server-bd3bde2f3bccb8550f1dbe3c8b254052e8b38865.zip
Set proper permissions on link share
If we do not allow public upload we should limit the permissions on links shares upon retrieval. * Added unit test * Allow fetching federated shares by token as well
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/share20/managertest.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/lib/share20/managertest.php b/tests/lib/share20/managertest.php
index 029c8cd8543..d8eb3e0a31e 100644
--- a/tests/lib/share20/managertest.php
+++ b/tests/lib/share20/managertest.php
@@ -2084,6 +2084,25 @@ class ManagerTest extends \Test\TestCase {
$this->assertSame($share, $res);
}
+ public function testGetShareByTokenPublicSharingDisabled() {
+ $share = $this->manager->newShare();
+ $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE);
+
+ $this->config->method('getAppValue')->will($this->returnValueMap([
+ ['core', 'shareapi_allow_public_upload', 'yes', 'no'],
+ ]));
+
+ $this->defaultProvider->expects($this->once())
+ ->method('getShareByToken')
+ ->willReturn('validToken')
+ ->willReturn($share);
+
+ $res = $this->manager->getShareByToken('validToken');
+
+ $this->assertSame(\OCP\Constants::PERMISSION_READ, $res->getPermissions());
+ }
+
public function testCheckPasswordNoLinkShare() {
$share = $this->getMock('\OCP\Share\IShare');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);