Skip to content

Commit

Permalink
user deletes own access of the space
Browse files Browse the repository at this point in the history
  • Loading branch information
ScharfViktor committed Apr 29, 2024
1 parent f7fb0bc commit 9ec53bd
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
37 changes: 32 additions & 5 deletions tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,13 @@ public function removeAccessToSpace(
): 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(),
Expand Down Expand Up @@ -593,7 +597,7 @@ public function userRemovesAccessOfUserOrGroupFromSpaceUsingPermissionsEndpointO
string $space
): void {
$this->featureContext->setResponse(
$this->removeAccessToSpaceItem($sharer, $recipientType, $space)
$this->removeAccessToSpaceItem($sharer, $recipientType, $space, null, $recipient)
);
}

Expand All @@ -620,6 +624,7 @@ public function userRemovesSharePermissionOfAResourceInLinkShareUsingGraphAPI(

/**
* @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)
Expand All @@ -637,7 +642,7 @@ public function userRemovesAccessOfUserOrGroupFromSpaceUsingGraphAPI(
string $space
): void {
$this->featureContext->setResponse(
$this->removeAccessToSpace($sharer, $recipientType, $space)
$this->removeAccessToSpace($sharer, $recipientType, $space, $recipient)
);
}

Expand All @@ -660,6 +665,28 @@ public function userRemovesLinkFromSpaceUsingRootEndpointOfGraphAPI(
);
}

/**
* @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):$/
*
Expand Down

0 comments on commit 9ec53bd

Please sign in to comment.