From c3d895445e9bbd54935f56241070aeb4424899a4 Mon Sep 17 00:00:00 2001 From: Sagar Gurung <46086950+SagarGi@users.noreply.github.com> Date: Fri, 16 Feb 2024 15:16:29 +0545 Subject: [PATCH] [tests-only][full-ci]Added tests to lists shared by me after sharee is deleted (#8450) * Added tests to lists shared by me after sharee is deleted Signed-off-by: sagargurung1001@gmail.com * Refactor tests * Review address Signed-off-by: sagargurung1001@gmail.com * Review address Signed-off-by: sagargurung1001@gmail.com --------- Signed-off-by: sagargurung1001@gmail.com --- .../features/apiSharingNg/sharedByMe.feature | 63 +++++++++++++++++++ .../features/bootstrap/GraphContext.php | 46 +++++++++++--- 2 files changed, 100 insertions(+), 9 deletions(-) diff --git a/tests/acceptance/features/apiSharingNg/sharedByMe.feature b/tests/acceptance/features/apiSharingNg/sharedByMe.feature index 1f30c008f6..2732534719 100644 --- a/tests/acceptance/features/apiSharingNg/sharedByMe.feature +++ b/tests/acceptance/features/apiSharingNg/sharedByMe.feature @@ -1451,3 +1451,66 @@ Feature: resources shared by user } } """ + + @env-config + Scenario: user lists shared resources for deleted sharee + Given the config "GRAPH_SPACES_USERS_CACHE_TTL" has been set to "1" + And the administrator has assigned the role "Admin" to user "Alice" using the Graph API + And user "Alice" has uploaded file with content "hello world" to "textfile.txt" + And user "Alice" has sent the following share invitation: + | resource | textfile.txt | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + And the administrator has deleted user "Brian" using the provisioning API + When user "Alice" lists the shares shared by her after clearing user cache using the Graph API + 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", + "minItems":0, + "maxItems":0 + } + } + } + """ + + @env-config + Scenario: user lists shared resources for deleted group + Given the config "GRAPH_SPACES_GROUPS_CACHE_TTL" has been set to "1" + And group "grp1" has been created + And the administrator has assigned the role "Admin" to user "Alice" using the Graph API + And user "Alice" has uploaded file with content "hello world" to "textfile.txt" + And user "Alice" has sent the following share invitation: + | resource | textfile.txt | + | space | Personal | + | sharee | grp1 | + | shareType | group | + | permissionsRole | Viewer | + And group "grp1" has been deleted + When user "Alice" lists the shares shared by her after clearing group cache using the Graph API + 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", + "minItems":0, + "maxItems":0 + } + } + } + """ diff --git a/tests/acceptance/features/bootstrap/GraphContext.php b/tests/acceptance/features/bootstrap/GraphContext.php index b73ebbb6a2..8b8216541b 100644 --- a/tests/acceptance/features/bootstrap/GraphContext.php +++ b/tests/acceptance/features/bootstrap/GraphContext.php @@ -2526,6 +2526,30 @@ class GraphContext implements Context { ); } + /** + * + * @param string $user + * @param bool $waitForCacheExpiry + * + * @return void + */ + public function listSharesSharedByMe(string $user, bool $waitForCacheExpiry = false) { + $credentials = $this->getAdminOrUserCredentials($user); + if ($waitForCacheExpiry) { + // ENV (GRAPH_SPACES_GROUPS_CACHE_TTL | GRAPH_SPACES_USERS_CACHE_TTL) is set default to 60 sec + // which means 60 sec is required to clean up all the user|group cache once they are deleted + // for tests we have set the above ENV's to minimum which is 1 sec as we check the details for the deleted users + sleep(1); + } + $response = GraphHelper::getSharesSharedByMe( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $credentials['username'], + $credentials['password'] + ); + $this->featureContext->setResponse($response); + } + /** * @When user :user lists the shares shared by him/her using the Graph API * @@ -2535,15 +2559,19 @@ class GraphContext implements Context { * @throws GuzzleException */ public function userListsTheResourcesSharedByAUserUsingGraphApi(string $user): void { - $credentials = $this->getAdminOrUserCredentials($user); - $this->featureContext->setResponse( - GraphHelper::getSharesSharedByMe( - $this->featureContext->getBaseUrl(), - $this->featureContext->getStepLineRef(), - $credentials['username'], - $credentials['password'] - ) - ); + $this->listSharesSharedByMe($user); + } + + /** + * @When user :user lists the shares shared by him/her after clearing user/group cache using the Graph API + * + * @param string $user + * + * @return void + * @throws GuzzleException + */ + public function userListsTheResourcesSharedByAUserAfterClearingUserOrGroupSpaceUsingGraphApi(string $user): void { + $this->listSharesSharedByMe($user, true); } /**