diff --git a/tests/acceptance/TestHelpers/GraphHelper.php b/tests/acceptance/TestHelpers/GraphHelper.php index 6488a3359c9..b6782fb0256 100644 --- a/tests/acceptance/TestHelpers/GraphHelper.php +++ b/tests/acceptance/TestHelpers/GraphHelper.php @@ -2059,6 +2059,32 @@ public static function getDrivePermissionsList( ); } + /** + * @param string $baseUrl + * @param string $user + * @param string $password + * @param string $spaceId + * @param string $permissionId + * + * @return ResponseInterface + * @throws GuzzleException + */ + public static function getSingleDrivePermission( + string $baseUrl, + string $user, + string $password, + string $spaceId, + string $permissionId + ): ResponseInterface { + $url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/root/permissions/$permissionId"); + return HttpRequestHelper::get( + $url, + $user, + $password, + self::getRequestHeaders() + ); + } + /** * @param string $baseUrl * @param string $user diff --git a/tests/acceptance/bootstrap/SharingNgContext.php b/tests/acceptance/bootstrap/SharingNgContext.php index d5963bc2542..54cf476e220 100644 --- a/tests/acceptance/bootstrap/SharingNgContext.php +++ b/tests/acceptance/bootstrap/SharingNgContext.php @@ -1766,6 +1766,58 @@ public function userListsThePermissionsOfDriveUsingRootEndPointOFTheGraphApi(str $this->featureContext->setResponse($response); } + /** + * @When /^user "([^"]*)" lists the permission of space "([^"]*)" shared to user "([^"]*)" using root endpoint of the Graph API$/ + * + * @param string $user + * @param string $space + * @param string $sharee + * + * @return void + * @throws Exception + * @throws GuzzleException + * + */ + public function userListDrivePermissionViaRootEndpointGraphApi(string $user, string $space, string $sharee): void { + $spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"]; + $permissionID = "u:" . $this->featureContext->getAttributeOfCreatedUser($sharee, 'id'); + $response = GraphHelper::getSingleDrivePermissionList( + $this->featureContext->getBaseUrl(), + $user, + $this->featureContext->getPasswordForUser($user), + $spaceId, + $permissionID + ); + $this->featureContext->setResponse($response); + } + + /** + * @When /^user "([^"]*)" lists the last link permission of space "([^"]*)" using root endpoint of the Graph API$/ + * + * @param string $user + * @param string $space + * + * @return void + * @throws Exception + * @throws GuzzleException + * + */ + public function userListsPermissionOfSpaceSharedViaLinkUsingRootEndpointGraphApi( + string $user, + string $space + ): void { + $spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"]; + $permissionId = $this->featureContext->shareNgGetLastCreatedLinkShareID(); + $response = GraphHelper::getSingleDrivePermission( + $this->featureContext->getBaseUrl(), + $user, + $this->featureContext->getPasswordForUser($user), + $spaceId, + $permissionId + ); + $this->featureContext->setResponse($response); + } + /** * @When /^user "([^"]*)" (?:tries to send|sends) the following space share invitation using root endpoint of the Graph API:$/ * diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index 2531a184151..52af6accf7e 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -396,6 +396,8 @@ The expected failures in this file are from features in the owncloud/ocis repo. ### [[Sharing NG] Implement https://owncloud.dev/libre-graph-api/#/drives.permissions/GetPermission](https://github.com/owncloud/ocis/issues/8616) - [apiSharingNgPermissions/listPermissions.feature:2585](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2585) - [apiSharingNgPermissions/listPermissions.feature:2631](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2631) +- [apiSharingNgPermissions/listPermissions.feature:2673](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2673) +- [apiSharingNgPermissions/listPermissions.feature:2718](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2718) Note: always have an empty line at the end of this file. The bash script that processes this file requires that the last line has a newline on the end. diff --git a/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature b/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature index 37ca2524d95..61822cc65e9 100644 --- a/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature +++ b/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature @@ -2668,3 +2668,91 @@ Feature: List a sharing permissions } } """ + + @issue-8616 + Scenario: sharer lists single membership permission of a project space using root endpoint + Given using spaces DAV path + And user "Brian" has been created with default attributes + 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 sent the following space share invitation: + | space | new-space | + | sharee | Brian | + | shareType | user | + | permissionsRole | Space Viewer | + When user "Alice" lists the permission of space "new-space" shared to user "Brian" using root endpoint of the Graph API + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": ["id", "roles", "grantedToV2"], + "properties": { + "id": { "pattern": "^u:%user_id_pattern%$" }, + "roles": { + "type": "array", + "minItems": 1, + "maxItems": 1, + "items": {"pattern": "^%role_id_pattern%$"} + }, + "grantedToV2": { + "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": "Brian Murphy"} + } + } + } + } + } + } + """ + + @issue-8616 + Scenario: sharer lists single link permission of a project space using root 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 "new-space" with the default quota using the Graph API + And user "Alice" has created the following space link share: + | space | new-space | + | permissionsRole | View | + | password | %public% | + When user "Alice" lists the last link permission of space "Personal" using root endpoint of the Graph API + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": ["createdDateTime", "hasPassword", "id", "link"], + "properties": { + "createdDateTime": { + "format": "date-time" + }, + "hasPassword": { "const": true}, + "id": {"pattern": "^[a-zA-Z]{15}$"}, + "link": { + "type": "object", + "required": [ + "@libre.graph.displayName", + "@libre.graph.quickLink", + "preventsDownload", + "type", + "webUrl" + ], + "properties": { + "@libre.graph.displayName": {"const": ""}, + "@libre.graph.quickLink": {"const": false}, + "preventsDownload": {"const": false}, + "type": {"const": "view"}, + "webUrl": {"pattern": "^%base_url%/s/[a-zA-Z]{15}$"} + } + } + } + } + """