Skip to content

Commit 45343c6

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

File tree

4 files changed

+168
-0
lines changed

4 files changed

+168
-0
lines changed

tests/acceptance/TestHelpers/GraphHelper.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,6 +2059,32 @@ public static function getDrivePermissionsList(
20592059
);
20602060
}
20612061

2062+
/**
2063+
* @param string $baseUrl
2064+
* @param string $user
2065+
* @param string $password
2066+
* @param string $spaceId
2067+
* @param string $permissionId
2068+
*
2069+
* @return ResponseInterface
2070+
* @throws GuzzleException
2071+
*/
2072+
public static function getSingleDrivePermission(
2073+
string $baseUrl,
2074+
string $user,
2075+
string $password,
2076+
string $spaceId,
2077+
string $permissionId
2078+
): ResponseInterface {
2079+
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/root/permissions/$permissionId");
2080+
return HttpRequestHelper::get(
2081+
$url,
2082+
$user,
2083+
$password,
2084+
self::getRequestHeaders()
2085+
);
2086+
}
2087+
20622088
/**
20632089
* @param string $baseUrl
20642090
* @param string $user

tests/acceptance/bootstrap/SharingNgContext.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,58 @@ public function userListsThePermissionsOfDriveUsingRootEndPointOFTheGraphApi(str
17661766
$this->featureContext->setResponse($response);
17671767
}
17681768

1769+
/**
1770+
* @When /^user "([^"]*)" lists the permission of space "([^"]*)" shared to user "([^"]*)" using root endpoint of the Graph API$/
1771+
*
1772+
* @param string $user
1773+
* @param string $space
1774+
* @param string $sharee
1775+
*
1776+
* @return void
1777+
* @throws Exception
1778+
* @throws GuzzleException
1779+
*
1780+
*/
1781+
public function userListDrivePermissionViaRootEndpointGraphApi(string $user, string $space, string $sharee): void {
1782+
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
1783+
$permissionID = "u:" . $this->featureContext->getAttributeOfCreatedUser($sharee, 'id');
1784+
$response = GraphHelper::getSingleDrivePermissionList(
1785+
$this->featureContext->getBaseUrl(),
1786+
$user,
1787+
$this->featureContext->getPasswordForUser($user),
1788+
$spaceId,
1789+
$permissionID
1790+
);
1791+
$this->featureContext->setResponse($response);
1792+
}
1793+
1794+
/**
1795+
* @When /^user "([^"]*)" lists the last link permission of space "([^"]*)" using root endpoint of the Graph API$/
1796+
*
1797+
* @param string $user
1798+
* @param string $space
1799+
*
1800+
* @return void
1801+
* @throws Exception
1802+
* @throws GuzzleException
1803+
*
1804+
*/
1805+
public function userListsPermissionOfSpaceSharedViaLinkUsingRootEndpointGraphApi(
1806+
string $user,
1807+
string $space
1808+
): void {
1809+
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
1810+
$permissionId = $this->featureContext->shareNgGetLastCreatedLinkShareID();
1811+
$response = GraphHelper::getSingleDrivePermission(
1812+
$this->featureContext->getBaseUrl(),
1813+
$user,
1814+
$this->featureContext->getPasswordForUser($user),
1815+
$spaceId,
1816+
$permissionId
1817+
);
1818+
$this->featureContext->setResponse($response);
1819+
}
1820+
17691821
/**
17701822
* @When /^user "([^"]*)" (?:tries to send|sends) the following space share invitation using root endpoint of the Graph API:$/
17711823
*

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ The expected failures in this file are from features in the owncloud/ocis repo.
396396
### [[Sharing NG] Implement https://owncloud.dev/libre-graph-api/#/drives.permissions/GetPermission](https://github.com/owncloud/ocis/issues/8616)
397397
- [apiSharingNgPermissions/listPermissions.feature:2585](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2585)
398398
- [apiSharingNgPermissions/listPermissions.feature:2631](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2631)
399+
- [apiSharingNgPermissions/listPermissions.feature:2673](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2673)
400+
- [apiSharingNgPermissions/listPermissions.feature:2718](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgPermissions/listPermissions.feature#L2718)
399401

400402
Note: always have an empty line at the end of this file.
401403
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: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2668,3 +2668,91 @@ Feature: List a sharing permissions
26682668
}
26692669
}
26702670
"""
2671+
2672+
@issue-8616
2673+
Scenario: sharer lists single membership permission of a project space using root endpoint
2674+
Given using spaces DAV path
2675+
And user "Brian" has been created with default attributes
2676+
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
2677+
And user "Alice" has created a space "new-space" with the default quota using the Graph API
2678+
And user "Alice" has sent the following space share invitation:
2679+
| space | new-space |
2680+
| sharee | Brian |
2681+
| shareType | user |
2682+
| permissionsRole | Space Viewer |
2683+
When user "Alice" lists the permission of space "new-space" shared to user "Brian" using root endpoint of the Graph API
2684+
Then the HTTP status code should be "200"
2685+
And the JSON data of the response should match
2686+
"""
2687+
{
2688+
"type": "object",
2689+
"required": ["id", "roles", "grantedToV2"],
2690+
"properties": {
2691+
"id": { "pattern": "^u:%user_id_pattern%$" },
2692+
"roles": {
2693+
"type": "array",
2694+
"minItems": 1,
2695+
"maxItems": 1,
2696+
"items": {"pattern": "^%role_id_pattern%$"}
2697+
},
2698+
"grantedToV2": {
2699+
"type": "object",
2700+
"required": ["user"],
2701+
"properties": {
2702+
"user": {
2703+
"type": "object",
2704+
"required": ["@libre.graph.userType", "displayName", "id"],
2705+
"properties": {
2706+
"@libre.graph.userType": {"const": "Member"},
2707+
"id": {"pattern": "^%user_id_pattern%$"},
2708+
"displayName": {"const": "Brian Murphy"}
2709+
}
2710+
}
2711+
}
2712+
}
2713+
}
2714+
}
2715+
"""
2716+
2717+
@issue-8616
2718+
Scenario: sharer lists single link permission of a project space using root endpoint
2719+
Given using spaces DAV path
2720+
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
2721+
And user "Alice" has created a space "new-space" with the default quota using the Graph API
2722+
And user "Alice" has created the following space link share:
2723+
| space | new-space |
2724+
| permissionsRole | View |
2725+
| password | %public% |
2726+
When user "Alice" lists the last link permission of space "Personal" using root endpoint of the Graph API
2727+
Then the HTTP status code should be "200"
2728+
And the JSON data of the response should match
2729+
"""
2730+
{
2731+
"type": "object",
2732+
"required": ["createdDateTime", "hasPassword", "id", "link"],
2733+
"properties": {
2734+
"createdDateTime": {
2735+
"format": "date-time"
2736+
},
2737+
"hasPassword": { "const": true},
2738+
"id": {"pattern": "^[a-zA-Z]{15}$"},
2739+
"link": {
2740+
"type": "object",
2741+
"required": [
2742+
"@libre.graph.displayName",
2743+
"@libre.graph.quickLink",
2744+
"preventsDownload",
2745+
"type",
2746+
"webUrl"
2747+
],
2748+
"properties": {
2749+
"@libre.graph.displayName": {"const": ""},
2750+
"@libre.graph.quickLink": {"const": false},
2751+
"preventsDownload": {"const": false},
2752+
"type": {"const": "view"},
2753+
"webUrl": {"pattern": "^%base_url%/s/[a-zA-Z]{15}$"}
2754+
}
2755+
}
2756+
}
2757+
}
2758+
"""

0 commit comments

Comments
 (0)