From c92ebf4b467df260867f757add74a9db33915ce8 Mon Sep 17 00:00:00 2001 From: Amrita <54478846+amrita-shrestha@users.noreply.github.com> Date: Wed, 21 Feb 2024 14:54:40 +0545 Subject: [PATCH] [full-ci][tests-only]add tests coverage for removing expiration date from shares (#8490) * add tests coverage for removing expiration date from share link * add coverage for folder --- .../features/apiSharingNg/linkShare.feature | 71 +++++++++++++++++ .../updateShareInvitations.feature | 76 ++++++++++++++++++- .../features/bootstrap/SharingNgContext.php | 10 +-- 3 files changed, 151 insertions(+), 6 deletions(-) diff --git a/tests/acceptance/features/apiSharingNg/linkShare.feature b/tests/acceptance/features/apiSharingNg/linkShare.feature index 23a419d97d..252b0a9b8d 100644 --- a/tests/acceptance/features/apiSharingNg/linkShare.feature +++ b/tests/acceptance/features/apiSharingNg/linkShare.feature @@ -518,6 +518,77 @@ Feature: Create a share link for a resource } """ + @issues-8405 + Scenario Outline: remove expiration date of a resource link share + Given user "Alice" has uploaded file with content "other data" to "textfile1.txt" + And user "Alice" has created folder "folder" + And user "Alice" has created the following link share: + | resource | | + | space | Personal | + | 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 + | resource | | + | space | Personal | + | expirationDateTime | | + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "hasPassword", + "id", + "link" + ], + "properties": { + "hasPassword": { + "type": "boolean", + "enum": [true] + }, + "id": { + "type": "string", + "pattern": "^[a-zA-Z]{15}$" + }, + "link": { + "type": "object", + "minItems": 5, + "maxItems": 5, + "required": [ + "@libre.graph.displayName", + "@libre.graph.quickLink", + "preventsDownload", + "type", + "webUrl" + ], + "properties": { + "@libre.graph.quickLink": { + "type": "boolean", + "enum": [false] + }, + "preventsDownload": { + "type": "boolean", + "enum": [false] + }, + "type": { + "type": "string", + "enum": ["view"] + }, + "webUrl": { + "type": "string", + "pattern": "^%base_url%\/s\/[a-zA-Z]{15}$" + } + } + } + } + } + """ + Examples: + | path | + | textfile1.txt | + | folder | + @env-config Scenario: set password on a file's link share Given the following configs have been set: diff --git a/tests/acceptance/features/apiSharingNg/updateShareInvitations.feature b/tests/acceptance/features/apiSharingNg/updateShareInvitations.feature index 0ba82e457d..f98612bed5 100644 --- a/tests/acceptance/features/apiSharingNg/updateShareInvitations.feature +++ b/tests/acceptance/features/apiSharingNg/updateShareInvitations.feature @@ -83,6 +83,80 @@ Feature: Update permission of a share """ + Scenario Outline: user removes expiration date of a share + Given user "Alice" has uploaded file with content "hello world" to "testfile.txt" + And user "Alice" has created folder "folder" + And user "Alice" has sent the following share invitation: + | resource | | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + | expirationDateTime | 2025-07-15T14:00:00Z | + When user "Alice" updates the last share with the following using the Graph API: + | space | Personal | + | resource | | + | expirationDateTime | | + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "minItems": 3, + "maxItems": 3, + "required": [ + "grantedToV2", + "id", + "roles" + ], + "properties": { + "grantedToV2": { + "type": "object", + "required": [ + "user" + ], + "properties":{ + "user": { + "type": "object", + "required": [ + "displayName", + "id" + ], + "properties": { + "displayName": { + "type": "string", + "enum": ["Brian Murphy"] + }, + "id": { + "type": "string", + "pattern": "^%user_id_pattern%$" + } + } + } + } + }, + "id": { + "type": "string", + "pattern": "^%permissions_id_pattern%$" + }, + "roles": { + "type": "array", + "items": [ + { + "type": "string", + "pattern": "^%role_id_pattern%$" + } + ] + } + } + } + """ + Examples: + | path | + | testfile.txt | + | folder | + + Scenario Outline: user updates role of a share Given user "Alice" has uploaded file with content "to share" to "/textfile1.txt" And user "Alice" has created folder "FolderToShare" @@ -157,4 +231,4 @@ Feature: Update permission of a share | Editor | FolderToShare | Viewer | | Editor | FolderToShare | Uploader | | Uploader | FolderToShare | Editor | - | Uploader | FolderToShare | Viewer | \ No newline at end of file + | Uploader | FolderToShare | Viewer | diff --git a/tests/acceptance/features/bootstrap/SharingNgContext.php b/tests/acceptance/features/bootstrap/SharingNgContext.php index 4c6453ea1d..bd33bc4167 100644 --- a/tests/acceptance/features/bootstrap/SharingNgContext.php +++ b/tests/acceptance/features/bootstrap/SharingNgContext.php @@ -262,11 +262,11 @@ class SharingNgContext implements Context { $body = []; if (\array_key_exists('permissionsRole', $bodyRows)) { - $body["roles"] = [GraphHelper::getPermissionsRoleIdByName($bodyRows['permissionsRole'])]; + $body['roles'] = [GraphHelper::getPermissionsRoleIdByName($bodyRows['permissionsRole'])]; } if (\array_key_exists('expirationDateTime', $bodyRows)) { - $body["expirationDateTime"] = $bodyRows['expirationDateTime']; + $body['expirationDateTime'] = empty($bodyRows['expirationDateTime']) ? null : $bodyRows['expirationDateTime']; } return GraphHelper::updateShare( @@ -357,16 +357,16 @@ class SharingNgContext implements Context { $bodyRows = $body->getRowsHash(); $space = $bodyRows['space']; $resource = $bodyRows['resource']; - $spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"]; + $spaceId = ($this->spacesContext->getSpaceByName($user, $space))['id']; $itemId = $this->spacesContext->getResourceId($user, $space, $resource); $body = []; if (\array_key_exists('permissionsRole', $bodyRows)) { - $body["link"]["type"] = $bodyRows['permissionsRole']; + $body['link']['type'] = $bodyRows['permissionsRole']; } if (\array_key_exists('expirationDateTime', $bodyRows)) { - $body["expirationDateTime"] = $bodyRows['expirationDateTime']; + $body['expirationDateTime'] = empty($bodyRows['expirationDateTime']) ? null : $bodyRows['expirationDateTime']; } return GraphHelper::updateShare(