apiTest. select option for root/permissions endpoint (#942)

This commit is contained in:
Viktor Scharf
2025-06-06 08:14:05 +02:00
committed by GitHub
parent d827766133
commit b11cd0def3
3 changed files with 289 additions and 32 deletions
+7 -1
View File
@@ -2168,6 +2168,7 @@ class GraphHelper {
* @param string $user
* @param string $password
* @param string $spaceId
* @param string|null $query
*
* @return ResponseInterface
* @throws GuzzleException
@@ -2177,9 +2178,14 @@ class GraphHelper {
string $xRequestId,
string $user,
string $password,
string $spaceId
string $spaceId,
?string $query = null
): ResponseInterface {
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/root/permissions");
if ($query !== null) {
$url .= "?$query";
}
return HttpRequestHelper::get(
$url,
$xRequestId,
+106 -30
View File
@@ -181,6 +181,37 @@ class SharingNgContext implements Context {
);
}
/**
* @param string $user
* @param string $space
* @param string|null $query
* @param string|null $spaceOwner
*
* @return ResponseInterface
* @throws GuzzleException
*/
private function getDrivePermissionsList(
string $user,
string $space,
?string $query = null,
?string $spaceOwner = null,
): ResponseInterface {
if ($spaceOwner) {
$spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"];
} else {
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
}
return GraphHelper::getDrivePermissionsList(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$spaceId,
$query
);
}
/**
* @When /^user "([^"]*)" gets permissions list for (folder|file) "([^"]*)" of the space "([^"]*)" using the Graph API$/
*
@@ -265,7 +296,7 @@ class SharingNgContext implements Context {
public function sendShareInvitation(
string $user,
array $shareInfo,
string $fileId = null,
?string $fileId = null,
bool $federatedShare = false
): ResponseInterface {
if ($shareInfo['space'] === 'Personal' || $shareInfo['space'] === 'Shares') {
@@ -1576,16 +1607,7 @@ class SharingNgContext implements Context {
*
*/
public function userListsThePermissionsOfDriveUsingRootEndPointOFTheGraphApi(string $user, string $space): void {
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
$response = GraphHelper::getDrivePermissionsList(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$spaceId
);
$this->featureContext->setResponse($response);
$this->featureContext->setResponse($this->getDrivePermissionsList($user, $space));
}
/**
@@ -1771,15 +1793,7 @@ class SharingNgContext implements Context {
* @throws GuzzleException
*/
public function userShouldNotHaveAnyPermissionsOnSpace(string $user, string $shareType, string $space): void {
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
$response = GraphHelper::getDrivePermissionsList(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$spaceId
);
$response = $this->getDrivePermissionsList($user, $space);
$responseBody = $this->featureContext->getJsonDecodedResponse($response);
foreach ($responseBody['value'] as $value) {
switch ($shareType) {
@@ -1878,16 +1892,7 @@ class SharingNgContext implements Context {
string $space,
string $spaceOwner
): void {
$spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"];
$response = GraphHelper::getDrivePermissionsList(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$spaceId
);
$this->featureContext->setResponse($response);
$this->featureContext->setResponse($this->getDrivePermissionsList($user, $space, null, $spaceOwner));
}
/**
@@ -2118,4 +2123,75 @@ class SharingNgContext implements Context {
$this->getPermissionsList($user, $fileOrFolder, $space, $resource, $query)
);
}
/**
* @When /^user "([^"]*)" gets the permittion list of (folder|file) "([^"]*)" from the space "([^"]*)" using the Graph API with query "([^"]*)"$/
*
* @param string $user
* @param string $fileOrFolder (file|folder)
* @param string $resource
* @param string $space
* @param string $query
*
* @return void
* @throws Exception
*/
public function userGetsPermissionsListWithQueryForFileOfTheSpaceUsingTheGraphApi(
string $user,
string $fileOrFolder,
string $resource,
string $space,
string $query
): void {
$this->featureContext->setResponse(
$this->getPermissionsList($user, $fileOrFolder, $space, $resource, $query)
);
}
/**
* @When /^user "([^"]*)" gets the drive permittion list of the space "([^"]*)" using the Graph API with query "([^"]*)"$/
*
* @param string $user
* @param string $space
* @param string $query
*
* @return void
* @throws Exception
*/
public function userGetsDrivePermissionsListWithQueryUsingTheGraphApi(
string $user,
string $space,
string $query
): void {
$this->featureContext->setResponse($this->getDrivePermissionsList($user, $space, $query));
}
/**
* @Then /^the JSON data of the response should (not |)contain the following keys:$/
*
* @param string|null $shouldOrNot (not| )
* @param TableNode $table
*
* @return void
* @throws Exception
*/
public function theJsonDataResponseShouldOrNotContainData(string $shouldOrNot, TableNode $table): void {
$response = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse());
foreach ($table->getColumn(0) as $key) {
$keyExists = \array_key_exists($key, $response);
if (\trim($shouldOrNot) !== "not") {
Assert::assertTrue(
$keyExists,
"Expected key '$key' to exist in the JSON response, but it doesn't."
);
} else {
Assert::assertFalse(
$keyExists,
"Key '$key' should not exist in the JSON response, but it does."
);
}
}
}
}
@@ -2250,7 +2250,7 @@ Feature: List a sharing permissions
}
"""
@env-config
Scenario: user lists permissions of a space after enabling 'Space Editor Without Versions' role
Given 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
@@ -2567,3 +2567,178 @@ Feature: List a sharing permissions
}
}
"""
Scenario: user lists permissions of a folder in personal space with select filter
Given user "Brian" has been created with default attributes
And user "Alice" has created folder "folder"
And user "Alice" has sent the following resource share invitation:
| resource | folder |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
When user "Alice" gets the permittion list of folder "folder" from the space "Personal" using the Graph API with query "$select=@libre.graph.permissions.roles.allowedValues"
Then the HTTP status code should be "200"
And the JSON data of the response should contain the following keys:
| @libre.graph.permissions.roles.allowedValues |
And the JSON data of the response should not contain the following keys:
| @libre.graph.permissions.actions.allowedValues |
| value |
When user "Alice" gets the permittion list of folder "folder" from the space "Personal" using the Graph API with query "$select=@libre.graph.permissions.actions.allowedValues"
Then the HTTP status code should be "200"
And the JSON data of the response should contain the following keys:
| @libre.graph.permissions.actions.allowedValues |
And the JSON data of the response should not contain the following keys:
| @libre.graph.permissions.roles.allowedValues |
| value |
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"@libre.graph.permissions.actions.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"
]
}
}
}
"""
Scenario: user lists permissions of a project space with select filter
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" gets the drive permittion list of the space "new-space" using the Graph API with query "$select=@libre.graph.permissions.actions.allowedValues"
Then the HTTP status code should be "200"
And the JSON data of the response should contain the following keys:
| @libre.graph.permissions.actions.allowedValues |
And the JSON data of the response should not contain the following keys:
| @libre.graph.permissions.roles.allowedValues |
| value |
When user "Alice" gets the drive permittion list of the space "new-space" using the Graph API with query "$select=@libre.graph.permissions.roles.allowedValues"
Then the HTTP status code should be "200"
And the JSON data of the response should contain the following keys:
| @libre.graph.permissions.roles.allowedValues |
And the JSON data of the response should not contain the following keys:
| @libre.graph.permissions.actions.allowedValues |
| value |
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": 3,
"maxItems": 3,
"uniqueItems": true,
"items": {
"oneOf": [
{
"type": "object",
"required": [
"@libre.graph.weight",
"description",
"displayName",
"id"
],
"properties": {
"@libre.graph.weight": {
"const": 40
},
"description": {
"const": "View and download."
},
"displayName": {
"const": "Can view"
},
"id": {
"const": "a8d5fe5e-96e3-418d-825b-534dbdf22b99"
}
}
},
{
"type": "object",
"required": [
"@libre.graph.weight",
"description",
"displayName",
"id"
],
"properties": {
"@libre.graph.weight": {
"const": 90
},
"description": {
"const": "View, download, upload, edit, add, delete including the history."
},
"displayName": {
"const": "Can edit"
},
"id": {
"const": "58c63c02-1d89-4572-916a-870abc5a1b7d"
}
}
},
{
"type": "object",
"required": [
"@libre.graph.weight",
"description",
"displayName",
"id"
],
"properties": {
"@libre.graph.weight": {
"const": 120
},
"description": {
"const": "View, download, upload, edit, add, delete and manage members."
},
"displayName": {
"const": "Can manage"
},
"id": {
"const": "312c0871-5ef7-4b3a-85b6-0e4074c64049"
}
}
}
]
}
}
}
}
"""