Merge pull request #10046 from nextcloud/fix-getting-the-information-of-a-group-share-as-a-sharee

Fix getting the information of a group share as a sharee
This commit is contained in:
Morris Jobke 2018-06-29 13:14:41 +02:00 committed by GitHub
commit a788f49114
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 7 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -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