Skip to content

Commit 7a8ec7d

Browse files
committed
test: add test to delete personal space
1 parent 8764028 commit 7a8ec7d

File tree

3 files changed

+153
-0
lines changed

3 files changed

+153
-0
lines changed

tests/acceptance/bootstrap/CliContext.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,4 +1048,65 @@ public function theAdministratorRestartsTheExpiredUploadSessionsUsingTheCLI(): v
10481048
];
10491049
$this->featureContext->setResponse(CliHelper::runCommand($body));
10501050
}
1051+
1052+
/**
1053+
* @When administrator deletes :space space using the CLI
1054+
*
1055+
* @param string $space
1056+
*
1057+
* @return void
1058+
* @throws GuzzleException
1059+
*/
1060+
public function theAdministratorDeletesSpaceUsingTheCLI(string $space): void {
1061+
$command = "storage-users spaces purge -t=" . strtolower($space) . " -r=0s -v -d=false";
1062+
$body = [
1063+
"command" => $command,
1064+
];
1065+
$this->featureContext->setResponse(CliHelper::runCommand($body));
1066+
}
1067+
1068+
/**
1069+
* @When administrator deletes :space space of user :user with space-id using the CLI
1070+
*
1071+
* @param string $spaceName
1072+
* @param string $user
1073+
*
1074+
* @return void
1075+
* @throws GuzzleException
1076+
*/
1077+
public function administratorDeletesSpaceWithSpaceIdUsingTheCli(string $spaceName, string $user): void {
1078+
$space = $this->featureContext->spacesContext->getSpaceByName($user, $spaceName);
1079+
1080+
if ($spaceName === "Personal") {
1081+
$spaceType = "personal";
1082+
} else {
1083+
$spaceType = 'project';
1084+
}
1085+
1086+
$command = "storage-users spaces purge -t=$spaceType -s=" . $space['id'] . " -r=0s -v -d=false";
1087+
$body = [
1088+
"command" => $command,
1089+
];
1090+
$this->featureContext->setResponse(CliHelper::runCommand($body));
1091+
}
1092+
1093+
/**
1094+
* @When administrator deletes :space space with :retentionPeriod retention period using the CLI
1095+
*
1096+
* @param string $space
1097+
* @param string $retentionPeriod
1098+
*
1099+
* @return void
1100+
* @throws GuzzleException
1101+
*/
1102+
public function administratorDeletesSpaceWithRetentionPeriodOfUsingTheCli(
1103+
string $space,
1104+
string $retentionPeriod,
1105+
): void {
1106+
$command = "storage-users spaces purge -t=" . strtolower($space) . " -r=$retentionPeriod -v -d=false";
1107+
$body = [
1108+
"command" => $command,
1109+
];
1110+
$this->featureContext->setResponse(CliHelper::runCommand($body));
1111+
}
10511112
}

tests/acceptance/bootstrap/SpacesContext.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3098,6 +3098,34 @@ public function sendUserHasDisabledSpaceRequest(
30983098
);
30993099
}
31003100

3101+
/**
3102+
* @Given /^user "([^"]*)" has disabled personal space of user "([^"]*)"$/
3103+
*
3104+
* @param string $user
3105+
* @param string $spaceOwnerName
3106+
*
3107+
* @return void
3108+
* @throws GuzzleException
3109+
*/
3110+
public function userHasDisabledPersonalSpaceOfUser(
3111+
string $user,
3112+
string $spaceOwnerName,
3113+
): void {
3114+
$space = $this->getSpaceByName($spaceOwnerName, "Personal");
3115+
$response = GraphHelper::disableSpace(
3116+
$this->featureContext->getBaseUrl(),
3117+
$user,
3118+
$this->featureContext->getPasswordForUser($user),
3119+
$space["id"],
3120+
);
3121+
$expectedHTTPStatus = "204";
3122+
$this->featureContext->theHTTPStatusCodeShouldBe(
3123+
$expectedHTTPStatus,
3124+
"Expected response status code should be $expectedHTTPStatus",
3125+
$response,
3126+
);
3127+
}
3128+
31013129
/**
31023130
* @param string $user
31033131
* @param string $spaceName
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
@env-config
2+
Feature: delete space using cli
3+
As an administrator
4+
I want to delete spaces of users using cli
5+
So that I can manage them
6+
7+
Background:
8+
Given user "Alice" has been created with default attributes
9+
10+
11+
Scenario: administrator deletes personal space of users
12+
Given user "Admin" has disabled personal space of user "Alice"
13+
When administrator deletes "Personal" space using the CLI
14+
Then the command should be successful
15+
And the command output should contain "Purge completed. Purged 1 spaces"
16+
17+
18+
Scenario: administrator deletes project spaces of users
19+
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
20+
And user "Alice" has created a space "project1" with the default quota using the Graph API
21+
And user "Alice" has created a space "project2" with the default quota using the Graph API
22+
And user "Alice" has disabled a space "project1"
23+
And user "Alice" has disabled a space "project2"
24+
When administrator deletes "Project" space using the CLI
25+
Then the command should be successful
26+
And the command output should contain "Purge completed. Purged 2 spaces"
27+
28+
29+
Scenario: administrator deletes personal space of users using space-id (Personal)
30+
Given user "Admin" has disabled personal space of user "Alice"
31+
When administrator deletes "Personal" space of user "Alice" with space-id using the CLI
32+
Then the command should be successful
33+
And the command output should contain "Purge completed. Purged 1 spaces"
34+
35+
36+
Scenario: administrator deletes project space of users using space-id (Project)
37+
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
38+
And user "Alice" has created a space "project" with the default quota using the Graph API
39+
And user "Alice" has disabled a space "project"
40+
When administrator deletes "project" space of user "Alice" with space-id using the CLI
41+
Then the command should be successful
42+
And the command output should contain "Purge completed. Purged 1 spaces"
43+
44+
45+
Scenario: administrator deletes spaces beyond the retention-period
46+
Given using spaces DAV path
47+
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
48+
And user "Alice" has created a space "project" with the default quota using the Graph API
49+
And user "Alice" has disabled a space "project"
50+
And the administrator has waited for "5s" seconds
51+
And user "Alice" has created a space "project1" with the default quota using the Graph API
52+
And user "Alice" has disabled a space "project1"
53+
When administrator deletes "Project" space with "2s" retention period using the CLI
54+
Then the command should be successful
55+
And the command output should contain "Purge completed. Purged 1 spaces"
56+
57+
58+
Scenario: administrator tries to delete enabled spaces
59+
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
60+
And user "Alice" has created a space "project" with the default quota using the Graph API
61+
When administrator deletes "project" space of user "Alice" with space-id using the CLI
62+
Then the command should be successful
63+
And the command output should contain "Purge completed. Purged 0 spaces"
64+

0 commit comments

Comments
 (0)