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

[tests-only]tests: add tests for removing share permission in link share #8128

Merged
merged 1 commit into from
Jan 12, 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
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiSharingNg/linkShare.feature:447](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/linkShare.feature#L447)
- [apiSharingNg/linkShare.feature:448](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/linkShare.feature#L448)
- [apiSharingNg/linkShare.feature:449](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/linkShare.feature#L449)
- [apiSharingNg/deletePermissions.feature:146](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/deletePermissions.feature#L146)
- [apiSharingNg/deletePermissions.feature:163](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/deletePermissions.feature#L163)
- [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)

### [Share invitation to deleted user or group gives 500 (Fixed on master)](https://github.com/owncloud/ocis/issues/7962)
- [apiSharingNg/shareInvitations.feature:918](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/shareInvitations.feature#L918)
Expand Down
76 changes: 76 additions & 0 deletions tests/acceptance/features/apiSharingNg/deletePermissions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,79 @@ Feature: Remove access to a drive item
| Co Owner | folder | FolderToShare |
| Uploader | folder | FolderToShare |
| Manager | folder | FolderToShare |


Scenario Outline: user removes access to a folder in link share
Given user "Alice" has created folder "FolderToShare"
And user "Alice" has created the following link share:
| resourceType | folder |
| resource | FolderToShare |
| space | Personal |
| permissionsRole | <role> |
| password | %public% |
When user "Alice" removes the share permission of link from folder "FolderToShare" of space "Personal" 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 file in link share
Given user "Alice" has uploaded file "filesForUpload/textfile.txt" to "textfile.txt"
And user "Alice" has created the following link share:
| resourceType | file |
| resource | textfile.txt |
| space | Personal |
| permissionsRole | <permissionsRole> |
| password | %public% |
When user "Alice" removes the share permission of link from file "textfile.txt" of space "Personal" using the Graph API
Then the HTTP status code should be "204"
Examples:
| permissionsRole |
| 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 file 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 |
74 changes: 62 additions & 12 deletions tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,33 +329,34 @@ public function userSetsOrUpdatesFollowingPasswordForLastLinkShareUsingTheGraphA
}

/**
* @When /^user "([^"]*)" removes the share permission of (user|group) "([^"]*)" from (file|folder) "([^"]*)" 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 $resourceType
* @param string $resource
* @param string $space
* @param string|null $sharee can be both user or group
*
* @return void
* @return ResponseInterface
* @throws GuzzleException
* @throws JsonException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function userRemovesSharePermissionOfUserFromResourceOfSpaceUsingGraphAPI(
public function removeSharePermission(
string $sharer,
string $shareType,
string $sharee,
string $resourceType,
string $resource,
string $space
): void {
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 = $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
$this->featureContext->setResponse(

$permId = ($shareType === 'link')
? $this->featureContext->shareNgGetLastCreatedLinkShareID()
: $this->featureContext->shareNgGetLastCreatedUserGroupShareID();
return
GraphHelper::deleteSharePermission(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
Expand All @@ -364,7 +365,56 @@ public function userRemovesSharePermissionOfUserFromResourceOfSpaceUsingGraphAPI
$spaceId,
$itemId,
$permId
)
);
}

/**
* @When /^user "([^"]*)" removes the share permission of (user|group) "([^"]*)" from (file|folder) "([^"]*)" 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 $resourceType
* @param string $resource
* @param string $space
*
* @return void
* @throws JsonException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function userRemovesSharePermissionOfUserFromResourceOfSpaceUsingGraphAPI(
string $sharer,
string $shareType,
string $sharee,
string $resourceType,
string $resource,
string $space
): void {
$this->featureContext->setResponse(
$this->removeSharePermission($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 userRemovesSharePermissionOfAResourceInLinkShareUsingGraphAPI(
string $sharer,
string $resourceType,
string $resource,
string $space
):void {
$this->featureContext->setResponse(
$this->removeSharePermission($sharer, 'link', $resourceType, $resource, $space)
);
}
}