From 743364403b3e1d3dbbfac066b53eece9110a227c Mon Sep 17 00:00:00 2001 From: Prarup Gurung Date: Wed, 31 Jan 2024 12:26:49 +0545 Subject: [PATCH 1/3] Added test to send share invitation with user for deleted file --- .../apiSharingNg/shareInvitations.feature | 42 +++++++++++++++++++ .../features/bootstrap/SharingNgContext.php | 25 ++++++++++- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/tests/acceptance/features/apiSharingNg/shareInvitations.feature b/tests/acceptance/features/apiSharingNg/shareInvitations.feature index 057f8ffb3..7a769fed2 100644 --- a/tests/acceptance/features/apiSharingNg/shareInvitations.feature +++ b/tests/acceptance/features/apiSharingNg/shareInvitations.feature @@ -1947,3 +1947,45 @@ Feature: Send a sharing invitations | Space Editor | | Co Owner | | Manager | + + + Scenario: send share invitation to user for deleted file + Given user "Alice" has uploaded file with content "to share" to "textfile1.txt" + And we save it into "FILEID" + And user "Alice" has deleted file "textfile1.txt" + When user "Alice" sends the following share invitation with file-id "<>" using the Graph API: + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + Then the HTTP status code should be "404" + And for user "Brian" the space Shares should not contain these entries: + | textfile1.txt | + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "string", + "enum": ["itemNotFound"] + }, + "message": { + "type": "string", + "enum": ["stat: error: not found: "] + } + } + } + } + } + """ diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index d8b261ea3..ba61eb9cc 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -130,6 +130,7 @@ class SharingNgContext implements Context { /** * @param string $user * @param TableNode $table + * @param string|null $fileId * * @return ResponseInterface * @@ -137,7 +138,7 @@ class SharingNgContext implements Context { * @throws \GuzzleHttp\Exception\GuzzleException * @throws Exception */ - public function sendShareInvitation(string $user, TableNode $table): ResponseInterface { + public function sendShareInvitation(string $user, TableNode $table, string $fileId = null): ResponseInterface { $rows = $table->getRowsHash(); if ($rows['space'] === 'Personal' || $rows['space'] === 'Shares') { $space = $this->spacesContext->getSpaceByName($user, $rows['space']); @@ -146,8 +147,11 @@ class SharingNgContext implements Context { } $spaceId = $space['id']; + // $fileId is used for sharing deleted files // for resharing a resource, "item-id" in API endpoint takes shareMountId - if ($rows['space'] === 'Shares') { + if ($fileId) { + $itemId = $fileId; + } elseif ($rows['space'] === 'Shares') { $itemId = GraphHelper::getShareMountId( $this->featureContext->getBaseUrl(), $this->featureContext->getStepLineRef(), @@ -236,6 +240,23 @@ class SharingNgContext implements Context { ); } + /** + * @When user :user sends the following share invitation with file-id :fileId using the Graph API: + * + * @param string $user + * @param string $fileId + * @param TableNode $table + * + * @return void + * @throws JsonException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function userSendsTheFollowingShareInvitationWithFileIdUsingTheGraphApi(string $user, string $fileId, TableNode $table): void { + $this->featureContext->setResponse( + $this->sendShareInvitation($user, $table, $fileId) + ); + } + /** * @When /^user "([^"]*)" creates the following link share using the Graph API:$/ * From e42e0c2d6f0c842d88cfeac0cde8b6e4c565b343 Mon Sep 17 00:00:00 2001 From: Prarup Gurung Date: Wed, 31 Jan 2024 12:27:21 +0545 Subject: [PATCH 2/3] Added test to send share invitation with group for deleted file --- .../apiSharingNg/shareInvitations.feature | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/acceptance/features/apiSharingNg/shareInvitations.feature b/tests/acceptance/features/apiSharingNg/shareInvitations.feature index 7a769fed2..11a237767 100644 --- a/tests/acceptance/features/apiSharingNg/shareInvitations.feature +++ b/tests/acceptance/features/apiSharingNg/shareInvitations.feature @@ -1989,3 +1989,53 @@ Feature: Send a sharing invitations } } """ + + + Scenario: send share invitation to group for deleted file + Given user "Carol" has been created with default attributes and without skeleton files + And group "grp1" has been created + And the following users have been added to the following groups + | username | groupname | + | Brian | grp1 | + | Carol | grp1 | + And user "Alice" has uploaded file with content "to share" to "textfile1.txt" + And we save it into "FILEID" + And user "Alice" has deleted file "textfile1.txt" + When user "Alice" sends the following share invitation with file-id "<>" using the Graph API: + | space | Personal | + | sharee | grp1 | + | shareType | group | + | permissionsRole | Viewer | + Then the HTTP status code should be "404" + And for user "Brian" the space Shares should not contain these entries: + | textfile1.txt | + And for user "Carol" the space Shares should not contain these entries: + | textfile1.txt | + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "string", + "enum": ["itemNotFound"] + }, + "message": { + "type": "string", + "enum": ["stat: error: not found: "] + } + } + } + } + } + """ From ba6b4ad2694bd1d8e89c9db004f2dfb35548e6e4 Mon Sep 17 00:00:00 2001 From: Prarup Gurung Date: Thu, 1 Feb 2024 09:50:54 +0545 Subject: [PATCH 3/3] Addressed reviews --- tests/acceptance/features/bootstrap/SharingNgContext.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index ba61eb9cc..3c8115a35 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -147,7 +147,7 @@ class SharingNgContext implements Context { } $spaceId = $space['id']; - // $fileId is used for sharing deleted files + // $fileId is used for trying to share deleted files // for resharing a resource, "item-id" in API endpoint takes shareMountId if ($fileId) { $itemId = $fileId;