Skip to content

Commit 9811825

Browse files
committed
tests: add test for list single permission
Signed-off-by: nabim777 <[email protected]>
1 parent e7147e2 commit 9811825

File tree

4 files changed

+153
-0
lines changed

4 files changed

+153
-0
lines changed

tests/acceptance/TestHelpers/GraphHelper.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,32 @@ public static function getDrivePermissionsList(
20302030
);
20312031
}
20322032

2033+
/**
2034+
* @param string $baseUrl
2035+
* @param string $user
2036+
* @param string $password
2037+
* @param string $spaceId
2038+
* @param string $permissionID
2039+
*
2040+
* @return ResponseInterface
2041+
* @throws GuzzleException
2042+
*/
2043+
public static function getDrivePermissionList(
2044+
string $baseUrl,
2045+
string $user,
2046+
string $password,
2047+
string $spaceId,
2048+
string $permissionID
2049+
): ResponseInterface {
2050+
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/root/permissions/$permissionID");
2051+
return HttpRequestHelper::get(
2052+
$url,
2053+
$user,
2054+
$password,
2055+
self::getRequestHeaders()
2056+
);
2057+
}
2058+
20332059
/**
20342060
* @param string $baseUrl
20352061
* @param string $user

tests/acceptance/bootstrap/SharingNgContext.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,31 @@ public function userListsThePermissionsOfDriveUsingRootEndPointOFTheGraphApi(str
17291729
$this->featureContext->setResponse($response);
17301730
}
17311731

1732+
/**
1733+
* @When /^user "([^"]*)" (?:tries to list|lists) the permission of space "([^"]*)" share for user "([^"]*)" using root endpoint of the Graph API$/
1734+
*
1735+
* @param string $user
1736+
* @param string $space
1737+
* @param string $sharee
1738+
*
1739+
* @return void
1740+
* @throws Exception
1741+
* @throws GuzzleException
1742+
*
1743+
*/
1744+
public function userListDrivPermissionViaRootEndpointOfGraphApi(string $user, string $space, string $sharee): void {
1745+
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
1746+
$permissionID = "u:" . $this->featureContext->getAttributeOfCreatedUser($sharee, 'id');
1747+
$response = GraphHelper::getDrivePermissionList(
1748+
$this->featureContext->getBaseUrl(),
1749+
$user,
1750+
$this->featureContext->getPasswordForUser($user),
1751+
$spaceId,
1752+
$permissionID
1753+
);
1754+
$this->featureContext->setResponse($response);
1755+
}
1756+
17321757
/**
17331758
* @When /^user "([^"]*)" (?:tries to send|sends) the following space share invitation using root endpoint of the Graph API:$/
17341759
*

tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,5 +393,11 @@ The expected failures in this file are from features in the owncloud/ocis repo.
393393
- [apiSharingNgShares/sharedWithMe.feature:5410](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgShares/sharedWithMe.feature#L5410)
394394
- [apiSharingNgShares/sharedWithMe.feature:5411](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgShares/sharedWithMe.feature#L5411)
395395

396+
### [[Sharing NG] Implement https://owncloud.dev/libre-graph-api/#/drives.permissions/GetPermission](https://github.com/owncloud/ocis/issues/8616)
397+
- [apiSharingNgPermissions/listPermissions.feature:2644](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2644)
398+
- [apiSharingNgPermissions/listPermissions.feature:2645](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2645)
399+
- [apiSharingNgPermissions/listPermissions.feature:2646](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2646)
400+
- [apiSharingNgPermissions/listPermissions.feature:2649](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2649)
401+
396402
Note: always have an empty line at the end of this file.
397403
The bash script that processes this file requires that the last line has a newline on the end.

tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,3 +2580,99 @@ Feature: List a sharing permissions
25802580
}
25812581
}
25822582
"""
2583+
2584+
@issue-8616
2585+
Scenario Outline: sharer list permission of a shared project space using root endpoint
2586+
Given using spaces DAV path
2587+
And user "Brian" has been created with default attributes
2588+
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
2589+
And user "Alice" has created a space "new-space" with the default quota using the Graph API
2590+
And user "Alice" has sent the following space share invitation:
2591+
| space | new-space |
2592+
| sharee | Brian |
2593+
| shareType | user |
2594+
| permissionsRole | <permissions-role> |
2595+
And user "Alice" has created the following space link share:
2596+
| space | new-space |
2597+
| permissionsRole | View |
2598+
| password | %public% |
2599+
When user "Alice" lists the permission of space "new-space" share for user "Brian" using root endpoint of the Graph API
2600+
Then the HTTP status code should be "200"
2601+
And the JSON data of the response should match
2602+
"""
2603+
{
2604+
"type": "object",
2605+
"required": ["id", "roles", "grantedToV2"],
2606+
"properties": {
2607+
"id": {
2608+
"type": "string",
2609+
"pattern": "^u:%user_id_pattern%$"
2610+
},
2611+
"roles": {
2612+
"type": "array",
2613+
"minItems": 1,
2614+
"maxItems": 1,
2615+
"items": {
2616+
"type": "string",
2617+
"pattern": "^%role_id_pattern%$"
2618+
}
2619+
},
2620+
"grantedToV2": {
2621+
"type": "object",
2622+
"required": ["user"],
2623+
"properties": {
2624+
"user": {
2625+
"type": "object",
2626+
"required": ["displayName", "id"],
2627+
"properties": {
2628+
"id": {
2629+
"type": "string",
2630+
"pattern": "^%user_id_pattern%$"
2631+
},
2632+
"displayName": {
2633+
"const": "Brian Murphy"
2634+
}
2635+
}
2636+
}
2637+
}
2638+
}
2639+
}
2640+
}
2641+
"""
2642+
Examples:
2643+
| permissions-role |
2644+
| Space Viewer |
2645+
| Space Editor |
2646+
| Manager |
2647+
2648+
@issue-8616
2649+
Scenario: user tries to list permission of a disabled project space using root endpoint
2650+
Given using spaces DAV path
2651+
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
2652+
And user "Alice" has created a space "new-space" with the default quota using the Graph API
2653+
And user "Alice" has disabled a space "new-space"
2654+
When user "Alice" tries to list the permission of space "new-space" share for user "Brian" using root endpoint of the Graph API
2655+
Then the HTTP status code should be "404"
2656+
And the JSON data of the response should match
2657+
"""
2658+
{
2659+
"type": "object",
2660+
"required": ["error"],
2661+
"properties": {
2662+
"error": {
2663+
"type": "object",
2664+
"required": ["code", "innererror", "message"],
2665+
"properties": {
2666+
"code": { "const": "itemNotFound" },
2667+
"innererror": {
2668+
"type": "object",
2669+
"required": ["date", "request-id"]
2670+
},
2671+
"message": {
2672+
"pattern": "stat: error: not found: %user_id_pattern%$"
2673+
}
2674+
}
2675+
}
2676+
}
2677+
}
2678+
"""

0 commit comments

Comments
 (0)