Skip to content

Commit

Permalink
adding test for updating share link of a project space using permissi…
Browse files Browse the repository at this point in the history
…on endpoint
  • Loading branch information
nirajacharya2 committed May 31, 2024
1 parent c48f435 commit 6b35bca
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiSharingNgLinkShare/linkShare.feature:2734](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgLinkShare/linkShare.feature#L2734)
- [apiSharingNgLinkShare/linkShare.feature:2735](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgLinkShare/linkShare.feature#L2735)
- [apiSharingNgLinkShare/linkShare.feature:2803](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgLinkShare/linkShare.feature#L2803)
- [apiSharingNgLinkShare/linkShare.feature:2889](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgLinkShare/linkShare.feature#L2889)
- [apiSharingNg/removeAccessToDriveItem.feature:125](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/removeAccessToDriveItem.feature#L125)
- [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)
Expand Down
94 changes: 90 additions & 4 deletions tests/acceptance/features/apiSharingNgLinkShare/linkShare.feature
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ Feature: Create a share link for a resource
| space | Personal |
| permissionsRole | <permissions-role> |
| password | %public% |
When user "Alice" updates the last public link share using the Graph API with
When user "Alice" updates the last public link share using the permissions endpoint of the Graph API
| resource | textfile1.txt |
| space | Personal |
| permissionsRole | <new-permissions-role> |
Expand Down Expand Up @@ -552,7 +552,7 @@ Feature: Create a share link for a resource
| space | Personal |
| permissionsRole | <permissions-role> |
| password | %public% |
When user "Alice" updates the last public link share using the Graph API with
When user "Alice" updates the last public link share using the permissions endpoint of the Graph API
| resource | textfile1.txt |
| space | Personal |
| permissionsRole | internal |
Expand Down Expand Up @@ -619,7 +619,7 @@ Feature: Create a share link for a resource
| permissionsRole | view |
| password | %public% |
| expirationDateTime | 2200-07-15T14:00:00.000Z |
When user "Alice" updates the last public link share using the Graph API with
When user "Alice" updates the last public link share using the permissions endpoint of the Graph API
| resource | textfile1.txt |
| space | Personal |
| expirationDateTime | 2201-07-15T14:00:00.000Z |
Expand Down Expand Up @@ -683,7 +683,7 @@ Feature: Create a share link for a resource
| permissionsRole | view |
| password | %public% |
| expirationDateTime | 2200-07-15T14:00:00.000Z |
When user "Alice" updates the last public link share using the Graph API with
When user "Alice" updates the last public link share using the permissions endpoint of the Graph API
| resource | <resource> |
| space | Personal |
| expirationDateTime | |
Expand Down Expand Up @@ -2801,3 +2801,89 @@ Feature: Create a share link for a resource
| upload |
| createOnly |
| blocksDownload |


Scenario Outline: update link share of a project-space using permissions endpoint
Given using spaces DAV path
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Alice" has created a space "projectSpace" with the default quota using the Graph API
And user "Alice" has created the following space link share:
| space | projectSpace |
| permissionsRole | <permissions-role> |
| password | %public% |
| displayName | Homework |
| expirationDateTime | 2200-07-15T14:00:00.000Z |
When user "Alice" updates the last public link share using the permissions endpoint of the Graph API:
| space | projectSpace |
| permissionsRole | <new-permissions-role> |
| password | p@$$w0rD |
| expirationDateTime | 2201-07-15T14:00:00Z |
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"hasPassword",
"id",
"link",
"expirationDateTime",
"createdDateTime"
],
"properties": {
"hasPassword": {
"const": true
},
"id": {
"type": "string",
"pattern": "^[a-zA-Z]{15}$"
},
"expirationDateTime": {
"const": "2201-07-15T23:59:59Z"
},
"link": {
"type": "object",
"required": [
"@libre.graph.displayName",
"@libre.graph.quickLink",
"preventsDownload",
"type",
"webUrl"
],
"properties": {
"@libre.graph.displayName": {
"const": "Homework"
},
"@libre.graph.quickLink": {
"const": false
},
"preventsDownload": {
"const": false
},
"type": {
"const": "<new-permissions-role>"
},
"webUrl": {
"type": "string",
"pattern": "^%base_url%/s/[a-zA-Z]{15}$"
}
}
}
}
}
"""
Examples:
| permissions-role | new-permissions-role |
| view | edit |
| view | upload |
| view | createOnly |
| edit | view |
| edit | upload |
| edit | createOnly |
| upload | view |
| upload | edit |
| upload | createOnly |
| createOnly | view |
| createOnly | edit |
| createOnly | upload |
| blocksDownload | blocksDownload |
11 changes: 7 additions & 4 deletions tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,15 +628,15 @@ public function userHasUpdatedLastPublicLinkShare(string $user, TableNode $body
}

/**
* @When /^user "([^"]*)" updates the last public link share using the Graph API with$/
* @When user :user updates the last public link share using the permissions endpoint of the Graph API:
*
* @param string $user
* @param TableNode $body
*
* @return void
* @throws Exception
*/
public function userUpdatesLastPublicLinkShareUsingTheGraphApiWith(string $user, TableNode $body):void {
public function userUpdatesTheLastPublicLinkShareUsingThePermissionsEndpointOfTheGraphApi(string $user, TableNode $body):void {
$this->featureContext->setResponse(
$this->updateLinkShare(
$user,
Expand All @@ -657,9 +657,12 @@ public function userUpdatesLastPublicLinkShareUsingTheGraphApiWith(string $user,
public function updateLinkShare(string $user, TableNode $body, string $permissionID): ResponseInterface {
$bodyRows = $body->getRowsHash();
$space = $bodyRows['space'];
$resource = $bodyRows['resource'];
if (isset($bodyRows['resource'])) {
$itemId = $this->spacesContext->getResourceId($user, $space, $bodyRows['resource']);
} else {
$itemId = $this->spacesContext->getResourceId($user, $space, $space);
}
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))['id'];
$itemId = $this->spacesContext->getResourceId($user, $space, $resource);
$body = [];

if (\array_key_exists('permissionsRole', $bodyRows)) {
Expand Down

0 comments on commit 6b35bca

Please sign in to comment.