From ed05e5486d640a1f9e6a754f1623ca294f4fc37f Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Thu, 25 Jan 2024 12:35:41 +0545 Subject: [PATCH] Added test for sharingNg for endpoint sharedByMe Signed-off-by: sagargurung1001@gmail.com Added tests for list shared by me Signed-off-by: sagargurung1001@gmail.com adding test for updating permission of a share --- .../features/apiSharingNg/sharedByMe.feature | 71 +++++++++++++++++++ .../features/bootstrap/SharingNgContext.php | 34 +++++++-- 2 files changed, 98 insertions(+), 7 deletions(-) diff --git a/tests/acceptance/features/apiSharingNg/sharedByMe.feature b/tests/acceptance/features/apiSharingNg/sharedByMe.feature index b2e368917ad..ecdd5a34eea 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 69cbec4a7aa..a2ee06837f8 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -231,6 +231,20 @@ public function userSendsTheFollowingShareInvitationUsingTheGraphApi(string $use ); } + /** + * @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->updateShare($user, $table, $permissionID); + } + /** * @When user :user sends the following share invitation with file-id :fileId using the Graph API: * @@ -287,16 +301,22 @@ public function userHasCreatedTheFollowingLinkShare(string $user, TableNode $bo * @throws Exception */ public function userUpdatesLastPublicLinkShareUsingTheGraphApiWith(string $user, TableNode $body):void { + $this->updateShare($user, $body, $this->featureContext->shareNgGetLastCreatedLinkShareID()); + } + + /** + * @param string $user + * @param TableNode $body + * @param string $permissionID + * + * @return void + */ + public function updateShare(string $user, TableNode $body, string $permissionID) { $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 = [ @@ -327,7 +347,7 @@ public function userUpdatesLastPublicLinkShareUsingTheGraphApiWith(string $user, $spaceId, $itemId, \json_encode($body), - $this->featureContext->shareNgGetLastCreatedLinkShareID() + $permissionID ); $this->featureContext->setResponse($response); }