Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions tests/acceptance/features/apiSharingNg/deletePermissions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
54 changes: 39 additions & 15 deletions tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,10 @@ public function userSetsOrUpdatesFollowingPasswordForLastLinkShareUsingTheGraphA

/**
* @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
Expand All @@ -462,12 +462,12 @@ public function userSetsOrUpdatesFollowingPasswordForLastLinkShareUsingTheGraphA
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()
Expand All @@ -488,8 +488,8 @@ public function removeSharePermission(
* @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
*
Expand All @@ -499,13 +499,36 @@ public function removeSharePermission(
*/
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)
);
}

Expand All @@ -526,7 +549,7 @@ public function userRemovesSharePermissionOfAResourceInLinkShareUsingGraphAPI(
string $space
):void {
$this->featureContext->setResponse(
$this->removeSharePermission($sharer, 'link', $resource, $space)
$this->removeSharePermission($sharer, 'link', $space, $resource)
);
}

Expand Down Expand Up @@ -640,18 +663,19 @@ public function userShouldHaveSyncEnabledOrDisabledForShare(string $user, string
);
$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'"
);
}
}