Skip to content

Commit

Permalink
adding test for listing permission of a project space
Browse files Browse the repository at this point in the history
  • Loading branch information
nirajacharya2 committed Mar 4, 2024
1 parent d33935c commit f4f29e7
Show file tree
Hide file tree
Showing 2 changed files with 188 additions and 13 deletions.
146 changes: 146 additions & 0 deletions tests/acceptance/features/apiSharingNg/listPermissions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,149 @@ Feature: List a sharing permissions
}
}
"""


Scenario: user lists permissions of a project space
Given using spaces DAV path
And user "Brian" has been created with default attributes and without skeleton files
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
When user "Alice" lists the permissions of space "new-space" 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"
],
"properties": {
"@libre.graph.permissions.actions.allowedValues": {
"const": [
"libre.graph/driveItem/permissions/create",
"libre.graph/driveItem/children/create",
"libre.graph/driveItem/standard/delete",
"libre.graph/driveItem/path/read",
"libre.graph/driveItem/quota/read",
"libre.graph/driveItem/content/read",
"libre.graph/driveItem/upload/create",
"libre.graph/driveItem/permissions/read",
"libre.graph/driveItem/children/read",
"libre.graph/driveItem/versions/read",
"libre.graph/driveItem/deleted/read",
"libre.graph/driveItem/path/update",
"libre.graph/driveItem/permissions/delete",
"libre.graph/driveItem/deleted/delete",
"libre.graph/driveItem/versions/update",
"libre.graph/driveItem/deleted/update",
"libre.graph/driveItem/basic/read",
"libre.graph/driveItem/permissions/update",
"libre.graph/driveItem/permissions/deny"
]
},
"@libre.graph.permissions.roles.allowedValues": {
"type": "array",
"minItems": 4,
"maxItems": 4,
"uniqueItems": true,
"items": {
"oneOf": [
{
"type": "object",
"required": [
"@libre.graph.weight",
"description",
"displayName",
"id"
],
"properties": {
"@libre.graph.weight": {
"const": 1
},
"description": {
"const": "Allows reading the shared space"
},
"displayName": {
"const": "Space Viewer"
},
"id": {
"const": "a8d5fe5e-96e3-418d-825b-534dbdf22b99"
}
}
},
{
"type": "object",
"required": [
"@libre.graph.weight",
"description",
"displayName",
"id"
],
"properties": {
"@libre.graph.weight": {
"const": 2
},
"description": {
"const": "Allows creating, reading, updating and deleting file or folder in the shared space"
},
"displayName": {
"const": "Space Editor"
},
"id": {
"const": "58c63c02-1d89-4572-916a-870abc5a1b7d"
}
}
},
{
"type": "object",
"required": [
"@libre.graph.weight",
"description",
"displayName",
"id"
],
"properties": {
"@libre.graph.weight": {
"const": 3
},
"description": {
"const": "Grants co-owner permissions on a resource"
},
"displayName": {
"const": "Co Owner"
},
"id": {
"const": "3a4ba8e9-6a0d-4235-9140-0e7a34007abe"
}
}
},
{
"type": "object",
"required": [
"@libre.graph.weight",
"description",
"displayName",
"id"
],
"properties": {
"@libre.graph.weight": {
"const": 4
},
"description": {
"const": "Grants manager permissions on a resource. Semantically equivalent to co-owner"
},
"displayName": {
"const": "Manager"
},
"id": {
"const": "312c0871-5ef7-4b3a-85b6-0e4074c64049"
}
}
}
]
}
}
}
}
"""
55 changes: 42 additions & 13 deletions tests/acceptance/features/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,33 +92,62 @@ public function createLinkShare(string $user, TableNode $body): ResponseInterfac
}

/**
* @When /^user "([^"]*)" gets permissions list for (folder|file) "([^"]*)" of the space "([^"]*)" using the Graph API$/
*
* @param string $user
* @param string $fileOrFolder (file|folder)
* @param string $resource
* @param string $space
* @param string $resource
*
* @return void
* @return ResponseInterface
* @throws Exception
*/
public function theUserPermissionsListOfResource(string $user, string $fileOrFolder, string $resource, string $space):void {
public function getPermissionsList(string $user, string $fileOrFolder, string $space, string $resource = ''):ResponseInterface {
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];

if ($fileOrFolder === 'folder') {
$itemId = $this->spacesContext->getResourceId($user, $space, $resource);
} else {
$itemId = $this->spacesContext->getFileId($user, $space, $resource);
}

return GraphHelper::getPermissionsList(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$spaceId,
$itemId
);
}

/**
* @When /^user "([^"]*)" gets permissions list for (folder|file) "([^"]*)" of 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 userGetsPermissionsListForResourceOfTheSpaceUsingTheGraphiAPI(string $user, string $fileOrFolder, string $resource, string $space):void {
$this->featureContext->setResponse(
GraphHelper::getPermissionsList(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$spaceId,
$itemId
)
$this->getPermissionsList($user, $fileOrFolder, $space, $resource)
);
}

/**
* @When /^user "([^"]*)" lists the permissions of space "([^"]*)" using the Graph API$/
*
* @param string $user
* @param string $space
*
* @return void
* @throws Exception
*/
public function userListsThePermissionsOfSpaceUsingTheGraphApi($user, $space):void {
$this->featureContext->setResponse(
$this->getPermissionsList($user, 'folder', $space)
);
}

Expand Down

0 comments on commit f4f29e7

Please sign in to comment.