mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-23 05:18:40 -05:00
apiTest: listPermissions (#7946)
* apiTest: listPermissions * fix after review * fix
This commit is contained in:
@@ -77,6 +77,7 @@ config = {
|
||||
"apiSpacesDavOperation",
|
||||
"apiDepthInfinity",
|
||||
"apiLocks",
|
||||
"apiSharingNg",
|
||||
],
|
||||
"skip": False,
|
||||
},
|
||||
|
||||
@@ -97,6 +97,17 @@ class GraphHelper {
|
||||
return $fullUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $baseUrl
|
||||
* @param string $path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getBetaFullUrl(string $baseUrl, string $path): string {
|
||||
$baseUrl = rtrim($baseUrl, "/");
|
||||
return $baseUrl . '/graph/v1beta1/' . $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $baseUrl
|
||||
* @param string $xRequestId
|
||||
@@ -1492,4 +1503,33 @@ class GraphHelper {
|
||||
$payload['preferredLanguage'] = $language;
|
||||
return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, 'PATCH', $user, $password, null, \json_encode($payload));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $baseUrl
|
||||
* @param string $xRequestId
|
||||
* @param string $user
|
||||
* @param string $password
|
||||
* @param string $spaceId
|
||||
* @param string $itemId
|
||||
*
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public static function getPermissionsList(
|
||||
string $baseUrl,
|
||||
string $xRequestId,
|
||||
string $user,
|
||||
string $password,
|
||||
string $spaceId,
|
||||
string $itemId
|
||||
): ResponseInterface {
|
||||
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/items/$itemId/permissions");
|
||||
return HttpRequestHelper::get(
|
||||
$url,
|
||||
$xRequestId,
|
||||
$user,
|
||||
$password,
|
||||
self::getRequestHeaders()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,6 +253,15 @@ default:
|
||||
- WebDavLockingContext:
|
||||
- PublicWebDavContext:
|
||||
|
||||
apiSharingNg:
|
||||
paths:
|
||||
- '%paths.base%/../features/apiSharingNg'
|
||||
context: *common_ldap_suite_context
|
||||
contexts:
|
||||
- FeatureContext: *common_feature_context_params
|
||||
- SpacesContext:
|
||||
- SharingNgContext:
|
||||
|
||||
extensions:
|
||||
rdx\behatvars\BehatVariablesExtension: ~
|
||||
|
||||
|
||||
@@ -0,0 +1,269 @@
|
||||
Feature: List a sharing permissions
|
||||
https://owncloud.dev/libre-graph-api/#/drives.permissions/ListPermissions
|
||||
|
||||
Background:
|
||||
Given these users have been created with default attributes and without skeleton files:
|
||||
| username |
|
||||
| Alice |
|
||||
|
||||
|
||||
Scenario: user lists permissions via the Graph API
|
||||
Given user "Alice" has created folder "folder"
|
||||
When user "Alice" gets permissions list for folder "folder" 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"
|
||||
],
|
||||
"properties": {
|
||||
"@libre.graph.permissions.actions.allowedValues": {
|
||||
"type": "array",
|
||||
"items": [
|
||||
{
|
||||
"type": "string",
|
||||
"required": [
|
||||
"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",
|
||||
"items": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"@libre.graph.weight",
|
||||
"description",
|
||||
"displayName",
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"@libre.graph.weight": {
|
||||
"type": "integer",
|
||||
"enum": [
|
||||
1
|
||||
]
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Allows upload file or folder"
|
||||
]
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Uploader"
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"1c996275-f1c9-4e71-abdf-a42f6495e960"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"@libre.graph.weight",
|
||||
"description",
|
||||
"displayName",
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"@libre.graph.weight": {
|
||||
"type": "integer",
|
||||
"enum": [
|
||||
2
|
||||
]
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Allows reading the shared file or folder"
|
||||
]
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Viewer"
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"@libre.graph.weight",
|
||||
"description",
|
||||
"displayName",
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"@libre.graph.weight": {
|
||||
"type": "integer",
|
||||
"enum": [
|
||||
3
|
||||
]
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Allows reading and updating file"
|
||||
]
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Editor"
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"2d00ce52-1fc2-4dbc-8b95-a73b73395f5a"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"@libre.graph.weight",
|
||||
"description",
|
||||
"displayName",
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"@libre.graph.weight": {
|
||||
"type": "integer",
|
||||
"enum": [
|
||||
4
|
||||
]
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Allows creating, reading, updating and deleting the shared file or folder"
|
||||
]
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Editor"
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"fb6c3e19-e378-47e5-b277-9732f9de6e21"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"@libre.graph.weight",
|
||||
"description",
|
||||
"displayName",
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"@libre.graph.weight": {
|
||||
"type": "integer",
|
||||
"enum": [
|
||||
5
|
||||
]
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Grants co-owner permissions on a resource"
|
||||
]
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Co Owner"
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"3a4ba8e9-6a0d-4235-9140-0e7a34007abe"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"@libre.graph.weight",
|
||||
"description",
|
||||
"displayName",
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"@libre.graph.weight": {
|
||||
"type": "integer",
|
||||
"enum": [
|
||||
6
|
||||
]
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Grants manager permissions on a resource. Semantically equivalent to co-owner"
|
||||
]
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Manager"
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"312c0871-5ef7-4b3a-85b6-0e4074c64049"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* @author Viktor Scharf <scharf.vi@gmail.com>
|
||||
*
|
||||
* @copyright Copyright (c) 2023, ownCloud GmbH
|
||||
* @license AGPL-3.0
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License, version 3,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
|
||||
use TestHelpers\GraphHelper;
|
||||
|
||||
require_once 'bootstrap.php';
|
||||
|
||||
/**
|
||||
* Acceptance test steps related to testing sharing ng features
|
||||
*/
|
||||
class SharingNgContext implements Context {
|
||||
private FeatureContext $featureContext;
|
||||
private SpacesContext $spacesContext;
|
||||
|
||||
/**
|
||||
* This will run before EVERY scenario.
|
||||
* It will set the properties for this object.
|
||||
*
|
||||
* @BeforeScenario
|
||||
*
|
||||
* @param BeforeScenarioScope $scope
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function before(BeforeScenarioScope $scope): void {
|
||||
// Get the environment
|
||||
$environment = $scope->getEnvironment();
|
||||
// Get all the contexts you need in this context from here
|
||||
$this->featureContext = $environment->getContext('FeatureContext');
|
||||
$this->spacesContext = $environment->getContext('SpacesContext');
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 theUserPermissionsListOfResource(string $user, string $fileOrFolder, string $resource, string $space):void {
|
||||
$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);
|
||||
}
|
||||
$this->featureContext->setResponse(
|
||||
GraphHelper::getPermissionsList(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
$spaceId,
|
||||
$itemId
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user