From c262bbdfa581a31b6385d325065b4d1366095381 Mon Sep 17 00:00:00 2001 From: amrita Date: Fri, 23 May 2025 16:28:58 +0545 Subject: [PATCH] add tests for puring all expired trashe resources --- tests/acceptance/bootstrap/CliContext.php | 13 ++++++ .../features/cliCommands/trashBin.feature | 44 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/tests/acceptance/bootstrap/CliContext.php b/tests/acceptance/bootstrap/CliContext.php index 45d95068162..12d215cbf37 100644 --- a/tests/acceptance/bootstrap/CliContext.php +++ b/tests/acceptance/bootstrap/CliContext.php @@ -894,4 +894,17 @@ public function theAdministratorRestoresTheTrashedResourcesOfSpaceOwnedByUser( ]; $this->featureContext->setResponse(CliHelper::runCommand($body)); } + + /** + * @When the administrator purges the expired trash resources + * + * @return void + * @throws GuzzleException + */ + public function theAdministratorPurgesTheExpiredTrashResources(): void { + $body = [ + "command" => "storage-users trash-bin purge-expired" + ]; + $this->featureContext->setResponse(CliHelper::runCommand($body)); + } } diff --git a/tests/acceptance/features/cliCommands/trashBin.feature b/tests/acceptance/features/cliCommands/trashBin.feature index da877a2758a..42ac43b151f 100644 --- a/tests/acceptance/features/cliCommands/trashBin.feature +++ b/tests/acceptance/features/cliCommands/trashBin.feature @@ -92,3 +92,47 @@ Feature: trashbin | resource | type | | /testfile.txt | file | | /folder-to-delete | folder | + + + Scenario: purge expired trashed resources of Personal space + Given the following configs have been set: + | config | value | + | STORAGE_USERS_PURGE_TRASH_BIN_PERSONAL_DELETE_BEFORE | 1s | + And 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 the following folders + | path | + | folder-to-delete | + And user "Alice" has deleted folder "/folder-to-delete" + And user "Alice" has created a space "Newspace" with the default quota using the Graph API + And user "Alice" has created a folder "uploadFolder" in space "Newspace" + And user "Alice" has uploaded a file inside space "Newspace" with content "hello world" to "text.txt" + And user "Alice" has removed the file "text.txt" from space "Newspace" + And the system waits for "1" seconds + When the administrator purges the expired trash resources + Then there should be no trashed resources of space "Personal" owned by user "Alice" + And there should be "1" trashed resources of space "Newspace" owned by user "Alice": + | resource | type | + | /text.txt | file | + + + Scenario: purge expired trashed resources of project space + Given the following configs have been set: + | config | value | + | STORAGE_USERS_PURGE_TRASH_BIN_PROJECT_DELETE_BEFORE | 1s | + And 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 the following folders + | path | + | folder-to-delete | + And user "Alice" has deleted folder "/folder-to-delete" + And user "Alice" has created a space "Newspace" with the default quota using the Graph API + And user "Alice" has created a folder "uploadFolder" in space "Newspace" + And user "Alice" has uploaded a file inside space "Newspace" with content "hello world" to "text.txt" + And user "Alice" has removed the file "text.txt" from space "Newspace" + And the system waits for "1" seconds + When the administrator purges the expired trash resources + Then there should be no trashed resources of space "Newspace" owned by user "Alice" + And there should be "1" trashed resources of space "Personal" owned by user "Alice": + | resource | type | + | /folder-to-delete | folder |