diff --git a/tests/acceptance/bootstrap/SharingNgContext.php b/tests/acceptance/bootstrap/SharingNgContext.php index 47d618d3186..8515d71e8a5 100644 --- a/tests/acceptance/bootstrap/SharingNgContext.php +++ b/tests/acceptance/bootstrap/SharingNgContext.php @@ -2111,31 +2111,6 @@ class SharingNgContext implements Context { } } - /** - * @When /^user "([^"]*)" gets the allowed roles for federated user of (folder|file) "([^"]*)" from the space "([^"]*)" using the Graph API$/ - * - * @param string $user - * @param string $fileOrFolder (file|folder) - * @param string $resource - * @param string $space - * - * @return void - * @throws Exception - */ - public function userGetsFederatedPermissionsListForFileOfTheSpaceUsingTheGraphApi( - string $user, - string $fileOrFolder, - string $resource, - string $space - ): void { - $query = '$filter=@libre.graph.permissions.roles.allowedValues' - . '/rolePermissions/any(p:contains(p/condition,+\'@Subject.UserType=="Federated"\'))' - . '&$select=@libre.graph.permissions.roles.allowedValues'; - $this->featureContext->setResponse( - $this->getPermissionsList($user, $fileOrFolder, $space, $resource, $query) - ); - } - /** * @When /^user "([^"]*)" lists permissions with following filters for (folder|file) "([^"]*)" of the space "([^"]*)" using the Graph API:$/ * diff --git a/tests/acceptance/features/apiOcm/listPermissions.feature b/tests/acceptance/features/apiOcm/listPermissions.feature index 7f383dae98c..9dc0223bd1c 100644 --- a/tests/acceptance/features/apiOcm/listPermissions.feature +++ b/tests/acceptance/features/apiOcm/listPermissions.feature @@ -1,4 +1,4 @@ -@ocm +@ocm @issue-9898 Feature: List a federated sharing permissions As a user I want to list the permissions for federated share @@ -6,15 +6,14 @@ Feature: List a federated sharing permissions Background: Given user "Alice" has been created with default attributes - - @issue-9898 - Scenario: user lists permissions of a resource shared to a federated user - Given using server "LOCAL" And "Alice" has created the federation share invitation And using server "REMOTE" And user "Brian" has been created with default attributes And "Brian" has accepted invitation - And using server "LOCAL" + + + Scenario: user lists permissions of a resource shared to a federated user + Given using server "LOCAL" And user "Alice" has uploaded file with content "ocm test" to "/textfile.txt" And user "Alice" has sent the following resource share invitation to federated user: | resource | textfile.txt | @@ -24,6 +23,94 @@ Feature: List a federated sharing permissions | permissionsRole | Viewer | When user "Alice" gets permissions list for file "textfile.txt" of the space "Personal" using the Graph API Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "@libre.graph.permissions.actions.allowedValues", + "@libre.graph.permissions.roles.allowedValues", + "value" + ], + "properties": { + "value": { + "type": "array", + "minItems": 1, + "maxItems": 1, + "uniqueItems": true, + "items": { + "oneOf":[ + { + "type": "object", + "required": ["grantedToV2","id","roles"], + "properties": { + "grantedToV2": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "object", + "required": ["@libre.graph.userType","displayName","id"], + "properties": { + "@libre.graph.userType": {"const": "Federated"}, + "id": {"pattern": "^%federated_user_id_pattern%$"}, + "displayName": {"const": "Brian Murphy"} + } + } + } + }, + "id": {"pattern": "^%user_id_pattern%$"}, + "invitation": { + "type": "object", + "required": ["invitedBy"], + "properties": { + "invitedBy": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "object", + "required": ["@libre.graph.userType", "displayName", "id"], + "properties": { + "@libre.graph.userType": {"const": "Member"}, + "id": {"pattern": "^%user_id_pattern%$"}, + "displayName": {"const": "Alice Hansen"} + } + } + } + } + } + }, + "roles": { + "type": "array", + "minItems": 1, + "maxItems": 1, + "items": {"pattern": "^%role_id_pattern%$"} + } + } + } + ] + } + } + } + } + """ + + + Scenario: user lists permissions of a project resource shared to a federated user + Given using server "LOCAL" + And 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 a folder "folderToShare" in space "projectSpace" + And user "Alice" has sent the following resource share invitation to federated user: + | resource | folderToShare | + | space | projectSpace | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + When user "Alice" gets permissions list for folder "folderToShare" of the space "projectSpace" using the Graph API + Then the HTTP status code should be "200" And the JSON data of the response should match """ { @@ -57,24 +144,14 @@ Feature: List a federated sharing permissions "type": "object", "required": ["@libre.graph.userType","displayName","id"], "properties": { - "@libre.graph.userType": { - "const": "Federated" - }, - "id": { - "type": "string", - "pattern": "^%federated_user_id_pattern%$" - }, - "displayName": { - "const": "Brian Murphy" - } + "@libre.graph.userType": {"const": "Federated"}, + "id": {"pattern": "^%federated_user_id_pattern%$"}, + "displayName": {"const": "Brian Murphy"} } } } }, - "id": { - "type": "string", - "pattern": "^%user_id_pattern%$" - }, + "id": { "pattern": "^%user_id_pattern%$" }, "invitation": { "type": "object", "required": ["invitedBy"], @@ -87,16 +164,9 @@ Feature: List a federated sharing permissions "type": "object", "required": ["@libre.graph.userType", "displayName", "id"], "properties": { - "@libre.graph.userType": { - "const": "Member" - }, - "id": { - "type": "string", - "pattern": "^%user_id_pattern%$" - }, - "displayName": { - "const": "Alice Hansen" - } + "@libre.graph.userType": {"const": "Member"}, + "id": {"pattern": "^%user_id_pattern%$"}, + "displayName": {"const": "Alice Hansen"} } } } @@ -107,10 +177,95 @@ Feature: List a federated sharing permissions "type": "array", "minItems": 1, "maxItems": 1, - "items": { - "type": "string", - "pattern": "^%role_id_pattern%$" + "items": {"pattern": "^%role_id_pattern%$"} + } + } + } + ] + } + } + } + } + """ + + + Scenario: user lists permissions of a project resource shared to a federated user + Given using server "LOCAL" + And 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 uploaded a file inside space "projectSpace" with content "some content" to "textfile.txt" + And user "Alice" has sent the following resource share invitation to federated user: + | resource | textfile.txt | + | space | projectSpace | + | sharee | Brian | + | shareType | user | + | permissionsRole | Viewer | + When user "Alice" gets permissions list for file "textfile.txt" of the space "projectSpace" using the Graph API + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "@libre.graph.permissions.actions.allowedValues", + "@libre.graph.permissions.roles.allowedValues", + "value" + ], + "properties": { + "value": { + "type": "array", + "minItems": 1, + "maxItems": 1, + "uniqueItems": true, + "items": { + "oneOf":[ + { + "type": "object", + "required": ["grantedToV2","id","roles"], + "properties": { + "grantedToV2": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "object", + "required": ["@libre.graph.userType","displayName","id"], + "properties": { + "@libre.graph.userType": {"const": "Federated"}, + "id": {"pattern": "^%federated_user_id_pattern%$"}, + "displayName": {"const": "Brian Murphy"} + } + } } + }, + "id": {"pattern": "^%user_id_pattern%$"}, + "invitation": { + "type": "object", + "required": ["invitedBy"], + "properties": { + "invitedBy": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "object", + "required": ["@libre.graph.userType", "displayName", "id"], + "properties": { + "@libre.graph.userType": {"const": "Member"}, + "id": {"pattern": "^%user_id_pattern%$"}, + "displayName": {"const": "Alice Hansen"} + } + } + } + } + } + }, + "roles": { + "type": "array", + "minItems": 1, + "maxItems": 1, + "items": {"pattern": "^%role_id_pattern%$"} } } } @@ -121,152 +276,3 @@ Feature: List a federated sharing permissions } """ - @issue-9745 @env-config - Scenario: user lists allowed file permissions for federated user - Given using server "LOCAL" - And the administrator has enabled the permissions role "Secure Viewer" - And user "Alice" has uploaded file with content "ocm test" to "/textfile.txt" - When user "Alice" gets the allowed roles for federated user of file "textfile.txt" from the space "Personal" using the Graph API - Then the HTTP status code should be "200" - And the JSON data of the response should match - """ - { - "type": "object", - "required": [ - "@libre.graph.permissions.roles.allowedValues" - ], - "properties": { - "@libre.graph.permissions.roles.allowedValues": { - "type": "array", - "minItems": 2, - "maxItems": 2, - "uniqueItems": true, - "items": { - "oneOf":[ - { - "type": "object", - "required": [ - "@libre.graph.weight", - "description", - "displayName", - "id" - ], - "properties": { - "@libre.graph.weight": { - "const": 1 - }, - "description": { - "const": "View and download." - }, - "displayName": { - "const": "Can view" - }, - "id": { - "const": "b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5" - } - } - }, - { - "type": "object", - "required": [ - "@libre.graph.weight", - "description", - "displayName", - "id" - ], - "properties": { - "@libre.graph.weight": { - "const": 2 - }, - "description": { - "const": "View, download and edit." - }, - "displayName": { - "const": "Can edit" - }, - "id": { - "const": "2d00ce52-1fc2-4dbc-8b95-a73b73395f5a" - } - } - } - ] - } - } - } - } - """ - - @issue-9745 - Scenario: user lists allowed folder permissions for federated user - Given using server "LOCAL" - And the administrator has enabled the permissions role "Secure Viewer" - And user "Alice" has created folder "folderToShare" - When user "Alice" gets the allowed roles for federated user of folder "folderToShare" from the space "Personal" using the Graph API - Then the HTTP status code should be "200" - And the JSON data of the response should match - """ - { - "type": "object", - "required": [ - "@libre.graph.permissions.roles.allowedValues" - ], - "properties": { - "@libre.graph.permissions.roles.allowedValues": { - "type": "array", - "minItems": 2, - "maxItems": 2, - "uniqueItems": true, - "items": { - "oneOf":[ - { - "type": "object", - "required": [ - "@libre.graph.weight", - "description", - "displayName", - "id" - ], - "properties": { - "@libre.graph.weight": { - "const": 1 - }, - "description": { - "const": "View and download." - }, - "displayName": { - "const": "Can view" - }, - "id": { - "const": "b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5" - } - } - }, - { - "type": "object", - "required": [ - "@libre.graph.weight", - "description", - "displayName", - "id" - ], - "properties": { - "@libre.graph.weight": { - "const": 2 - }, - "description": { - "const": "View, download, upload, edit, add and delete." - }, - "displayName": { - "const": "Can edit" - }, - "id": { - "const": "fb6c3e19-e378-47e5-b277-9732f9de6e21" - } - } - } - ] - } - } - } - } - """ diff --git a/tests/acceptance/features/apiSharingNg1/filterPermissions.feature b/tests/acceptance/features/apiSharingNg1/filterPermissions.feature index 0030a9b2e62..d5a32e0c5d5 100644 --- a/tests/acceptance/features/apiSharingNg1/filterPermissions.feature +++ b/tests/acceptance/features/apiSharingNg1/filterPermissions.feature @@ -1166,3 +1166,209 @@ Feature: filter sharing permissions } } """ + + @issue-9745 @env-config + Scenario: user lists allowed file permissions for federated user + Given the administrator has enabled the permissions role "Secure Viewer" + And user "Alice" has uploaded file with content "ocm test" to "/textfile.txt" + When user "Alice" lists permissions with following filters for file "textfile.txt" of the space "Personal" using the Graph API: + | $filter=@libre.graph.permissions.roles.allowedValues/rolePermissions/any(p:contains(p/condition,+'@Subject.UserType=="Federated"')) | + | $select=@libre.graph.permissions.roles.allowedValue | + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "@libre.graph.permissions.roles.allowedValues" + ], + "properties": { + "@libre.graph.permissions.roles.allowedValues": { + "type": "array", + "minItems": 2, + "maxItems": 2, + "uniqueItems": true, + "items": { + "oneOf":[ + { + "type": "object", + "required": ["@libre.graph.weight","description","displayName","id"], + "properties": { + "@libre.graph.weight": {"const": 1}, + "description": {"const": "View and download."}, + "displayName": {"const": "Can view"}, + "id": {"const": "b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5"} + } + }, + { + "type": "object", + "required": ["@libre.graph.weight","description","displayName","id"], + "properties": { + "@libre.graph.weight": {"const": 2}, + "description": {"const": "View, download and edit."}, + "displayName": {"const": "Can edit"}, + "id": {"const": "2d00ce52-1fc2-4dbc-8b95-a73b73395f5a" } + } + } + ] + } + } + } + } + """ + + @issue-9745 @env-config + Scenario: user lists allowed folder permissions for federated user + Given the administrator has enabled the permissions role "Denied" + And user "Alice" has created folder "folderToShare" + When user "Alice" lists permissions with following filters for folder "folderToShare" of the space "Personal" using the Graph API: + | $filter=@libre.graph.permissions.roles.allowedValues/rolePermissions/any(p:contains(p/condition,+'@Subject.UserType=="Federated"')) | + | $select=@libre.graph.permissions.roles.allowedValue | + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "@libre.graph.permissions.roles.allowedValues" + ], + "properties": { + "@libre.graph.permissions.roles.allowedValues": { + "type": "array", + "minItems": 2, + "maxItems": 2, + "uniqueItems": true, + "items": { + "oneOf":[ + { + "type": "object", + "required": ["@libre.graph.weight","description","displayName","id"], + "properties": { + "@libre.graph.weight": {"const": 1}, + "description": {"const": "View and download."}, + "displayName": {"const": "Can view"}, + "id": {"const": "b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5"} + } + }, + { + "type": "object", + "required": ["@libre.graph.weight","description","displayName","id"], + "properties": { + "@libre.graph.weight": {"const": 2}, + "description": {"const": "View, download, upload, edit, add and delete."}, + "displayName": {"const": "Can edit"}, + "id": {"const": "fb6c3e19-e378-47e5-b277-9732f9de6e21"} + } + } + ] + } + } + } + } + """ + + @issue-9745 @env-config + Scenario: user lists allowed file permissions for federated user (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" + When user "Alice" lists permissions with following filters for file "textfile.txt" of the space "new-space" using the Graph API: + | $filter=@libre.graph.permissions.roles.allowedValues/rolePermissions/any(p:contains(p/condition,+'@Subject.UserType=="Federated"')) | + | $select=@libre.graph.permissions.roles.allowedValue | + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "@libre.graph.permissions.roles.allowedValues" + ], + "properties": { + "@libre.graph.permissions.roles.allowedValues": { + "type": "array", + "minItems": 2, + "maxItems": 2, + "uniqueItems": true, + "items": { + "oneOf":[ + { + "type": "object", + "required": ["@libre.graph.weight","description","displayName","id"], + "properties": { + "@libre.graph.weight": {"const": 1}, + "description": {"const": "View and download."}, + "displayName": {"const": "Can view"}, + "id": {"const": "b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5"} + } + }, + { + "type": "object", + "required": ["@libre.graph.weight","description","displayName","id"], + "properties": { + "@libre.graph.weight": {"const": 2}, + "description": {"const": "View, download and edit."}, + "displayName": {"const": "Can edit"}, + "id": {"const": "2d00ce52-1fc2-4dbc-8b95-a73b73395f5a"} + } + } + ] + } + } + } + } + """ + + @issue-9745 @env-config + Scenario: user lists allowed folder permissions for federated user (Project Space) + Given using spaces DAV path + And the administrator has enabled the permissions role "Denied" + 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 created a folder "folderToShare" in space "new-space" + When user "Alice" lists permissions with following filters for folder "folderToShare" of the space "new-space" using the Graph API: + | $filter=@libre.graph.permissions.roles.allowedValues/rolePermissions/any(p:contains(p/condition,+'@Subject.UserType=="Federated"')) | + | $select=@libre.graph.permissions.roles.allowedValue | + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "@libre.graph.permissions.roles.allowedValues" + ], + "properties": { + "@libre.graph.permissions.roles.allowedValues": { + "type": "array", + "minItems": 2, + "maxItems": 2, + "uniqueItems": true, + "items": { + "oneOf":[ + { + "type": "object", + "required": ["@libre.graph.weight","description","displayName","id"], + "properties": { + "@libre.graph.weight": {"const": 1}, + "description": {"const": "View and download."}, + "displayName": {"const": "Can view"}, + "id": {"const": "b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5"} + } + }, + { + "type": "object", + "required": ["@libre.graph.weight","description","displayName","id"], + "properties": { + "@libre.graph.weight": {"const": 2}, + "description": {"const": "View, download, upload, edit, add and delete."}, + "displayName": {"const": "Can edit"}, + "id": {"const": "fb6c3e19-e378-47e5-b277-9732f9de6e21"} + } + } + ] + } + } + } + } + """