[test-only] remove user/group from space (#8826)

* remove user/grop from space

* fix after review
This commit is contained in:
Viktor Scharf
2024-04-11 09:20:00 +02:00
committed by GitHub
parent 4a597688b9
commit 81bf10b577
2 changed files with 77 additions and 15 deletions

View File

@@ -177,3 +177,41 @@ Feature: Remove access to a drive item
| view |
| edit |
| blocksDownload |
Scenario Outline: user removes user member from project space
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
And user "Alice" has sent the following share invitation:
| space | NewSpace |
| sharee | Brian |
| shareType | user |
| permissionsRole | <permissions-role> |
When user "Alice" removes the share permission of user "Brian" from space "NewSpace" using the Graph API
Then the HTTP status code should be "204"
And the user "Brian" should not have a space called "NewSpace"
Examples:
| permissions-role |
| Space Viewer |
| Space Editor |
| Manager |
@issue-8768
Scenario Outline: user removes group from project space
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
And group "group1" has been created
And user "Brian" has been added to group "group1"
And user "Alice" has sent the following share invitation:
| space | NewSpace |
| sharee | group1 |
| shareType | group |
| permissionsRole | <permissions-role> |
When user "Alice" removes the share permission of group "group1" from space "NewSpace" using the Graph API
Then the HTTP status code should be "204"
And the user "Brian" should not have a space called "NewSpace"
Examples:
| permissions-role |
| Space Viewer |
| Space Editor |
| Manager |

View File

@@ -450,10 +450,10 @@ class SharingNgContext implements Context {
/**
* @param string $sharer
* @param string $shareType (user|group)
* @param string $resource
* @param string $shareType (user|group|link)
* @param string $space
* @param string|null $sharee can be both user or group
* @param string|null $resource
* @param string|null $recipient
*
* @return ResponseInterface
* @throws GuzzleException
@@ -462,12 +462,12 @@ class SharingNgContext implements Context {
public function removeSharePermission(
string $sharer,
string $shareType,
string $resource,
string $space,
?string $sharee = null
?string $resource = null,
?string $recipient = null
): ResponseInterface {
$spaceId = ($this->spacesContext->getSpaceByName($sharer, $space))["id"];
$itemId = $this->spacesContext->getResourceId($sharer, $space, $resource);
$itemId = (isset($resource)) ? $this->spacesContext->getResourceId($sharer, $space, $resource) : $this->spacesContext->getResourceId($sharer, $space, $space);
$permId = ($shareType === 'link')
? $this->featureContext->shareNgGetLastCreatedLinkShareID()
@@ -488,8 +488,8 @@ class SharingNgContext implements Context {
* @When /^user "([^"]*)" removes the share permission of (user|group) "([^"]*)" from (?:file|folder|resource) "([^"]*)" of space "([^"]*)" using the Graph API$/
*
* @param string $sharer
* @param string $shareType (user|group)
* @param string $sharee can be both user or group
* @param string $recipientType (user|group)
* @param string $recipient can be both user or group
* @param string $resource
* @param string $space
*
@@ -499,13 +499,36 @@ class SharingNgContext implements Context {
*/
public function userRemovesSharePermissionOfUserFromResourceOfSpaceUsingGraphAPI(
string $sharer,
string $shareType,
string $sharee,
string $recipientType,
string $recipient,
string $resource,
string $space
): void {
$this->featureContext->setResponse(
$this->removeSharePermission($sharer, $shareType, $resource, $space)
$this->removeSharePermission($sharer, $recipientType, $space, $resource)
);
}
/**
* @When /^user "([^"]*)" removes the share permission of (user|group) "([^"]*)" from space "([^"]*)" using the Graph API$/
*
* @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 \GuzzleHttp\Exception\GuzzleException
*/
public function userRemovesSharePermissionOfUserFromSpaceUsingGraphAPI(
string $sharer,
string $recipientType,
string $recipient,
string $space
): void {
$this->featureContext->setResponse(
$this->removeSharePermission($sharer, $recipientType, $space)
);
}
@@ -526,7 +549,7 @@ class SharingNgContext implements Context {
string $space
):void {
$this->featureContext->setResponse(
$this->removeSharePermission($sharer, 'link', $resource, $space)
$this->removeSharePermission($sharer, 'link', $space, $resource)
);
}
@@ -629,18 +652,19 @@ class SharingNgContext implements Context {
);
$responseBody = $this->featureContext->getJsonDecodedResponse($response);
$expectedValue = $status === "enabled" ? "true" : "false";
$actualValue = "";
foreach ($responseBody["value"] as $value) {
if ($value["remoteItem"]["name"] === $resource) {
// var_export converts values to their string representations
// e.g.: true -> 'true'
$actaulValue = var_export($value["@client.synchronize"], true);
$actualValue = var_export($value["@client.synchronize"], true);
break;
}
}
Assert::assertSame(
$actaulValue,
$actualValue,
$expectedValue,
"Expected property '@client.synchronize' to be '$expectedValue' but found '$actaulValue'"
"Expected property '@client.synchronize' to be '$expectedValue' but found '$actualValue'"
);
}
}