Skip to content

Commit 4769c4b

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

File tree

4 files changed

+173
-0
lines changed

4 files changed

+173
-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 getSingleDrivePermission(
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 last link permission of the space "([^"]*)" using root endpoint of 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::getSingleDrivePermission(
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,5 +393,9 @@ 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:2585](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2585)
398+
- [apiSharingNgPermissions/listPermissions.feature:2630](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2630)
399+
396400
Note: always have an empty line at the end of this file.
397401
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: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,3 +2580,97 @@ Feature: List a sharing permissions
25802580
}
25812581
}
25822582
"""
2583+
2584+
@issue-8616
2585+
Scenario: sharer list single membership permission of a 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 | Space Viewer |
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+
2629+
@issue-8616
2630+
Scenario: sharer list single link permission of a project space using root endpoint
2631+
Given using spaces DAV path
2632+
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
2633+
And user "Alice" has created a space "new-space" with the default quota using the Graph API
2634+
And user "Alice" has created the following space link share:
2635+
| space | new-space |
2636+
| permissionsRole | View |
2637+
| password | %public% |
2638+
When user "Alice" lists the last link permission of the space "Personal" using root endpoint of the Graph API
2639+
Then the HTTP status code should be "200"
2640+
And the JSON data of the response should match
2641+
"""
2642+
{
2643+
"type": "object",
2644+
"required": ["createdDateTime", "hasPassword", "id", "link"],
2645+
"properties": {
2646+
"createdDateTime": {
2647+
"format": "date-time"
2648+
},
2649+
"hasPassword": { "const": true},
2650+
"id": {
2651+
"type": "string",
2652+
"pattern": "^[a-zA-Z]{15}$"
2653+
},
2654+
"link": {
2655+
"type": "object",
2656+
"required": [
2657+
"@libre.graph.displayName",
2658+
"@libre.graph.quickLink",
2659+
"preventsDownload",
2660+
"type",
2661+
"webUrl"
2662+
],
2663+
"properties": {
2664+
"@libre.graph.displayName": {"const": ""},
2665+
"@libre.graph.quickLink": {"const": false},
2666+
"preventsDownload": {"const": false},
2667+
"type": {"const": "view"},
2668+
"webUrl": {
2669+
"type": "string",
2670+
"pattern": "^%base_url%/s/[a-zA-Z]{15}$"
2671+
}
2672+
}
2673+
}
2674+
}
2675+
}
2676+
"""

0 commit comments

Comments
 (0)