[tests-only]tests: add tests for removing share permission in group share (#8099)
* tests: add tests for removing share permission in group share * tests: address reviews
This commit is contained in:
@@ -1543,11 +1543,12 @@ class GraphHelper {
|
|||||||
/**
|
/**
|
||||||
* @param string $baseUrl
|
* @param string $baseUrl
|
||||||
* @param string $xRequestId
|
* @param string $xRequestId
|
||||||
* @param string $user
|
* @param string $sharer
|
||||||
* @param string $userIdOfShareeUser
|
* @param string $userIdOfShareeUser this is a uuidv4 of sharee
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* @param string $spaceId
|
* @param string $spaceId
|
||||||
* @param string $itemId
|
* @param string $itemId
|
||||||
|
* @param string $shareType (user|group)
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
@@ -1557,22 +1558,23 @@ class GraphHelper {
|
|||||||
public static function getSharePermissionId(
|
public static function getSharePermissionId(
|
||||||
string $baseUrl,
|
string $baseUrl,
|
||||||
string $xRequestId,
|
string $xRequestId,
|
||||||
string $user,
|
string $sharer,
|
||||||
string $userIdOfShareeUser,
|
string $userIdOfShareeUser,
|
||||||
string $password,
|
string $password,
|
||||||
string $spaceId,
|
string $spaceId,
|
||||||
string $itemId
|
string $itemId,
|
||||||
|
string $shareType
|
||||||
): string {
|
): string {
|
||||||
$response = self::getPermissionsList($baseUrl, $xRequestId, $user, $password, $spaceId, $itemId);
|
$response = self::getPermissionsList($baseUrl, $xRequestId, $sharer, $password, $spaceId, $itemId);
|
||||||
$permissionList = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
|
$permissionList = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
|
||||||
foreach ($permissionList["value"] as $value) {
|
foreach ($permissionList["value"] as $value) {
|
||||||
if ($value["grantedToV2"]["user"]["id"] === $userIdOfShareeUser) {
|
if ($value["grantedToV2"][$shareType]["id"] === $userIdOfShareeUser) {
|
||||||
return $value["id"];
|
return $value["id"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new \Exception(
|
throw new \Exception(
|
||||||
__METHOD__
|
__METHOD__
|
||||||
. " Cannot find share permission id for user '$user'"
|
. " Cannot find share permission id for user"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1751,7 +1753,7 @@ class GraphHelper {
|
|||||||
*
|
*
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
*/
|
*/
|
||||||
public static function deleteSharePermission(
|
public static function removeSharePermission(
|
||||||
string $baseUrl,
|
string $baseUrl,
|
||||||
string $xRequestId,
|
string $xRequestId,
|
||||||
string $user,
|
string $user,
|
||||||
|
|||||||
@@ -63,3 +63,65 @@ Feature: Remove access to a drive item
|
|||||||
| Co Owner | folder | FolderToShare |
|
| Co Owner | folder | FolderToShare |
|
||||||
| Uploader | folder | FolderToShare |
|
| Uploader | folder | FolderToShare |
|
||||||
| Manager | folder | FolderToShare |
|
| Manager | folder | FolderToShare |
|
||||||
|
|
||||||
|
|
||||||
|
Scenario Outline: user removes access to a resource in a group share
|
||||||
|
Given group "group1" has been created
|
||||||
|
And user "Brian" has been added to group "group1"
|
||||||
|
And user "Alice" has been added to group "group1"
|
||||||
|
And user "Alice" has created folder "FolderToShare"
|
||||||
|
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "textfile.txt"
|
||||||
|
And user "Alice" has sent the following share invitation:
|
||||||
|
| resourceType | <resource-type> |
|
||||||
|
| resource | <path> |
|
||||||
|
| space | Personal |
|
||||||
|
| sharee | group1 |
|
||||||
|
| shareType | group |
|
||||||
|
| role | <role> |
|
||||||
|
When user "Alice" removes the share permission of group "group1" from <resource-type> "<path>" of space "Personal" using the Graph API
|
||||||
|
Then the HTTP status code should be "204"
|
||||||
|
And for user "Brian" the space "Shares" should not contain these entries:
|
||||||
|
| <path> |
|
||||||
|
Examples:
|
||||||
|
| role | resource-type | path |
|
||||||
|
| Viewer | file | textfile.txt |
|
||||||
|
| File Editor | file | textfile.txt |
|
||||||
|
| Co Owner | file | textfile.txt |
|
||||||
|
| Manager | file | textfile.txt |
|
||||||
|
| Viewer | folder | FolderToShare |
|
||||||
|
| Editor | folder | FolderToShare |
|
||||||
|
| Co Owner | folder | FolderToShare |
|
||||||
|
| Uploader | folder | FolderToShare |
|
||||||
|
| Manager | folder | FolderToShare |
|
||||||
|
|
||||||
|
|
||||||
|
Scenario Outline: user removes access to a resource inside of a project space in group share
|
||||||
|
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 created a folder "FolderToShare" in space "NewSpace"
|
||||||
|
And user "Alice" has uploaded a file inside space "NewSpace" with content "some content" to "textfile.txt"
|
||||||
|
And group "group1" has been created
|
||||||
|
And user "Brian" has been added to group "group1"
|
||||||
|
And user "Alice" has been added to group "group1"
|
||||||
|
And user "Alice" has sent the following share invitation:
|
||||||
|
| resourceType | <resource-type> |
|
||||||
|
| resource | <path> |
|
||||||
|
| space | NewSpace |
|
||||||
|
| sharee | group1 |
|
||||||
|
| shareType | group |
|
||||||
|
| role | <role> |
|
||||||
|
When user "Alice" removes the share permission of group "group1" from <resource-type> "<path>" of space "NewSpace" using the Graph API
|
||||||
|
Then the HTTP status code should be "204"
|
||||||
|
And for user "Brian" the space "Shares" should not contain these entries:
|
||||||
|
| <path> |
|
||||||
|
Examples:
|
||||||
|
| role | resource-type | path |
|
||||||
|
| Viewer | file | textfile.txt |
|
||||||
|
| File Editor | file | textfile.txt |
|
||||||
|
| Co Owner | file | textfile.txt |
|
||||||
|
| Manager | file | textfile.txt |
|
||||||
|
| Viewer | folder | FolderToShare |
|
||||||
|
| Editor | folder | FolderToShare |
|
||||||
|
| Co Owner | folder | FolderToShare |
|
||||||
|
| Uploader | folder | FolderToShare |
|
||||||
|
| Manager | folder | FolderToShare |
|
||||||
|
|||||||
@@ -284,10 +284,11 @@ class SharingNgContext implements Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When /^user "([^"]*)" removes the share permission of user "([^"]*)" from (file|folder) "([^"]*)" of space "([^"]*)" using the Graph API$/
|
* @When /^user "([^"]*)" removes the share permission of (user|group) "([^"]*)" from (file|folder) "([^"]*)" of space "([^"]*)" using the Graph API$/
|
||||||
*
|
*
|
||||||
* @param string $user
|
* @param string $sharer
|
||||||
* @param string $shareeUser
|
* @param string $shareType (user|group)
|
||||||
|
* @param string $sharee can be both user or group
|
||||||
* @param string $resourceType
|
* @param string $resourceType
|
||||||
* @param string $resource
|
* @param string $resource
|
||||||
* @param string $space
|
* @param string $space
|
||||||
@@ -296,27 +297,37 @@ class SharingNgContext implements Context {
|
|||||||
* @throws JsonException
|
* @throws JsonException
|
||||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||||
*/
|
*/
|
||||||
public function userRemovesSharePermissionOfUserFromResourceOfSpaceUsingGraphAPI(string $user, string $shareeUser, string $resourceType, string $resource, string $space): void {
|
public function userRemovesSharePermissionOfUserFromResourceOfSpaceUsingGraphAPI(
|
||||||
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
|
string $sharer,
|
||||||
|
string $shareType,
|
||||||
|
string $sharee,
|
||||||
|
string $resourceType,
|
||||||
|
string $resource,
|
||||||
|
string $space
|
||||||
|
): void {
|
||||||
|
$spaceId = ($this->spacesContext->getSpaceByName($sharer, $space))["id"];
|
||||||
$itemId = ($resourceType === 'folder')
|
$itemId = ($resourceType === 'folder')
|
||||||
? $this->spacesContext->getResourceId($user, $space, $resource)
|
? $this->spacesContext->getResourceId($sharer, $space, $resource)
|
||||||
: $this->spacesContext->getFileId($user, $space, $resource);
|
: $this->spacesContext->getFileId($sharer, $space, $resource);
|
||||||
$userIdOfShareeUser = $this->featureContext->getUserIdByUserName($shareeUser);
|
$userIdOfSharee = ($shareType === 'user')
|
||||||
|
? $this->featureContext->getUserIdByUserName($sharee)
|
||||||
|
: $this->featureContext->getGroupIdByGroupName($sharee);
|
||||||
$permId = GraphHelper::getSharePermissionId(
|
$permId = GraphHelper::getSharePermissionId(
|
||||||
$this->featureContext->getBaseUrl(),
|
$this->featureContext->getBaseUrl(),
|
||||||
$this->featureContext->getStepLineRef(),
|
$this->featureContext->getStepLineRef(),
|
||||||
$user,
|
$sharer,
|
||||||
$userIdOfShareeUser,
|
$userIdOfSharee,
|
||||||
$this->featureContext->getPasswordForUser($user),
|
$this->featureContext->getPasswordForUser($sharer),
|
||||||
$spaceId,
|
$spaceId,
|
||||||
$itemId
|
$itemId,
|
||||||
|
$shareType
|
||||||
);
|
);
|
||||||
$this->featureContext->setResponse(
|
$this->featureContext->setResponse(
|
||||||
GraphHelper::deleteSharePermission(
|
GraphHelper::removeSharePermission(
|
||||||
$this->featureContext->getBaseUrl(),
|
$this->featureContext->getBaseUrl(),
|
||||||
$this->featureContext->getStepLineRef(),
|
$this->featureContext->getStepLineRef(),
|
||||||
$user,
|
$sharer,
|
||||||
$this->featureContext->getPasswordForUser($user),
|
$this->featureContext->getPasswordForUser($sharer),
|
||||||
$spaceId,
|
$spaceId,
|
||||||
$itemId,
|
$itemId,
|
||||||
$permId
|
$permId
|
||||||
|
|||||||
Reference in New Issue
Block a user