diff --git a/tests/acceptance/features/apiSharingNg/sharedByMe.feature b/tests/acceptance/features/apiSharingNg/sharedByMe.feature index b2e368917..ecdd5a34e 100644 --- a/tests/acceptance/features/apiSharingNg/sharedByMe.feature +++ b/tests/acceptance/features/apiSharingNg/sharedByMe.feature @@ -1463,3 +1463,74 @@ Feature: resources shared by user } } """ + + + Scenario: user updates expiration date of a share + Given user "Alice" has uploaded file with content "hello world" to "testfile.txt" + And user "Alice" has sent the following share invitation: + | resource | testfile.txt | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + When user "Alice" updates the last share with the following using the Graph API: + | space | Personal | + | resource | testfile.txt | + | expirationDateTime | 2200-07-15T14:00:00Z | + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "expirationDateTime", + "grantedToV2", + "id", + "roles" + ], + "properties": { + "expirationDateTime": { + "type": "string", + "enum": ["2200-07-15T14:00:00Z"] + }, + "grantedToV2": { + "type": "object", + "required": [ + "user" + ], + "properties":{ + "user": { + "type": "object", + "required": [ + "displayName", + "id" + ], + "properties": { + "displayName": { + "type": "string", + "enum": ["Brian Murphy"] + }, + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + } + } + } + } + }, + "id": { + "type": "string", + "pattern": "^%permissions_id_pattern%$" + }, + "roles": { + "type": "array", + "items": [ + { + "type": "string", + "pattern": "^%role_id_pattern%$" + } + ] + } + } + } + """ \ No newline at end of file diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index 69cbec4a7..da74b9560 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -231,6 +231,26 @@ class SharingNgContext implements Context { ); } + /** + * @When user :user updates the last share with the following using the Graph API: + * + * @param string $user + * @param TableNode $table + * + * @return void + */ + public function userUpdatesTheLastShareWithFollowingUsingGraphApi($user, TableNode $table) { + $response = $this->featureContext->shareNgGetLastCreatedUserGroupShare(); + $permissionID = json_decode($response->getBody()->getContents())->value[0]->id; + $this->featureContext->setResponse( + $this->updateShare( + $user, + $table, + $permissionID + ) + ); + } + /** * @When user :user sends the following share invitation with file-id :fileId using the Graph API: * @@ -287,16 +307,28 @@ class SharingNgContext implements Context { * @throws Exception */ public function userUpdatesLastPublicLinkShareUsingTheGraphApiWith(string $user, TableNode $body):void { + $this->featureContext->setResponse( + $this->updateShare( + $user, + $body, + $this->featureContext->shareNgGetLastCreatedLinkShareID() + ) + ); + } + + /** + * @param string $user + * @param TableNode $body + * @param string $permissionID + * + * @return ResponseInterface + */ + public function updateShare(string $user, TableNode $body, string $permissionID): ResponseInterface { $bodyRows = $body->getRowsHash(); $space = $bodyRows['space']; - $resourceType = $bodyRows['resourceType']; $resource = $bodyRows['resource']; $spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"]; - if ($resourceType === 'folder') { - $itemId = $this->spacesContext->getResourceId($user, $space, $resource); - } else { - $itemId = $this->spacesContext->getFileId($user, $space, $resource); - } + $itemId = $this->spacesContext->getResourceId($user, $space, $resource); if (\array_key_exists('role', $bodyRows) && \array_key_exists('expirationDateTime', $bodyRows)) { $body = [ @@ -319,7 +351,7 @@ class SharingNgContext implements Context { throw new Error('Expiration date or role is missing to update for share link!'); } - $response = GraphHelper::updateLinkShare( + return GraphHelper::updateLinkShare( $this->featureContext->getBaseUrl(), $this->featureContext->getStepLineRef(), $user, @@ -327,9 +359,8 @@ class SharingNgContext implements Context { $spaceId, $itemId, \json_encode($body), - $this->featureContext->shareNgGetLastCreatedLinkShareID() + $permissionID ); - $this->featureContext->setResponse($response); } /**