Skip to content

Commit dc06b91

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

File tree

5 files changed

+196
-0
lines changed

5 files changed

+196
-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/FeatureContext.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,7 @@ public function getJSONSchema($schemaString) {
15771577
*/
15781578
public function getJsonDecodedResponseBodyContent(ResponseInterface $response = null): mixed {
15791579
$response = $response ?? $this->response;
1580+
var_dump($response->getBody()->getContents());
15801581
$response->getBody()->rewind();
15811582
return HttpRequestHelper::getJsonDecodedResponseBodyContent($response);
15821583
}

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: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,3 +2580,113 @@ Feature: List a sharing permissions
25802580
}
25812581
}
25822582
"""
2583+
2584+
@issue-8616
2585+
Scenario Outline: sharer list single 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" shared to 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": { "pattern": "^u:%user_id_pattern%$" },
2608+
"roles": {
2609+
"type": "array",
2610+
"minItems": 1,
2611+
"maxItems": 1,
2612+
"items": {"pattern": "^%role_id_pattern%$"}
2613+
},
2614+
"grantedToV2": {
2615+
"type": "object",
2616+
"required": ["user"],
2617+
"properties": {
2618+
"user": {
2619+
"type": "object",
2620+
"required": ["@libre.graph.userType", "displayName", "id"],
2621+
"properties": {
2622+
"@libre.graph.userType": {"const": "Member"},
2623+
"id": {"pattern": "^%user_id_pattern%$"},
2624+
"displayName": {"const": "Brian Murphy"}
2625+
}
2626+
}
2627+
}
2628+
}
2629+
}
2630+
}
2631+
"""
2632+
Examples:
2633+
| permissions-role |
2634+
| Space Viewer |
2635+
| Space Editor |
2636+
| Manager |
2637+
2638+
@issue-8616
2639+
Scenario Outline: sharer list single permission of a shared project space via link using root endpoint
2640+
Given using spaces DAV path
2641+
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
2642+
And user "Alice" has created a space "new-space" with the default quota using the Graph API
2643+
And user "Alice" has created the following space link share:
2644+
| space | new-space |
2645+
| permissionsRole | <permissions-role> |
2646+
| password | %public% |
2647+
When user "Alice" lists the permission of the space "Personal" shared via link using root endpoint the Graph API
2648+
Then the HTTP status code should be "200"
2649+
And the JSON data of the response should match
2650+
"""
2651+
{
2652+
"type": "object",
2653+
"required": ["createdDateTime", "hasPassword", "id", "link"],
2654+
"properties": {
2655+
"createdDateTime": {
2656+
"format": "date-time"
2657+
},
2658+
"hasPassword": { "const": true},
2659+
"id": {
2660+
"type": "string",
2661+
"pattern": "^[a-zA-Z]{15}$"
2662+
},
2663+
"link": {
2664+
"type": "object",
2665+
"required": [
2666+
"@libre.graph.displayName",
2667+
"@libre.graph.quickLink",
2668+
"preventsDownload",
2669+
"type",
2670+
"webUrl"
2671+
],
2672+
"properties": {
2673+
"@libre.graph.displayName": {"const": ""},
2674+
"@libre.graph.quickLink": {"const": false},
2675+
"preventsDownload": {"const": false},
2676+
"type": {"const": "<permissions-role-value>"},
2677+
"webUrl": {
2678+
"type": "string",
2679+
"pattern": "^%base_url%/s/[a-zA-Z]{15}$"
2680+
}
2681+
}
2682+
}
2683+
}
2684+
}
2685+
"""
2686+
Examples:
2687+
| permissions-role | permissions-role-value |
2688+
| View | view |
2689+
| Edit | edit |
2690+
| Upload | upload |
2691+
| File Drop | createOnly |
2692+
| Secure View | blocksDownload |

0 commit comments

Comments
 (0)