From 3e3a4b688b35220538111645d941b2babdaac080 Mon Sep 17 00:00:00 2001 From: prashant-gurung899 Date: Mon, 3 Mar 2025 12:19:31 +0545 Subject: [PATCH] add test to share resources with fileEditorWithVersions role and list versions Signed-off-by: prashant-gurung899 --- .drone.star | 1 + tests/acceptance/TestHelpers/GraphHelper.php | 2 + tests/acceptance/config/behat.yml | 10 + .../editorWithVersions.feature | 172 ++++++++++++++++++ 4 files changed, 185 insertions(+) create mode 100644 tests/acceptance/features/apiOptionalShareRole/editorWithVersions.feature diff --git a/.drone.star b/.drone.star index 400423748aa..9ab1198ac7e 100644 --- a/.drone.star +++ b/.drone.star @@ -167,6 +167,7 @@ config = { "apiReshare", "apiSharingNg1", "apiSharingNg2", + "apiOptionalShareRole", ], "skip": False, }, diff --git a/tests/acceptance/TestHelpers/GraphHelper.php b/tests/acceptance/TestHelpers/GraphHelper.php index 1a70055b4d4..de1b82acb53 100644 --- a/tests/acceptance/TestHelpers/GraphHelper.php +++ b/tests/acceptance/TestHelpers/GraphHelper.php @@ -44,6 +44,8 @@ class GraphHelper { 'Secure Viewer' => 'aa97fe03-7980-45ac-9e50-b325749fd7e6', 'Space Editor Without Versions' => '3284f2d5-0070-4ad8-ac40-c247f7c1fb27', 'Denied' => '63e64e19-8d43-42ec-a738-2b6af2610efa', + 'Editor With Versions' => '0911d62b-1e3f-4778-8b1b-903b7e4e8476', + 'File Editor With Versions' => 'b173329d-cf2e-42f0-a595-ee410645d840' ]; public const SHARING_LINK_TYPE_MAPPINGS = [ diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index a40298a695d..3af23a876d4 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -365,6 +365,16 @@ default: - EmailContext: - OcisConfigContext: + apiOptionalShareRole: + paths: + - "%paths.base%/../features/apiOptionalShareRole" + context: *common_ldap_suite_context + contexts: + - FeatureContext: *common_feature_context_params + - GraphContext: + - SharingNgContext: + - OcisConfigContext: + apiSharingNgShareInvitation: paths: - "%paths.base%/../features/apiSharingNgShareInvitation" diff --git a/tests/acceptance/features/apiOptionalShareRole/editorWithVersions.feature b/tests/acceptance/features/apiOptionalShareRole/editorWithVersions.feature new file mode 100644 index 00000000000..e7c24509b69 --- /dev/null +++ b/tests/acceptance/features/apiOptionalShareRole/editorWithVersions.feature @@ -0,0 +1,172 @@ +@env-config +Feature: an user shares resources + As a user + I want to share resources with Editor With Versions role + So that users can edit the resource and see the versions + + Background: + Given these users have been created with default attributes: + | username | + | Alice | + | Brian | + + + Scenario: sharee checks version of a file shared with FileEditorWithVersions role + Given the administrator has enabled the permissions role 'File Editor With Versions' + And user "Alice" has uploaded file with content "to share" to "textfile.txt" + And we save it into "FILEID" + When user "Alice" sends the following resource share invitation using the Graph API: + | resource | textfile.txt | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | File Editor With Versions | + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": ["value"], + "properties": { + "value": { + "type": "array", + "maxItems": 1, + "minItems": 1, + "items": { + "type": "object", + "required": ["createdDateTime", "id", "roles", "grantedToV2", "invitation"], + "properties": { + "id": { "pattern": "^%permissions_id_pattern%$" }, + "roles": { + "type": "array", + "maxItems": 1, + "minItems": 1, + "items": { "const": "b173329d-cf2e-42f0-a595-ee410645d840" } + }, + "invitation": { + "type": "object", + "required": ["invitedBy"], + "properties": { + "invitedBy": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "object", + "required": ["displayName", "id", "@libre.graph.userType"], + "properties": { + "displayName": { "const": "Alice Hansen" }, + "id": { "pattern": "^%user_id_pattern%$" }, + "@libre.graph.userType": { "const": "Member" } + } + } + } + } + } + }, + "grantedToV2": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "object", + "required": ["id", "displayName", "@libre.graph.userType"], + "properties": { + "id": { "pattern": "^%user_id_pattern%$" }, + "displayName": { "const": "Brian Murphy" }, + "@libre.graph.userType": { "const": "Member" } + } + } + } + } + } + } + } + } + } + """ + And user "Brian" has uploaded file with content "updated content" to "Shares/textfile.txt" + When user "Brian" gets the number of versions of file "textfile.txt" using file-id "<>" + Then the HTTP status code should be "207" + And the number of versions should be "1" + + + Scenario: sharee checks version of a file inside a folder shared with EditorWithVersions role + Given the administrator has enabled the permissions role 'Editor With Versions' + And user "Alice" has created folder "folderToShare" + And user "Alice" has uploaded file with content "to share" to "folderToShare/textfile.txt" + And we save it into "FILEID" + When user "Alice" sends the following resource share invitation using the Graph API: + | resource | folderToShare | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Editor With Versions | + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": ["value"], + "properties": { + "value": { + "type": "array", + "maxItems": 1, + "minItems": 1, + "items": { + "type": "object", + "required": ["createdDateTime", "id", "roles", "grantedToV2", "invitation"], + "properties": { + "id": { "pattern": "^%permissions_id_pattern%$" }, + "roles": { + "type": "array", + "maxItems": 1, + "minItems": 1, + "items": { "const": "0911d62b-1e3f-4778-8b1b-903b7e4e8476" } + }, + "invitation": { + "type": "object", + "required": ["invitedBy"], + "properties": { + "invitedBy": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "object", + "required": ["displayName", "id", "@libre.graph.userType"], + "properties": { + "displayName": { "const": "Alice Hansen" }, + "id": { "pattern": "^%user_id_pattern%$" }, + "@libre.graph.userType": { "const": "Member" } + } + } + } + } + } + }, + "grantedToV2": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "object", + "required": ["id", "displayName", "@libre.graph.userType"], + "properties": { + "id": { "pattern": "^%user_id_pattern%$" }, + "displayName": { "const": "Brian Murphy" }, + "@libre.graph.userType": { "const": "Member" } + } + } + } + } + } + } + } + } + } + """ + And user "Brian" has uploaded file with content "updated content" to "Shares/folderToShare/textfile.txt" + When user "Brian" gets the number of versions of file "textfile.txt" using file-id "<>" + Then the HTTP status code should be "207" + And the number of versions should be "1"