Skip to content

Commit 0c9a5b4

Browse files
authored
Merge pull request #10810 from owncloud/add-list-permission-with-query
[tests-only][full-ci]Add list permission tests with query dedicated to ocm
2 parents 9881496 + c652cbc commit 0c9a5b4

File tree

6 files changed

+404
-263
lines changed

6 files changed

+404
-263
lines changed

tests/acceptance/TestHelpers/GraphHelper.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,7 @@ public static function switchSystemLanguage(
17001700
* @param string $password
17011701
* @param string $spaceId
17021702
* @param string $itemId
1703+
* @param string|null $query
17031704
*
17041705
* @return ResponseInterface
17051706
* @throws GuzzleException
@@ -1710,9 +1711,14 @@ public static function getPermissionsList(
17101711
string $user,
17111712
string $password,
17121713
string $spaceId,
1713-
string $itemId
1714+
string $itemId,
1715+
?string $query = null
17141716
): ResponseInterface {
17151717
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/items/$itemId/permissions");
1718+
if (!empty($query)) {
1719+
$url .= "?$query";
1720+
}
1721+
17161722
return HttpRequestHelper::get(
17171723
$url,
17181724
$xRequestId,

tests/acceptance/TestHelpers/HttpRequestHelper.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ public static function sendRequest(
251251
\sleep(1);
252252
}
253253
} while ($loopAgain);
254-
255254
return $response;
256255
}
257256

tests/acceptance/bootstrap/SharingNgContext.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ public function createDriveLinkShare(string $user, TableNode $body): ResponseInt
151151
* @param string $fileOrFolder (file|folder)
152152
* @param string $space
153153
* @param string|null $resource
154+
* @param string|null $query
154155
*
155156
* @return ResponseInterface
156157
* @throws GuzzleException
@@ -159,7 +160,8 @@ public function getPermissionsList(
159160
string $user,
160161
string $fileOrFolder,
161162
string $space,
162-
?string $resource = ''
163+
?string $resource = '',
164+
?string $query = null
163165
): ResponseInterface {
164166
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
165167

@@ -175,7 +177,8 @@ public function getPermissionsList(
175177
$user,
176178
$this->featureContext->getPasswordForUser($user),
177179
$spaceId,
178-
$itemId
180+
$itemId,
181+
$query
179182
);
180183
}
181184

@@ -2091,4 +2094,29 @@ public function theJsonResponseShouldContainTheFollowingShares(TableNode $table)
20912094
);
20922095
}
20932096
}
2097+
2098+
/**
2099+
* @When /^user "([^"]*)" gets the allowed roles for federated user of (folder|file) "([^"]*)" from the space "([^"]*)" using the Graph API$/
2100+
*
2101+
* @param string $user
2102+
* @param string $fileOrFolder (file|folder)
2103+
* @param string $resource
2104+
* @param string $space
2105+
*
2106+
* @return void
2107+
* @throws Exception
2108+
*/
2109+
public function userGetsFederatedPermissionsListForFileOfTheSpaceUsingTheGraphApi(
2110+
string $user,
2111+
string $fileOrFolder,
2112+
string $resource,
2113+
string $space
2114+
): void {
2115+
$query = '$filter=@libre.graph.permissions.roles.allowedValues'
2116+
. '/rolePermissions/any(p:contains(p/condition,+\'@Subject.UserType=="Federated"\'))'
2117+
. '&$select=@libre.graph.permissions.roles.allowedValues';
2118+
$this->featureContext->setResponse(
2119+
$this->getPermissionsList($user, $fileOrFolder, $space, $resource, $query)
2120+
);
2121+
}
20942122
}
Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
@ocm
2+
Feature: List a federated sharing permissions
3+
As a user
4+
I want to list the permissions for federated share
5+
So that the federated share is assigned the correct permissions
6+
7+
Background:
8+
Given user "Alice" has been created with default attributes
9+
10+
@issue-9898
11+
Scenario: user lists permissions of a resource shared to a federated user
12+
Given using server "LOCAL"
13+
And "Alice" has created the federation share invitation
14+
And using server "REMOTE"
15+
And user "Brian" has been created with default attributes
16+
And "Brian" has accepted invitation
17+
And using server "LOCAL"
18+
And user "Alice" has uploaded file with content "ocm test" to "/textfile.txt"
19+
And user "Alice" has sent the following resource share invitation to federated user:
20+
| resource | textfile.txt |
21+
| space | Personal |
22+
| sharee | Brian |
23+
| shareType | user |
24+
| permissionsRole | Viewer |
25+
When user "Alice" gets permissions list for file "textfile.txt" of the space "Personal" using the Graph API
26+
Then the HTTP status code should be "200"
27+
And the JSON data of the response should match
28+
"""
29+
{
30+
"type": "object",
31+
"required": [
32+
"@libre.graph.permissions.actions.allowedValues",
33+
"@libre.graph.permissions.roles.allowedValues",
34+
"value"
35+
],
36+
"properties": {
37+
"value": {
38+
"type": "array",
39+
"minItems": 1,
40+
"maxItems": 1,
41+
"uniqueItems": true,
42+
"items": {
43+
"oneOf":[
44+
{
45+
"type": "object",
46+
"required": [
47+
"grantedToV2",
48+
"id",
49+
"roles"
50+
],
51+
"properties": {
52+
"grantedToV2": {
53+
"type": "object",
54+
"required": ["user"],
55+
"properties": {
56+
"user": {
57+
"type": "object",
58+
"required": ["@libre.graph.userType","displayName","id"],
59+
"properties": {
60+
"@libre.graph.userType": {
61+
"const": "Federated"
62+
},
63+
"id": {
64+
"type": "string",
65+
"pattern": "^%federated_user_id_pattern%$"
66+
},
67+
"displayName": {
68+
"const": "Brian Murphy"
69+
}
70+
}
71+
}
72+
}
73+
},
74+
"id": {
75+
"type": "string",
76+
"pattern": "^%user_id_pattern%$"
77+
},
78+
"invitation": {
79+
"type": "object",
80+
"required": ["invitedBy"],
81+
"properties": {
82+
"invitedBy": {
83+
"type": "object",
84+
"required": ["user"],
85+
"properties": {
86+
"user": {
87+
"type": "object",
88+
"required": ["@libre.graph.userType", "displayName", "id"],
89+
"properties": {
90+
"@libre.graph.userType": {
91+
"const": "Member"
92+
},
93+
"id": {
94+
"type": "string",
95+
"pattern": "^%user_id_pattern%$"
96+
},
97+
"displayName": {
98+
"const": "Alice Hansen"
99+
}
100+
}
101+
}
102+
}
103+
}
104+
}
105+
},
106+
"roles": {
107+
"type": "array",
108+
"minItems": 1,
109+
"maxItems": 1,
110+
"items": {
111+
"type": "string",
112+
"pattern": "^%role_id_pattern%$"
113+
}
114+
}
115+
}
116+
}
117+
]
118+
}
119+
}
120+
}
121+
}
122+
"""
123+
124+
@issue-9745 @env-config
125+
Scenario: user lists allowed file permissions for federated user
126+
Given using server "LOCAL"
127+
And the administrator has enabled the permissions role "Secure Viewer"
128+
And user "Alice" has uploaded file with content "ocm test" to "/textfile.txt"
129+
When user "Alice" gets the allowed roles for federated user of file "textfile.txt" from the space "Personal" using the Graph API
130+
Then the HTTP status code should be "200"
131+
And the JSON data of the response should match
132+
"""
133+
{
134+
"type": "object",
135+
"required": [
136+
"@libre.graph.permissions.roles.allowedValues"
137+
],
138+
"properties": {
139+
"@libre.graph.permissions.roles.allowedValues": {
140+
"type": "array",
141+
"minItems": 2,
142+
"maxItems": 2,
143+
"uniqueItems": true,
144+
"items": {
145+
"oneOf":[
146+
{
147+
"type": "object",
148+
"required": [
149+
"@libre.graph.weight",
150+
"description",
151+
"displayName",
152+
"id"
153+
],
154+
"properties": {
155+
"@libre.graph.weight": {
156+
"const": 1
157+
},
158+
"description": {
159+
"const": "View and download."
160+
},
161+
"displayName": {
162+
"const": "Can view"
163+
},
164+
"id": {
165+
"const": "b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5"
166+
}
167+
}
168+
},
169+
{
170+
"type": "object",
171+
"required": [
172+
"@libre.graph.weight",
173+
"description",
174+
"displayName",
175+
"id"
176+
],
177+
"properties": {
178+
"@libre.graph.weight": {
179+
"const": 2
180+
},
181+
"description": {
182+
"const": "View, download and edit."
183+
},
184+
"displayName": {
185+
"const": "Can edit"
186+
},
187+
"id": {
188+
"const": "2d00ce52-1fc2-4dbc-8b95-a73b73395f5a"
189+
}
190+
}
191+
}
192+
]
193+
}
194+
}
195+
}
196+
}
197+
"""
198+
199+
@issue-9745
200+
Scenario: user lists allowed folder permissions for federated user
201+
Given using server "LOCAL"
202+
And the administrator has enabled the permissions role "Secure Viewer"
203+
And user "Alice" has created folder "folderToShare"
204+
When user "Alice" gets the allowed roles for federated user of folder "folderToShare" from the space "Personal" using the Graph API
205+
Then the HTTP status code should be "200"
206+
And the JSON data of the response should match
207+
"""
208+
{
209+
"type": "object",
210+
"required": [
211+
"@libre.graph.permissions.roles.allowedValues"
212+
],
213+
"properties": {
214+
"@libre.graph.permissions.roles.allowedValues": {
215+
"type": "array",
216+
"minItems": 2,
217+
"maxItems": 2,
218+
"uniqueItems": true,
219+
"items": {
220+
"oneOf":[
221+
{
222+
"type": "object",
223+
"required": [
224+
"@libre.graph.weight",
225+
"description",
226+
"displayName",
227+
"id"
228+
],
229+
"properties": {
230+
"@libre.graph.weight": {
231+
"const": 1
232+
},
233+
"description": {
234+
"const": "View and download."
235+
},
236+
"displayName": {
237+
"const": "Can view"
238+
},
239+
"id": {
240+
"const": "b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5"
241+
}
242+
}
243+
},
244+
{
245+
"type": "object",
246+
"required": [
247+
"@libre.graph.weight",
248+
"description",
249+
"displayName",
250+
"id"
251+
],
252+
"properties": {
253+
"@libre.graph.weight": {
254+
"const": 2
255+
},
256+
"description": {
257+
"const": "View, download, upload, edit, add and delete."
258+
},
259+
"displayName": {
260+
"const": "Can edit"
261+
},
262+
"id": {
263+
"const": "fb6c3e19-e378-47e5-b277-9732f9de6e21"
264+
}
265+
}
266+
}
267+
]
268+
}
269+
}
270+
}
271+
}
272+
"""

0 commit comments

Comments
 (0)