From 211dfd27e82afec9194242ec652a5b56d18e8088 Mon Sep 17 00:00:00 2001 From: Prajwol Amatya Date: Wed, 11 Dec 2024 14:29:15 +0545 Subject: [PATCH] added test to update role to existing roles after assigned role is disabled --- .../acceptance/bootstrap/SharingNgContext.php | 18 +++ .../enableDisablePermissionsRole.feature | 109 ++++++++++++++++++ 2 files changed, 127 insertions(+) diff --git a/tests/acceptance/bootstrap/SharingNgContext.php b/tests/acceptance/bootstrap/SharingNgContext.php index d18d6abc616..c05260aedc4 100644 --- a/tests/acceptance/bootstrap/SharingNgContext.php +++ b/tests/acceptance/bootstrap/SharingNgContext.php @@ -2119,4 +2119,22 @@ public function userGetsFederatedPermissionsListForFileOfTheSpaceUsingTheGraphAp $this->getPermissionsList($user, $fileOrFolder, $space, $resource, $query) ); } + + /** + * @Then the updated permissions role of the last share should be :permissionsRole + * + * @param string $permissionsRole + * + * @return void + */ + public function theUpdatedPermissionsRoleOfTheLastShareShouldBe(string $permissionsRole): void { + $responseBody = $this->featureContext->getJsonDecodedResponseBodyContent(); + $actualRoleId = $responseBody->roles[0]; + $expectedRoleId = GraphHelper::getPermissionsRoleIdByName($permissionsRole); + Assert::assertEquals( + $actualRoleId, + $expectedRoleId, + "Expected permissions role id to be $expectedRoleId but found $actualRoleId" + ); + } } diff --git a/tests/acceptance/features/apiSharingNg1/enableDisablePermissionsRole.feature b/tests/acceptance/features/apiSharingNg1/enableDisablePermissionsRole.feature index 1196b450870..3ac10f0c93a 100644 --- a/tests/acceptance/features/apiSharingNg1/enableDisablePermissionsRole.feature +++ b/tests/acceptance/features/apiSharingNg1/enableDisablePermissionsRole.feature @@ -547,3 +547,112 @@ Feature: enable disable permissions role | oc:name | new-space | | oc:permissions | DNVCK | And user "Brian" should be able to download file "textfile1.txt" from space "new-space" + + + Scenario Outline: update share role of a file to an existing role after assigned share role Secure Viewer is disabled (Personal Space) + Given using spaces DAV path + And the administrator has enabled the permissions role "Secure Viewer" + And user "Alice" has uploaded file with content "some content" to "textfile.txt" + And user "Alice" has created folder "folderToShare" + And user "Alice" has uploaded file with content "hello world" to "folderToShare/textfile1.txt" + And user "Alice" has sent the following resource share invitation: + | resource | | + | space | Personal | + | sharee | Brian | + | shareType | user | + | permissionsRole | Secure Viewer | + And user "Brian" has a share "" synced + And the administrator has disabled the permissions role "Secure Viewer" + When user "Alice" updates the last resource share with the following properties using the Graph API: + | permissionsRole | | + | space | Personal | + | resource | | + Then the HTTP status code should be "200" + And the updated permissions role of the last share should be "" + And user "Brian" should have a share "" shared by user "Alice" from space "Personal" + When user "Brian" sends PROPFIND request from the space "Shares" to the resource "" with depth "0" using the WebDAV API + Then the HTTP status code should be "207" + And as user "Brian" the PROPFIND response should contain a resource "" with these key and value pairs: + | key | value | + | oc:name | | + | oc:permissions | | + And user "Brian" should be able to download file "" from space "Shares" + Examples: + | resource | permissions-role | permissions | resource-to-download | + | textfile.txt | File Editor | SNVW | textfile.txt | + | textfile.txt | Viewer | S | textfile.txt | + | folderToShare | Uploader | SCK | folderToShare/textfile1.txt | + | folderToShare | Editor | SDNVCK | folderToShare/textfile1.txt | + | folderToShare | Viewer | S | folderToShare/textfile1.txt | + + + Scenario Outline: update share role of a file to an existing role after assigned share role Secure Viewer is disabled (Project Space) + Given using spaces DAV path + And the administrator has enabled the permissions role "Secure Viewer" + And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And user "Alice" has created a space "new-space" with the default quota using the Graph API + And user "Alice" has uploaded a file inside space "new-space" with content "some content" to "textfile.txt" + And user "Alice" has created a folder "folderToShare" in space "new-space" + And user "Alice" has uploaded a file inside space "new-space" with content "hello world" to "folderToShare/textfile1.txt" + And user "Alice" has sent the following resource share invitation: + | resource | | + | space | new-space | + | sharee | Brian | + | shareType | user | + | permissionsRole | Secure Viewer | + And user "Brian" has a share "" synced + And the administrator has disabled the permissions role "Secure Viewer" + When user "Alice" updates the last resource share with the following properties using the Graph API: + | permissionsRole | | + | space | new-space | + | resource | | + Then the HTTP status code should be "200" + And the updated permissions role of the last share should be "" + And user "Brian" should have a share "" shared by user "Alice" from space "new-space" + When user "Brian" sends PROPFIND request from the space "Shares" to the resource "" with depth "0" using the WebDAV API + Then the HTTP status code should be "207" + And as user "Brian" the PROPFIND response should contain a resource "" with these key and value pairs: + | key | value | + | oc:name | | + | oc:permissions | | + And user "Brian" should be able to download file "" from space "Shares" + Examples: + | resource | permissions-role | permissions | resource-to-download | + | textfile.txt | File Editor | SNVW | textfile.txt | + | textfile.txt | Viewer | S | textfile.txt | + | folderToShare | Uploader | SCK | folderToShare/textfile1.txt | + | folderToShare | Editor | SDNVCK | folderToShare/textfile1.txt | + | folderToShare | Viewer | S | folderToShare/textfile1.txt | + + + Scenario Outline: update share role of a project space to an existing role after assigned share role is disabled + Given using spaces DAV path + And the administrator has enabled the permissions role "Space Editor Without Versions" + And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And user "Alice" has created a space "new-space" with the default quota using the Graph API + And user "Alice" has uploaded a file inside space "new-space" with content "some content" to "textfile.txt" + And user "Alice" has sent the following space share invitation: + | space | new-space | + | sharee | Brian | + | shareType | user | + | permissionsRole | Space Editor Without Versions | + And the administrator has disabled the permissions role "Space Editor Without Versions" + When user "Alice" updates the last drive share with the following using root endpoint of the Graph API: + | permissionsRole | | + | space | new-space | + | shareType | user | + | sharee | Brian | + Then the HTTP status code should be "200" + And the updated permissions role of the last share should be "" + When user "Brian" sends PROPFIND request to space "new-space" with depth "0" using the WebDAV API + Then the HTTP status code should be "207" + And as user "Brian" the PROPFIND response should contain a space "new-space" with these key and value pairs: + | key | value | + | oc:name | new-space | + | oc:permissions | | + And user "Brian" should be able to download file "textfile.txt" from space "new-space" + Examples: + | permissions-role | permissions | + | Space Viewer | | + | Space Editor | DNVCK | + | Manager | RDNVCKZP |