diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 30a8ded2a4..35fe3ac81a 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -908,7 +908,7 @@ class ShareAPIController extends OCSController { // First check if it is an internal share. try { - $share = $this->shareManager->getShareById('ocinternal:' . $id); + $share = $this->shareManager->getShareById('ocinternal:' . $id, $this->currentUser); return $share; } catch (ShareNotFound $e) { // Do nothing, just try the other share type @@ -917,7 +917,7 @@ class ShareAPIController extends OCSController { try { if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_CIRCLE)) { - $share = $this->shareManager->getShareById('ocCircleShare:' . $id); + $share = $this->shareManager->getShareById('ocCircleShare:' . $id, $this->currentUser); return $share; } } catch (ShareNotFound $e) { @@ -926,7 +926,7 @@ class ShareAPIController extends OCSController { try { if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) { - $share = $this->shareManager->getShareById('ocMailShare:' . $id); + $share = $this->shareManager->getShareById('ocMailShare:' . $id, $this->currentUser); return $share; } } catch (ShareNotFound $e) { @@ -936,7 +936,7 @@ class ShareAPIController extends OCSController { if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) { throw new ShareNotFound(); } - $share = $this->shareManager->getShareById('ocFederatedSharing:' . $id); + $share = $this->shareManager->getShareById('ocFederatedSharing:' . $id, $this->currentUser); return $share; } diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index 89a21d7d1e..2c638fe4ed 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -229,7 +229,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager ->expects($this->once()) ->method('getShareById') - ->with('ocinternal:42') + ->with('ocinternal:42', 'currentUser') ->will($this->throwException(new \OC\Share20\Exception\ShareNotFound())); $expected = new \OC\OCS\Result(null, 404, 'wrong share ID, share doesn\'t exist.'); @@ -457,7 +457,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager ->expects($this->once()) ->method('getShareById') - ->with($share->getFullId()) + ->with($share->getFullId(), 'currentUser') ->willReturn($share); $userFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock(); @@ -517,7 +517,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager ->expects($this->once()) ->method('getShareById') - ->with('ocinternal:42') + ->with('ocinternal:42', 'currentUser') ->willReturn($share); $this->ocs->getShare(42); diff --git a/build/integration/features/sharing-v1-part2.feature b/build/integration/features/sharing-v1-part2.feature index 216b173cd1..e90d44d1a6 100644 --- a/build/integration/features/sharing-v1-part2.feature +++ b/build/integration/features/sharing-v1-part2.feature @@ -62,6 +62,59 @@ Feature: sharing | displayname_owner | user0 | | mimetype | text/plain | + Scenario: getting share info of a group share + Given user "user0" exists + And user "user1" exists + And group "group1" exists + And user "user1" belongs to group "group1" + And file "textfile0.txt" of user "user0" is shared with group "group1" + And As an "user0" + When Getting info of last share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And Share fields of last share match with + | id | A_NUMBER | + | item_type | file | + | item_source | A_NUMBER | + | share_type | 1 | + | share_with | group1 | + | file_source | A_NUMBER | + | file_target | /textfile0.txt | + | path | /textfile0.txt | + | permissions | 19 | + | stime | A_NUMBER | + | storage | A_NUMBER | + | mail_send | 0 | + | uid_owner | user0 | + | storage_id | home::user0 | + | file_parent | A_NUMBER | + | share_with_displayname | group1 | + | displayname_owner | user0 | + | mimetype | text/plain | + And As an "user1" + And Getting info of last share + And the OCS status code should be "100" + And the HTTP status code should be "200" + And Share fields of last share match with + | id | A_NUMBER | + | item_type | file | + | item_source | A_NUMBER | + | share_type | 1 | + | share_with | group1 | + | file_source | A_NUMBER | + | file_target | /textfile0 (2).txt | + | path | /textfile0 (2).txt | + | permissions | 19 | + | stime | A_NUMBER | + | storage | A_NUMBER | + | mail_send | 0 | + | uid_owner | user0 | + | storage_id | shared::/textfile0 (2).txt | + | file_parent | A_NUMBER | + | share_with_displayname | group1 | + | displayname_owner | user0 | + | mimetype | text/plain | + Scenario: keep group permissions in sync Given As an "admin" Given user "user0" exists @@ -92,6 +145,26 @@ Feature: sharing | file_parent | A_NUMBER | | displayname_owner | user0 | | mimetype | text/plain | + And As an "user1" + And Getting info of last share + And the OCS status code should be "100" + And the HTTP status code should be "200" + And Share fields of last share match with + | id | A_NUMBER | + | item_type | file | + | item_source | A_NUMBER | + | share_type | 1 | + | file_source | A_NUMBER | + | file_target | /FOLDER/textfile0.txt | + | permissions | 1 | + | stime | A_NUMBER | + | storage | A_NUMBER | + | mail_send | 0 | + | uid_owner | user0 | + | storage_id | shared::/FOLDER/textfile0.txt | + | file_parent | A_NUMBER | + | displayname_owner | user0 | + | mimetype | text/plain | Scenario: Sharee can see the share Given user "user0" exists