From cb2822b8b741a67a1ac33500f7b98bb4f4b7afd2 Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Tue, 23 Aug 2022 10:42:27 +0200 Subject: [PATCH] [tests-only] [full-ci] ApiTest. after each test users delete their personal space (#4433) * after each test users delete their personal space * Simplify deleteAllPersonalSpaces * Simplify deleteAllPersonalSpaces() Co-authored-by: Phil Davis --- ...ected-failures-localAPI-on-OCIS-storage.md | 4 -- .../features/bootstrap/SpacesContext.php | 42 ++++++++++++++----- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index 0170f03fe..a636c8ba4 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -21,7 +21,3 @@ The expected failures in this file are from features in the owncloud/ocis repo. ### [Search by shares jail works incorrect](https://github.com/owncloud/ocis/issues/4014) - [apiSpaces/search.feature:43](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/search.feature#L43) - -### [Changing personal drive quota on another user as admin is not possible](https://github.com/owncloud/ocis/issues/4325) -- [apiSpaces/changeSpaces.feature:221](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/changeSpaces.feature#L221) - diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 43c96caee..590b085a7 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -126,14 +126,8 @@ class SpacesContext implements Context { $this->createdSpaces[$spaceName] = $spaceCreator; } - /** - * @var array - */ - private array $availableSpaces; + private array $availableSpaces = []; - /** - * @var array - */ private array $lastPublicLinkData = []; /** @@ -378,7 +372,7 @@ class SpacesContext implements Context { /** * using method from core to set share data - * + * * @return void */ public function setLastShareData(): void { @@ -428,11 +422,11 @@ class SpacesContext implements Context { public function cleanDataAfterTests(): void { // TODO enable when admin can disable and delete spaces // $this->deleteAllSpacesOfTheType('project'); - // $this->deleteAllSpacesOfTheType('personal'); + $this->deleteAllPersonalSpaces(); } /** - * The method first disables and then deletes spaces + * Admin first disables and then deletes spaces * * @param string $driveType * @@ -463,6 +457,32 @@ class SpacesContext implements Context { } } + /** + * users delete their personal space at the end of the test + * + * @return void + * + * @throws Exception|GuzzleException + */ + public function deleteAllPersonalSpaces(): void { + $query = "\$filter=driveType eq personal"; + $createdUsers= $this->featureContext->getCreatedUsers(); + + foreach($createdUsers as $user) { + $this->theUserListsAllHisAvailableSpacesUsingTheGraphApi( + $user["actualUsername"], + $query + ); + $drives = $this->getAvailableSpaces(); + foreach ($drives as $value) { + if (!\array_key_exists("deleted", $value["root"])) { + $this->sendDisableSpaceRequest($user["actualUsername"], $value["name"]); + } + $this->sendDeleteSpaceRequest($user["actualUsername"], $value["name"]); + } + } + } + /** * Send Graph List My Spaces Request * @@ -3013,7 +3033,7 @@ class SpacesContext implements Context { $space = $this->getSpaceByName($user, $spaceName); $body = $space['id']; } - + $url = "/apps/files_sharing/api/v1/shares?reshares=true&space_ref=" . $body; $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody(