1
0
mirror of https://github.com/owncloud/ocis.git synced 2025-04-18 23:44:07 +03:00

add tests for list permissions using root endpoint (#8824)

This commit is contained in:
Amrita 2024-04-18 15:17:51 +05:45 committed by GitHub
parent 65213abcb4
commit da656cb8f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 232 additions and 14 deletions

View File

@ -1983,4 +1983,31 @@ class GraphHelper {
\json_encode($body)
);
}
/**
* @param string $baseUrl
* @param string $xRequestId
* @param string $user
* @param string $password
* @param string $spaceId
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function getDrivePermissionsList(
string $baseUrl,
string $xRequestId,
string $user,
string $password,
string $spaceId
): ResponseInterface {
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/root/permissions");
return HttpRequestHelper::get(
$url,
$xRequestId,
$user,
$password,
self::getRequestHeaders()
);
}
}

View File

@ -913,3 +913,169 @@ Feature: List a sharing permissions
| space | Personal |
| sharee | Brian |
| shareType | user |
@issues-8351
Scenario: user lists permissions 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
When user "Alice" lists the permissions of space "new-space" 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": [
"@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": 3,
"maxItems": 3,
"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": "a8d5fe5e-96e3-418d-825b-534dbdf22b99"
}
}
},
{
"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": "58c63c02-1d89-4572-916a-870abc5a1b7d"
}
}
},
{
"type": "object",
"required": [
"@libre.graph.weight",
"description",
"displayName",
"id"
],
"properties": {
"@libre.graph.weight": {
"const": 3
},
"description": {
"const": "View, download, upload, edit, add, delete and manage members."
},
"displayName": {
"const": "Can manage"
},
"id": {
"const": "312c0871-5ef7-4b3a-85b6-0e4074c64049"
}
}
}
]
}
}
}
}
"""
Scenario Outline: try to lists the permissions of a Personal/Shares drive 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
When user "Alice" tries to list the permissions of space "<drive>" using root endpoint of the Graph API
Then the HTTP status code should be "400"
And the JSON data of the response should match
"""
{
"type": "object",
"required": ["error"],
"properties": {
"error": {
"type": "object",
"required": [
"code",
"innererror",
"message"
],
"properties": {
"code": {
"const": "invalidRequest"
},
"innererror": {
"type": "object",
"required": [
"date",
"request-id"
]
},
"message": {
"const": "unsupported space type"
}
}
}
}
}
"""
Examples:
| drive |
| Personal |
| Shares |

View File

@ -19,7 +19,7 @@ Feature: an user gets the resources shared to them
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| permissionsRole | Viewer |
When user "Brian" lists the shares shared with him after clearing user cache using the Graph API
Then the HTTP status code should be "200"
And the JSON data of the response should match
@ -3540,7 +3540,7 @@ Feature: an user gets the resources shared to them
}
"""
@issue-8027
Scenario: user lists the file shared with them from project space
Given using spaces DAV path
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API

View File

@ -21,6 +21,7 @@
use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;
use TestHelpers\GraphHelper;
use TestHelpers\WebDavHelper;
@ -60,7 +61,7 @@ class SharingNgContext implements Context {
*
* @return ResponseInterface
* @throws Exception
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function createLinkShare(string $user, TableNode $body): ResponseInterface {
$bodyRows = $body->getRowsHash();
@ -159,7 +160,7 @@ class SharingNgContext implements Context {
* @return ResponseInterface
*
* @throws JsonException
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
* @throws Exception
*/
public function sendShareInvitation(string $user, TableNode $table, string $fileId = null): ResponseInterface {
@ -230,7 +231,7 @@ class SharingNgContext implements Context {
*
* @return void
* @throws Exception
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function userHasSentTheFollowingShareInvitation(string $user, TableNode $table): void {
$response = $this->sendShareInvitation($user, $table);
@ -247,7 +248,7 @@ class SharingNgContext implements Context {
*
* @return void
* @throws Exception
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function userSendsTheFollowingShareInvitationUsingTheGraphApi(string $user, TableNode $table): void {
$this->featureContext->setResponse(
@ -319,7 +320,7 @@ class SharingNgContext implements Context {
*
* @return void
* @throws JsonException
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function userSendsTheFollowingShareInvitationWithFileIdUsingTheGraphApi(string $user, string $fileId, TableNode $table): void {
$this->featureContext->setResponse(
@ -334,7 +335,7 @@ class SharingNgContext implements Context {
* @param TableNode|null $body
*
* @return void
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function userCreatesAPublicLinkShareWithSettings(string $user, TableNode $body):void {
$response = $this->createLinkShare($user, $body);
@ -348,7 +349,7 @@ class SharingNgContext implements Context {
* @param TableNode|null $body
*
* @return void
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function userHasCreatedTheFollowingLinkShare(string $user, TableNode $body): void {
$response = $this->createLinkShare($user, $body);
@ -418,7 +419,7 @@ class SharingNgContext implements Context {
*
* @return void
* @throws Exception
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function userSetsOrUpdatesFollowingPasswordForLastLinkShareUsingTheGraphApi(string $user, TableNode $body):void {
$bodyRows = $body->getRowsHash();
@ -495,7 +496,7 @@ class SharingNgContext implements Context {
*
* @return void
* @throws JsonException
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function userRemovesSharePermissionOfUserFromResourceOfSpaceUsingGraphAPI(
string $sharer,
@ -519,7 +520,7 @@ class SharingNgContext implements Context {
*
* @return void
* @throws JsonException
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function userRemovesSharePermissionOfUserFromSpaceUsingGraphAPI(
string $sharer,
@ -641,7 +642,7 @@ class SharingNgContext implements Context {
* @param string $resource
*
* @return void
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function userShouldHaveSyncEnabledOrDisabledForShare(string $user, string $status, string $resource):void {
$response = GraphHelper::getSharesSharedWithMe(
@ -676,7 +677,7 @@ class SharingNgContext implements Context {
*
* @return void
* @throws Exception
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function userShouldBeAbleToSendShareInvitationWithAllAllowedPermissionRoles(string $user, TableNode $table): void {
$listPermissionResponse = $this->featureContext->getJsonDecodedResponseBodyContent();
@ -714,4 +715,28 @@ class SharingNgContext implements Context {
}
Assert::assertTrue($areAllSendInvitationSuccessFullForAllowedRoles, $shareInvitationRequestResult);
}
/**
* @When /^user "([^"]*)" (?:tries to list|lists) the permissions of space "([^"]*)" using root endpoint of the Graph API$/
*
* @param string $user
* @param string $space
*
* @return void
* @throws Exception
* @throws GuzzleException
*
*/
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);
}
}