[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 <phil@jankaritech.com>
This commit is contained in:
Viktor Scharf
2022-08-23 10:42:27 +02:00
committed by GitHub
co-authored by Phil Davis
parent 9506bfc8db
commit cb2822b8b7
2 changed files with 31 additions and 15 deletions
@@ -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) ### [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) - [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)
@@ -126,14 +126,8 @@ class SpacesContext implements Context {
$this->createdSpaces[$spaceName] = $spaceCreator; $this->createdSpaces[$spaceName] = $spaceCreator;
} }
/** private array $availableSpaces = [];
* @var array
*/
private array $availableSpaces;
/**
* @var array
*/
private array $lastPublicLinkData = []; private array $lastPublicLinkData = [];
/** /**
@@ -428,11 +422,11 @@ class SpacesContext implements Context {
public function cleanDataAfterTests(): void { public function cleanDataAfterTests(): void {
// TODO enable when admin can disable and delete spaces // TODO enable when admin can disable and delete spaces
// $this->deleteAllSpacesOfTheType('project'); // $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 * @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 * Send Graph List My Spaces Request
* *