diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2017-09-04 12:43:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-04 12:43:02 +0200 |
commit | 2060ff591bc0ab2a5600d40acc4020849075b2c9 (patch) | |
tree | 0eaf450963c62bf5422a2cb9f147ebc5c4ff5220 /apps | |
parent | f0158e42e9f1a867e55d79fedb751fbeca10548d (diff) | |
parent | 6e7865d05b04bf232d49cfdc28d62c29f5d926e0 (diff) | |
download | nextcloud-server-2060ff591bc0ab2a5600d40acc4020849075b2c9.tar.gz nextcloud-server-2060ff591bc0ab2a5600d40acc4020849075b2c9.zip |
Merge pull request #6120 from nextcloud/public_upload_share_api_fix
Public upload share permission handling
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareAPIController.php | 1 | ||||
-rw-r--r-- | apps/files_sharing/tests/Controller/ShareAPIControllerTest.php | 24 |
2 files changed, 18 insertions, 7 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 592deba1cf6..a2e7cbf727a 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -700,6 +700,7 @@ class ShareAPIController extends OCSController { if ($permissions !== null) { $newPermissions = (int)$permissions; + $newPermissions = $newPermissions & ~\OCP\Constants::PERMISSION_SHARE; } if ($newPermissions !== null && diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index f5df9b62b19..fc6e4572845 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -1541,11 +1541,7 @@ class ShareAPIControllerTest extends TestCase { $this->assertEquals($expected->getData(), $result->getData()); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSBadRequestException - * @expectedExceptionMessage Can't change permissions for public share links - */ - public function testUpdateLinkShareInvalidPermissions() { + public function testUpdateLinkSharePermissionsShare() { $ocs = $this->mockFormatShare(); $date = new \DateTime('2000-01-01'); @@ -1558,13 +1554,27 @@ class ShareAPIControllerTest extends TestCase { ->setShareType(\OCP\Share::SHARE_TYPE_LINK) ->setPassword('password') ->setExpirationDate($date) - ->setPermissions(\OCP\Constants::PERMISSION_ALL) + ->setPermissions(\OCP\Constants::PERMISSION_READ) ->setNode($folder); $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true); - $ocs->updateShare(42, 31); + $this->shareManager->expects($this->once())->method('updateShare')->with( + $this->callback(function (\OCP\Share\IShare $share) use ($date) { + return $share->getPermissions() === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) && + $share->getPassword() === 'password' && + $share->getExpirationDate() === $date; + }) + )->will($this->returnArgument(0)); + + $this->shareManager->method('getSharedWith')->willReturn([]); + + $expected = new DataResponse(null); + $result = $ocs->updateShare(42, 31, null, null, null); + + $this->assertInstanceOf(get_class($expected), $result); + $this->assertEquals($expected->getData(), $result->getData()); } public function testUpdateOtherPermissions() { |