add tests for removing share link (#9123)

This commit is contained in:
Amrita
2024-05-10 16:28:58 +05:45
committed by GitHub
parent 6a005aedd4
commit 00ed2ce58c
3 changed files with 120 additions and 0 deletions

View File

@@ -266,6 +266,8 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiSharingNg/removeAccessToDriveItem.feature:141](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/removeAccessToDriveItem.feature#L141)
- [apiSharingNg/removeAccessToDriveItem.feature:161](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/removeAccessToDriveItem.feature#L161)
- [apiSharingNg/removeAccessToDriveItem.feature:179](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/removeAccessToDriveItem.feature#L179)
- [apiSharingNg/removeAccessToDrive.feature:178](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/removeAccessToDrive.feature#L178)
- [apiSharingNg/removeAccessToDrive.feature:207](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/removeAccessToDrive.feature#L207)
### [sharee (editor role) MOVE a file by file-id into same shared folder returns 403](https://github.com/owncloud/ocis/issues/7617)

View File

@@ -157,3 +157,61 @@ Feature: Remove access to a drive
When user "Brian" tries to remove the access of group "group1" from space "NewSpace" using root endpoint of the Graph API
Then the HTTP status code should be "403"
And the user "Brian" should have a space called "NewSpace"
@issue-7879
Scenario Outline: user removes link share 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 created the following space link share:
| space | NewSpace |
| permissionsRole | <permissions-role> |
| password | %public% |
When user "Alice" removes the link from space "NewSpace" using root endpoint of the Graph API
Then the HTTP status code should be "204"
And user "Alice" should not have any "link" permissions on space "NewSpace"
Examples:
| permissions-role |
| view |
| edit |
| upload |
| createOnly |
| blocksDownload |
Scenario: user removes internal link share 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 created the following space link share:
| space | NewSpace |
| permissionsRole | internal |
When user "Alice" removes the link from space "NewSpace" using root endpoint of the Graph API
Then the HTTP status code should be "204"
And user "Alice" should not have any "link" permissions on space "NewSpace"
@issue-7879
Scenario Outline: user tries to remove link share of project space owned by next user
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 the following space link share:
| space | NewSpace |
| permissionsRole | <permissions-role> |
| password | %public% |
When user "Brian" tries to remove the link from space "NewSpace" owned by "Alice" using root endpoint of the Graph API
Then the HTTP status code should be "500"
Examples:
| permissions-role |
| view |
| edit |
| upload |
| createOnly |
| blocksDownload |
Scenario: user tries to remove internal link share of project space owned by next user
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 the following space link share:
| space | NewSpace |
| permissionsRole | internal |
When user "Brian" tries to remove the link from space "NewSpace" owned by "Alice" using root endpoint of the Graph API
Then the HTTP status code should be "500"

View File

@@ -1316,4 +1316,64 @@ class SharingNgContext implements Context {
);
$this->featureContext->setResponse($response);
}
/**
* @When user :user tries to remove the link from space :space owned by :owner using root endpoint of the Graph API
*
* @param string $user
* @param string $space
* @param string $spaceOwner
*
* @return void
* @throws GuzzleException
*/
public function userTriesToRemoveShareLinkOfSpaceOwnedByUsingRootEndpointOfTheGraphApi(string $user, string $space, string $spaceOwner): void {
$permissionID = $this->featureContext->shareNgGetLastCreatedLinkShareID();
$spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"];
$response = GraphHelper::removeAccessToSpace(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$spaceId,
$permissionID
);
$this->featureContext->setResponse($response);
}
/**
* @Then user :user should not have any :shareType permissions on space :space
*
* @param string $user
* @param string $shareType
* @param string $space
*
* @return void
* @throws GuzzleException
*/
public function userShouldNotHaveAnyPermissionsOnSpace(string $user, string $shareType, string $space): void {
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
$response = GraphHelper::getDrivePermissionsList(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$spaceId
);
$responseBody = $this->featureContext->getJsonDecodedResponse($response);
foreach ($responseBody['value'] as $value) {
switch ($shareType) {
case $shareType === 'link':
Assert::assertArrayNotHasKey('link', $value, $space . ' space should not have any link permissions but found ' . print_r($value, true));
break;
case $shareType === "share":
Assert::assertArrayNotHasKey('grantedToV2', $value, $space . ' space should not have any share permissions but found ' . print_r($value, true));
break;
default:
Assert::fail('Invalid share type has been specified');
}
}
}
}