Skip to content

Commit

Permalink
Add tests for remove permissions link share
Browse files Browse the repository at this point in the history
Signed-off-by: Swikriti Tripathi <[email protected]>
  • Loading branch information
SwikritiT committed Jan 11, 2024
1 parent 737cada commit 15983b7
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,5 +267,7 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiSharingNg/linkShare.feature:449](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/linkShare.feature#L449)
- [apiSharingNg/deletePermissions.feature:147](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/deletePermissions.feature#L147)
- [apiSharingNg/deletePermissions.feature:162](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/deletePermissions.feature#L162)
- [apiSharingNg/deletePermissions.feature:184](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/deletePermissions.feature#L184)
- [apiSharingNg/deletePermissions.feature:203](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/deletePermissions.feature#L203)
- Note: always have an empty line at the end of this file.
The bash script that processes this file requires that the last line has a newline on the end.
40 changes: 40 additions & 0 deletions tests/acceptance/features/apiSharingNg/deletePermissions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,43 @@ Feature: Remove access to a drive item
| view |
| edit |
| blocksDownload |


Scenario Outline: user removes access to a folder in project space in link 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 created the following link share:
| resourceType | folder |
| resource | FolderToShare |
| space | NewSpace |
| permissionsRole | <role> |
| password | %public% |
When user "Alice" removes the share permission of link from folder "FolderToShare" of space "NewSpace" using the Graph API
Then the HTTP status code should be "204"
Examples:
| role |
| view |
| edit |
| upload |
| createOnly |
| blocksDownload |


Scenario Outline: user removes access to a folder in project space in link 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 uploaded a file inside space "NewSpace" with content "some content" to "textfile.txt"
And user "Alice" has created the following link share:
| resourceType | file |
| resource | textfile.txt |
| space | NewSpace |
| permissionsRole | <permissionsRole> |
| password | %public% |
When user "Alice" removes the share permission of link from file "textfile.txt" of space "NewSpace" using the Graph API
Then the HTTP status code should be "204"
Examples:
| permissionsRole |
| view |
| edit |
| blocksDownload |
136 changes: 67 additions & 69 deletions tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,51 +328,49 @@ public function userSetsOrUpdatesFollowingPasswordForLastLinkShareUsingTheGraphA
$this->featureContext->setResponse($response);
}

/**
* @param string $sharer
* @param string $shareType (user|group)
* @param string $resourceType
* @param string $resource
* @param string $space
* @param string|null $sharee can be both user or group
*
* @return ResponseInterface
* @throws GuzzleException
* @throws JsonException
*/
public function removeSharePermissionOfAResource(
string $sharer,
string $shareType,
string $resourceType,
string $resource,
string $space,
?string $sharee = null,
): ResponseInterface
{
$spaceId = ($this->spacesContext->getSpaceByName($sharer, $space))["id"];
$itemId = ($resourceType === 'folder')
? $this->spacesContext->getResourceId($sharer, $space, $resource)
: $this->spacesContext->getFileId($sharer, $space, $resource);
$permId = null;
if($shareType === 'link') {
$permId = $this->featureContext->shareNgGetLastCreatedLinkShareID();
} else {
$permId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
}
return
GraphHelper::deleteSharePermission(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$sharer,
$this->featureContext->getPasswordForUser($sharer),
$spaceId,
$itemId,
$permId
);
}

/**
* @param string $sharer
* @param string $shareType (user|group)
* @param string $resourceType
* @param string $resource
* @param string $space
* @param string|null $sharee can be both user or group
*
* @return ResponseInterface
* @throws GuzzleException
* @throws JsonException
*/
public function removeSharePermissionOfAResource(
string $sharer,
string $shareType,
string $resourceType,
string $resource,
string $space,
?string $sharee = null,
): ResponseInterface {
$spaceId = ($this->spacesContext->getSpaceByName($sharer, $space))["id"];
$itemId = ($resourceType === 'folder')
? $this->spacesContext->getResourceId($sharer, $space, $resource)
: $this->spacesContext->getFileId($sharer, $space, $resource);
$permId = null;
if ($shareType === 'link') {
$permId = $this->featureContext->shareNgGetLastCreatedLinkShareID();
} else {
$permId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
}
return
GraphHelper::deleteSharePermission(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$sharer,
$this->featureContext->getPasswordForUser($sharer),
$spaceId,
$itemId,
$permId
);
}

/**
/**
* @When /^user "([^"]*)" removes the share permission of (user|group) "([^"]*)" from (file|folder) "([^"]*)" of space "([^"]*)" using the Graph API$/
*
* @param string $sharer
Expand All @@ -394,31 +392,31 @@ public function userRemovesSharePermissionOfUserFromResourceOfSpaceUsingGraphAPI
string $resource,
string $space
): void {
$this->featureContext->setResponse(
$this->removeSharePermissionOfAResource($sharer,$shareType,$resourceType,$resource,$space)
);
$this->featureContext->setResponse(
$this->removeSharePermissionOfAResource($sharer, $shareType, $resourceType, $resource, $space)
);
}

/**
* @When /^user "([^"]*)" removes the share permission of link from (file|folder) "([^"]*)" of space "([^"]*)" using the Graph API$/
*
* @param string $sharer
* @param string $resourceType
* @param string $resource
* @param string $space
*
* @return void
* @throws JsonException
* @throws GuzzleException
*/
public function removeSharePermissionOfAResourceInLinkShareUsingGraphAPI(
string $sharer,
string $resourceType,
string $resource,
string $space
):void {
$this->featureContext->setResponse(
$this->removeSharePermissionOfAResource($sharer,'link',$resourceType,$resource,$space)
);
}
/**
* @When /^user "([^"]*)" removes the share permission of link from (file|folder) "([^"]*)" of space "([^"]*)" using the Graph API$/
*
* @param string $sharer
* @param string $resourceType
* @param string $resource
* @param string $space
*
* @return void
* @throws JsonException
* @throws GuzzleException
*/
public function removeSharePermissionOfAResourceInLinkShareUsingGraphAPI(
string $sharer,
string $resourceType,
string $resource,
string $space
):void {
$this->featureContext->setResponse(
$this->removeSharePermissionOfAResource($sharer, 'link', $resourceType, $resource, $space)
);
}
}

0 comments on commit 15983b7

Please sign in to comment.