Skip to content

Commit a2fc304

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

File tree

4 files changed

+191
-0
lines changed

4 files changed

+191
-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 getSingleDrivePermissionList(
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: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,55 @@ public function userListsThePermissionsOfDriveUsingRootEndPointOFTheGraphApi(str
17291729
$this->featureContext->setResponse($response);
17301730
}
17311731

1732+
/**
1733+
* @When /^user "([^"]*)" lists the permission of space "([^"]*)" shared to 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 userListDrivePermissionViaRootEndpointGraphApi(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::getSingleDrivePermissionList(
1748+
$this->featureContext->getBaseUrl(),
1749+
$user,
1750+
$this->featureContext->getPasswordForUser($user),
1751+
$spaceId,
1752+
$permissionID
1753+
);
1754+
$this->featureContext->setResponse($response);
1755+
}
1756+
1757+
/**
1758+
* @When /^user "([^"]*)" lists the permission of the space "([^"]*)" shared via link using root endpoint the Graph API$/
1759+
*
1760+
* @param string $user
1761+
* @param string $space
1762+
*
1763+
* @return void
1764+
* @throws Exception
1765+
* @throws GuzzleException
1766+
*
1767+
*/
1768+
public function userListPermissionOfSpaceSharedViaLinkUsingRootEndpointGraphApi(string $user, string $space): void {
1769+
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
1770+
$permissionId = $this->featureContext->shareNgGetLastCreatedLinkShareID();
1771+
$response = GraphHelper::getSingleDrivePermissionList(
1772+
$this->featureContext->getBaseUrl(),
1773+
$user,
1774+
$this->featureContext->getPasswordForUser($user),
1775+
$spaceId,
1776+
$permissionId
1777+
);
1778+
$this->featureContext->setResponse($response);
1779+
}
1780+
17321781
/**
17331782
* @When /^user "([^"]*)" (?:tries to send|sends) the following space share invitation using root endpoint of the Graph API:$/
17341783
*

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,5 +393,15 @@ 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:2634](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2634)
398+
- [apiSharingNgPermissions/listPermissions.feature:2635](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2635)
399+
- [apiSharingNgPermissions/listPermissions.feature:2636](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2636)
400+
- [apiSharingNgPermissions/listPermissions.feature:2688](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2688)
401+
- [apiSharingNgPermissions/listPermissions.feature:2689](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2689)
402+
- [apiSharingNgPermissions/listPermissions.feature:2690](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2690)
403+
- [apiSharingNgPermissions/listPermissions.feature:2691](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2691)
404+
- [apiSharingNgPermissions/listPermissions.feature:2692](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2692)
405+
396406
Note: always have an empty line at the end of this file.
397407
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: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,3 +2580,109 @@ Feature: List a sharing permissions
25802580
}
25812581
}
25822582
"""
2583+
2584+
@issue-8616
2585+
Scenario Outline: sharer list single permission of a shared project space via invitation 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+
When user "Alice" lists the permission of space "new-space" shared to user "Brian" using root endpoint of the Graph API
2596+
Then the HTTP status code should be "200"
2597+
And the JSON data of the response should match
2598+
"""
2599+
{
2600+
"type": "object",
2601+
"required": ["id", "roles", "grantedToV2"],
2602+
"properties": {
2603+
"id": { "pattern": "^u:%user_id_pattern%$" },
2604+
"roles": {
2605+
"type": "array",
2606+
"minItems": 1,
2607+
"maxItems": 1,
2608+
"items": {"pattern": "^%role_id_pattern%$"}
2609+
},
2610+
"grantedToV2": {
2611+
"type": "object",
2612+
"required": ["user"],
2613+
"properties": {
2614+
"user": {
2615+
"type": "object",
2616+
"required": ["@libre.graph.userType", "displayName", "id"],
2617+
"properties": {
2618+
"@libre.graph.userType": {"const": "Member"},
2619+
"id": {"pattern": "^%user_id_pattern%$"},
2620+
"displayName": {"const": "Brian Murphy"}
2621+
}
2622+
}
2623+
}
2624+
}
2625+
}
2626+
}
2627+
"""
2628+
Examples:
2629+
| permissions-role |
2630+
| Space Viewer |
2631+
| Space Editor |
2632+
| Manager |
2633+
2634+
@issue-8616
2635+
Scenario Outline: sharer list single permission of a shared project space via link using root endpoint
2636+
Given using spaces DAV path
2637+
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
2638+
And user "Alice" has created a space "new-space" with the default quota using the Graph API
2639+
And user "Alice" has created the following space link share:
2640+
| space | new-space |
2641+
| permissionsRole | <permissions-role> |
2642+
| password | %public% |
2643+
When user "Alice" lists the permission of the space "Personal" shared via link using root endpoint the Graph API
2644+
Then the HTTP status code should be "200"
2645+
And the JSON data of the response should match
2646+
"""
2647+
{
2648+
"type": "object",
2649+
"required": ["createdDateTime", "hasPassword", "id", "link"],
2650+
"properties": {
2651+
"createdDateTime": {
2652+
"format": "date-time"
2653+
},
2654+
"hasPassword": { "const": true},
2655+
"id": {
2656+
"type": "string",
2657+
"pattern": "^[a-zA-Z]{15}$"
2658+
},
2659+
"link": {
2660+
"type": "object",
2661+
"required": [
2662+
"@libre.graph.displayName",
2663+
"@libre.graph.quickLink",
2664+
"preventsDownload",
2665+
"type",
2666+
"webUrl"
2667+
],
2668+
"properties": {
2669+
"@libre.graph.displayName": {"const": ""},
2670+
"@libre.graph.quickLink": {"const": false},
2671+
"preventsDownload": {"const": false},
2672+
"type": {"const": "<permissions-role-value>"},
2673+
"webUrl": {
2674+
"type": "string",
2675+
"pattern": "^%base_url%/s/[a-zA-Z]{15}$"
2676+
}
2677+
}
2678+
}
2679+
}
2680+
}
2681+
"""
2682+
Examples:
2683+
| permissions-role | permissions-role-value |
2684+
| View | view |
2685+
| Edit | edit |
2686+
| Upload | upload |
2687+
| File Drop | createOnly |
2688+
| Secure View | blocksDownload |

0 commit comments

Comments
 (0)