diff --git a/tests/acceptance/features/apiSharingNg/reshare.feature b/tests/acceptance/features/apiSharingNg/reshare.feature new file mode 100644 index 000000000..cdc91fc6e --- /dev/null +++ b/tests/acceptance/features/apiSharingNg/reshare.feature @@ -0,0 +1,397 @@ +Feature: Reshare a share invitation + As a user + I want to be able to reshare the share invitations to other users + So that they can have access to it + + https://owncloud.dev/libre-graph-api/#/drives.permissions/Invite + + Background: + Given these users have been created with default attributes and without skeleton files: + | username | + | Alice | + | Brian | + | Carol | + + + Scenario Outline: reshare a file to a user with different roles + Given user "Alice" has uploaded file with content "to share" to "/textfile1.txt" + And user "Alice" has sent the following share invitation: + | resourceType | file | + | resource | textfile1.txt | + | space | Personal | + | sharee | Brian | + | shareType | user | + | role | | + When user "Brian" sends the following share invitation using the Graph API: + | resourceType | file | + | resource | textfile1.txt | + | space | Shares | + | sharee | Carol | + | shareType | user | + | role | | + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "roles", + "grantedToV2" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%share_id_pattern%$" + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "pattern": "^%role_id_pattern%$" + } + }, + "grantedToV2": { + "type": "object", + "required": [ + "user" + ], + "properties": { + "user": { + "type": "object", + "required": [ + "id", + "displayName" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "displayName": { + "type": "string", + "enum": [ + "Carol King" + ] + } + } + } + } + } + } + } + } + } + } + """ + Examples: + | role | reshare-role | + | Viewer | Viewer | + | File Editor | Viewer | + | File Editor | File Editor | + | Co Owner | Viewer | + | Co Owner | File Editor | + | Co Owner | Co Owner | + | Manager | Viewer | + | Manager | File Editor | + | Manager | Co Owner | + | Manager | Manager | + + + Scenario Outline: reshare a folder to a user with different roles + Given user "Alice" has created folder "FolderToShare" + And user "Alice" has sent the following share invitation: + | resourceType | folder | + | resource | FolderToShare | + | space | Personal | + | sharee | Brian | + | shareType | user | + | role | | + When user "Brian" sends the following share invitation using the Graph API: + | resourceType | folder | + | resource | FolderToShare | + | space | Shares | + | sharee | Carol | + | shareType | user | + | role | | + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "roles", + "grantedToV2" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%share_id_pattern%$" + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "pattern": "^%role_id_pattern%$" + } + }, + "grantedToV2": { + "type": "object", + "required": [ + "user" + ], + "properties": { + "user": { + "type": "object", + "required": [ + "id", + "displayName" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "displayName": { + "type": "string", + "enum": [ + "Carol King" + ] + } + } + } + } + } + } + } + } + } + } + """ + Examples: + | role | reshare-role | + | Viewer | Viewer | + | Editor | Viewer | + | Editor | Editor | + | Editor | Uploader | + | Co Owner | Viewer | + | Co Owner | Editor | + | Co Owner | Co Owner | + | Co Owner | Uploader | + | Manager | Viewer | + | Manager | Editor | + | Manager | Co Owner | + | Manager | Uploader | + | Manager | Manager | + + + Scenario Outline: reshare a file inside project space to a user with different roles + 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 "to share" to "textfile1.txt" + And user "Alice" has sent the following share invitation: + | resourceType | file | + | resource | textfile1.txt | + | space | NewSpace | + | sharee | Brian | + | shareType | user | + | role | | + When user "Brian" sends the following share invitation using the Graph API: + | resourceType | file | + | resource | textfile1.txt | + | space | Shares | + | sharee | Carol | + | shareType | user | + | role | | + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "roles", + "grantedToV2" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%share_id_pattern%$" + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "pattern": "^%role_id_pattern%$" + } + }, + "grantedToV2": { + "type": "object", + "required": [ + "user" + ], + "properties": { + "user": { + "type": "object", + "required": [ + "id", + "displayName" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "displayName": { + "type": "string", + "enum": [ + "Carol King" + ] + } + } + } + } + } + } + } + } + } + } + """ + Examples: + | role | reshare-role | + | Viewer | Viewer | + | File Editor | Viewer | + | File Editor | File Editor | + | Co Owner | Viewer | + | Co Owner | File Editor | + | Co Owner | Co Owner | + | Manager | Viewer | + | Manager | File Editor | + | Manager | Co Owner | + | Manager | Manager | + + + Scenario Outline: reshare a folder inside project space to a user with different roles + 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 created a folder "FolderToShare" in space "NewSpace" + And user "Alice" has sent the following share invitation: + | resourceType | folder | + | resource | FolderToShare | + | space | NewSpace | + | sharee | Brian | + | shareType | user | + | role | | + When user "Brian" sends the following share invitation using the Graph API: + | resourceType | folder | + | resource | FolderToShare | + | space | Shares | + | sharee | Carol | + | shareType | user | + | role | | + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "roles", + "grantedToV2" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%share_id_pattern%$" + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "pattern": "^%role_id_pattern%$" + } + }, + "grantedToV2": { + "type": "object", + "required": [ + "user" + ], + "properties": { + "user": { + "type": "object", + "required": [ + "id", + "displayName" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + }, + "displayName": { + "type": "string", + "enum": [ + "Carol King" + ] + } + } + } + } + } + } + } + } + } + } + """ + Examples: + | role | reshare-role | + | Viewer | Viewer | + | Editor | Viewer | + | Editor | Editor | + | Editor | Uploader | + | Co Owner | Viewer | + | Co Owner | Editor | + | Co Owner | Co Owner | + | Co Owner | Uploader | + | Manager | Viewer | + | Manager | Editor | + | Manager | Co Owner | + | Manager | Uploader | + | Manager | Manager | diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index eb016d95b..61e522ecf 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -139,9 +139,20 @@ class SharingNgContext implements Context { $rows = $table->getRowsHash(); $spaceId = ($this->spacesContext->getSpaceByName($user, $rows['space']))["id"]; - $itemId = ($rows['resourceType'] === 'folder') - ? $this->spacesContext->getResourceId($user, $rows['space'], $rows['resource']) - : $this->spacesContext->getFileId($user, $rows['space'], $rows['resource']); + // for resharing a resource, "item-id" in API endpoint takes shareMountId + if ($rows['space'] === 'Shares') { + $itemId = GraphHelper::getShareMountId( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user), + $rows['resource'] + ); + } else { + $itemId = ($rows['resourceType'] === 'folder') + ? $this->spacesContext->getResourceId($user, $rows['space'], $rows['resource']) + : $this->spacesContext->getFileId($user, $rows['space'], $rows['resource']); + } $sharees = array_map('trim', explode(',', $rows['sharee'])); $shareTypes = array_map('trim', explode(',', $rows['shareType']));