user deletes own access of the space (#8986)

This commit is contained in:
Viktor Scharf
2024-04-29 11:59:08 +02:00
committed by GitHub
parent 6aff09530e
commit 836fcc5433
2 changed files with 57 additions and 6 deletions

View File

@@ -128,8 +128,32 @@ Feature: Remove access to a drive
When user "Brian" removes the access of user "Carol" from space "NewSpace" using permissions endpoint of the Graph API
Then the HTTP status code should be "<status-code>"
And the user "Carol" <shouldOrNot> have a space called "NewSpace"
Examples:
Examples:
| permissions-role | status-code | shouldOrNot |
| Space Viewer | 403 | should |
| Space Editor | 403 | should |
| Manager | 204 | should not |
Scenario: user cannot remove himself from the project space if he is the last manager
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "NewSpace" with the default quota using the Graph API
When user "Alice" tries to remove the access of user "Alice" from space "NewSpace" using root endpoint of the Graph API
Then the HTTP status code should be "403"
And the user "Alice" should have a space called "NewSpace"
Scenario: user of a group cannot remove own group from project space if it is the last manager
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And group "group1" has been created
And user "Brian" has been added to group "group1"
And user "Alice" has created a space "NewSpace" with the default quota using the Graph API
And user "Alice" has sent the following share invitation:
| space | NewSpace |
| sharee | group1 |
| shareType | group |
| permissionsRole | Manager |
And user "Alice" has removed the access of user "Alice" from space "NewSpace"
When user "Brian" tries to remove the access of group "group1" from space "NewSpace" using root endpoint of the Graph API
Then the HTTP status code should be "403"
And the user "Brian" should have a space called "NewSpace"

View File

@@ -537,9 +537,13 @@ class SharingNgContext implements Context {
): ResponseInterface {
$spaceId = ($this->spacesContext->getSpaceByName($sharer, $space))["id"];
$permId = ($shareType === 'link')
? $this->featureContext->shareNgGetLastCreatedLinkShareID()
: $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
$permId = match ($shareType) {
'link' => $this->featureContext->shareNgGetLastCreatedLinkShareID(),
'user' => 'u:' . $this->featureContext->getAttributeOfCreatedUser($recipient, 'id'),
'group' => 'g:' . $this->featureContext->getAttributeOfCreatedGroup($recipient, 'id'),
default => throw new Exception("shareType '$shareType' does not match user|group|link "),
};
return
GraphHelper::removeAccessToSpace(
$this->featureContext->getBaseUrl(),
@@ -595,7 +599,7 @@ class SharingNgContext implements Context {
string $space
): void {
$this->featureContext->setResponse(
$this->removeAccessToSpaceItem($sharer, $recipientType, $space)
$this->removeAccessToSpaceItem($sharer, $recipientType, $space, null, $recipient)
);
}
@@ -622,6 +626,7 @@ class SharingNgContext implements Context {
/**
* @When /^user "([^"]*)" removes the access of (user|group) "([^"]*)" from space "([^"]*)" using root endpoint of the Graph API$/
* @When /^user "([^"]*)" tries to remove the access of (user|group) "([^"]*)" from space "([^"]*)" using root endpoint of the Graph API$/
*
* @param string $sharer
* @param string $recipientType (user|group)
@@ -639,7 +644,7 @@ class SharingNgContext implements Context {
string $space
): void {
$this->featureContext->setResponse(
$this->removeAccessToSpace($sharer, $recipientType, $space)
$this->removeAccessToSpace($sharer, $recipientType, $space, $recipient)
);
}
@@ -662,6 +667,28 @@ class SharingNgContext implements Context {
);
}
/**
* @Given /^user "([^"]*)" has removed the access of (user|group) "([^"]*)" from space "([^"]*)"$/
*
* @param string $sharer
* @param string $recipientType (user|group)
* @param string $recipient can be both user or group
* @param string $space
*
* @return void
* @throws JsonException
* @throws GuzzleException
*/
public function userHasRemovedAccessOfUserOrGroupFromSpace(
string $sharer,
string $recipientType,
string $recipient,
string $space
): void {
$response = $this->removeAccessToSpace($sharer, $recipientType, $space, $recipient);
$this->featureContext->theHTTPStatusCodeShouldBe(204, "", $response);
}
/**
* @Then /^for user "([^"]*)" the space Shares should (not|)\s?contain these (files|entries):$/
*