Skip to content

Commit

Permalink
Extend ShareNg test for updating share permission for project space (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
SagarGi authored Apr 30, 2024
1 parent 83dd7d6 commit f962cbb
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 5 deletions.
152 changes: 152 additions & 0 deletions tests/acceptance/features/apiSharingNg/updateShareInvitations.feature
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,155 @@ Feature: Update permission of a share
| Editor | FolderToShare | Uploader |
| Uploader | FolderToShare | Editor |
| Uploader | FolderToShare | Viewer |


Scenario Outline: space admin updates role of a member in project space (permissions endpoint)
Given using spaces DAV path
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "NewSpace" with the default quota using the Graph API
And user "Alice" has sent the following share invitation:
| space | NewSpace |
| sharee | Brian |
| shareType | user |
| permissionsRole | <permissions-role> |
When user "Alice" updates the last share with the following using the Graph API:
| permissionsRole | <new-permissions-role> |
| space | NewSpace |
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"grantedToV2",
"id",
"roles"
],
"properties": {
"grantedToV2": {
"type": "object",
"required": [
"user"
],
"properties":{
"user": {
"type": "object",
"required": [
"displayName",
"id"
],
"properties": {
"displayName": {
"const": "Brian Murphy"
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
}
}
}
}
},
"id": {
"type": "string",
"pattern": "^u:%user_id_pattern%$"
},
"roles": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
}
}
}
}
"""
Examples:
| permissions-role | new-permissions-role |
| Space Viewer | Space Editor |
| Space Viewer | Manager |
| Space Editor | Space Viewer |
| Space Editor | Manager |
| Manager | Space Editor |
| Manager | Space Viewer |


Scenario Outline: user updates role of a shared resource of project space
Given using spaces DAV path
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "NewSpace" with the default quota using the Graph API
And user "Alice" has uploaded a file inside space "NewSpace" with content "share space items" to "textfile1.txt"
And user "Alice" has created a folder "FolderToShare" in space "NewSpace"
And user "Alice" has sent the following share invitation:
| resource | <resource> |
| space | NewSpace |
| sharee | Brian |
| shareType | user |
| permissionsRole | <permissions-role> |
When user "Alice" updates the last share with the following using the Graph API:
| permissionsRole | <new-permissions-role> |
| space | NewSpace |
| resource | <resource> |
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"grantedToV2",
"id",
"roles"
],
"properties": {
"grantedToV2": {
"type": "object",
"required": [
"user"
],
"properties":{
"user": {
"type": "object",
"required": [
"displayName",
"id"
],
"properties": {
"displayName": {
"const": "Brian Murphy"
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
}
}
}
}
},
"id": {
"type": "string",
"pattern": "^%permissions_id_pattern%$"
},
"roles": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
}
}
}
}
"""
Examples:
| permissions-role | new-permissions-role | resource |
| Viewer | File Editor | textfile1.txt |
| File Editor | Viewer | textfile1.txt |
| Viewer | Editor | FolderToShare |
| Viewer | Uploader | FolderToShare |
| Editor | Viewer | FolderToShare |
| Editor | Uploader | FolderToShare |
| Uploader | Viewer | FolderToShare |
| Uploader | Editor | FolderToShare |
18 changes: 13 additions & 5 deletions tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,20 @@ public function userUpdatesTheLastShareWithFollowingUsingGraphApi($user, TableNo
*/
public function updateResourceShare(string $user, TableNode $body, string $permissionID): ResponseInterface {
$bodyRows = $body->getRowsHash();
$space = $bodyRows['space'];
$resource = $bodyRows['resource'];
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
$itemId = $this->spacesContext->getResourceId($user, $space, $resource);
if ($bodyRows['space'] === 'Personal' || $bodyRows['space'] === 'Shares') {
$space = $this->spacesContext->getSpaceByName($user, $bodyRows['space']);
} else {
$space = $this->spacesContext->getCreatedSpace($bodyRows['space']);
}
$spaceId = $space["id"];
// for updating role of project space shared, we do not need to provide resource
$resource = $bodyRows['resource'] ?? '';
if ($resource === '' && !\in_array($bodyRows['space'], ['Personal', 'Shares'])) {
$itemId = $space['fileId'];
} else {
$itemId = $this->spacesContext->getResourceId($user, $bodyRows['space'], $resource);
}
$body = [];

if (\array_key_exists('permissionsRole', $bodyRows)) {
$body['roles'] = [GraphHelper::getPermissionsRoleIdByName($bodyRows['permissionsRole'])];
}
Expand Down

0 comments on commit f962cbb

Please sign in to comment.