From 62076ad9760a6576d21d7bf5b940c15b659cc088 Mon Sep 17 00:00:00 2001 From: nirajacharya2 <122071597+nirajacharya2@users.noreply.github.com> Date: Fri, 31 May 2024 12:36:26 +0545 Subject: [PATCH] adding test for updating share link of a project space using permission endpoint (#9251) --- ...ected-failures-localAPI-on-OCIS-storage.md | 1 + .../apiSharingNgLinkShare/linkShare.feature | 94 ++++++++++++++++++- .../features/bootstrap/SharingNgContext.php | 11 ++- 3 files changed, 98 insertions(+), 8 deletions(-) diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index cfc16c508c..b85584b7ef 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -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) diff --git a/tests/acceptance/features/apiSharingNgLinkShare/linkShare.feature b/tests/acceptance/features/apiSharingNgLinkShare/linkShare.feature index cd23a5521d..1231a60e58 100644 --- a/tests/acceptance/features/apiSharingNgLinkShare/linkShare.feature +++ b/tests/acceptance/features/apiSharingNgLinkShare/linkShare.feature @@ -482,7 +482,7 @@ Feature: Create a share link for a resource | space | Personal | | permissionsRole | | | 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 | | @@ -552,7 +552,7 @@ Feature: Create a share link for a resource | space | Personal | | permissionsRole | | | 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 | @@ -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 | @@ -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 | | | space | Personal | | expirationDateTime | | @@ -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 | | + | 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 | | + | 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": "" + }, + "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 | \ No newline at end of file diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index 6e7a05eec2..1a1a9230a4 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -628,7 +628,7 @@ class SharingNgContext implements Context { } /** - * @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 @@ -636,7 +636,7 @@ class SharingNgContext implements Context { * @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, @@ -657,9 +657,12 @@ class SharingNgContext implements Context { 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)) {