Skip to content

Commit 9881496

Browse files
Merge pull request #10756 from owncloud/list-drives
[tests-only][full-ci]added test to list drives after the share role has been disabled
2 parents d264dd8 + 000a4f9 commit 9881496

File tree

2 files changed

+178
-20
lines changed

2 files changed

+178
-20
lines changed

tests/acceptance/bootstrap/SpacesContext.php

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,9 +2049,10 @@ public function userOverwritesFileFromAndToSpaceBetweenSpaces(
20492049
}
20502050

20512051
/**
2052-
* @Then /^user "([^"]*)" should not be able to download file "([^"]*)" from space "([^"]*)"$/
2052+
* @Then /^user "([^"]*)" (should|should not) be able to download file "([^"]*)" from space "([^"]*)"$/
20532053
*
20542054
* @param string $user
2055+
* @param string $shouldOrNot
20552056
* @param string $fileName
20562057
* @param string $spaceName
20572058
*
@@ -2060,6 +2061,7 @@ public function userOverwritesFileFromAndToSpaceBetweenSpaces(
20602061
*/
20612062
public function userShouldOrShouldNotBeAbleToDownloadFileFromSpace(
20622063
string $user,
2064+
string $shouldOrNot,
20632065
string $fileName,
20642066
string $spaceName
20652067
): void {
@@ -2071,19 +2073,27 @@ public function userShouldOrShouldNotBeAbleToDownloadFileFromSpace(
20712073
null,
20722074
$spaceId
20732075
);
2074-
Assert::assertGreaterThanOrEqual(
2075-
400,
2076-
$response->getStatusCode(),
2077-
__METHOD__
2078-
. ' download must fail'
2079-
);
2080-
Assert::assertLessThanOrEqual(
2081-
499,
2082-
$response->getStatusCode(),
2083-
__METHOD__
2084-
. ' 4xx error expected but got status code "'
2085-
. $response->getStatusCode() . '"'
2086-
);
2076+
if ($shouldOrNot === 'should') {
2077+
$this->featureContext->theHTTPStatusCodeShouldBe(
2078+
200,
2079+
__METHOD__ . "Expected response status code is 200 but got " . $response->getStatusCode(),
2080+
$response
2081+
);
2082+
} else {
2083+
Assert::assertGreaterThanOrEqual(
2084+
400,
2085+
$response->getStatusCode(),
2086+
__METHOD__
2087+
. ' download must fail'
2088+
);
2089+
Assert::assertLessThanOrEqual(
2090+
499,
2091+
$response->getStatusCode(),
2092+
__METHOD__
2093+
. ' 4xx error expected but got status code "'
2094+
. $response->getStatusCode() . '"'
2095+
);
2096+
}
20872097
}
20882098

20892099
/**

tests/acceptance/features/apiSharingNg1/enableDisablePermissionsRole.feature

Lines changed: 154 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Feature: enable disable permissions role
1515
Given the administrator has enabled the permissions role "Secure Viewer"
1616
And user "Alice" has uploaded file with content "some content" to "textfile.txt"
1717
And user "Alice" has created folder "folderToShare"
18+
And user "Alice" has uploaded file with content "hello world" to "folderToShare/textfile1.txt"
1819
And user "Alice" has sent the following resource share invitation:
1920
| resource | <resource> |
2021
| space | Personal |
@@ -135,15 +136,24 @@ Feature: enable disable permissions role
135136
}
136137
}
137138
"""
139+
And user "Brian" should have a share "<resource>" shared by user "Alice" from space "Personal"
140+
When user "Brian" sends PROPFIND request from the space "Shares" to the resource "<resource>" with depth "0" using the WebDAV API
141+
Then the HTTP status code should be "207"
142+
And as user "Brian" the PROPFIND response should contain a resource "<resource>" with these key and value pairs:
143+
| key | value |
144+
| oc:name | <resource> |
145+
| oc:permissions | SX |
146+
And user "Brian" should not be able to download file "<resource-to-download>" from space "Shares"
138147
Examples:
139-
| resource | resource-type |
140-
| textfile.txt | file |
141-
| folderToShare | folder |
148+
| resource | resource-type | resource-to-download |
149+
| textfile.txt | file | textfile.txt |
150+
| folderToShare | folder | folderToShare/textfile1.txt |
142151

143152

144153
Scenario: users list the shares shared with Denied after the role is disabled (Personal Space)
145154
Given the administrator has enabled the permissions role "Denied"
146155
And user "Alice" has created folder "folderToShare"
156+
And user "Alice" has uploaded file with content "hello world" to "folderToShare/textfile1.txt"
147157
And user "Alice" has sent the following resource share invitation:
148158
| resource | folderToShare |
149159
| space | Personal |
@@ -202,6 +212,10 @@ Feature: enable disable permissions role
202212
}
203213
}
204214
"""
215+
And user "Brian" should not have a share "folderToShare" shared by user "Alice" from space "Personal"
216+
When user "Brian" sends PROPFIND request from the space "Shares" to the resource "folderToShare" with depth "0" using the WebDAV API
217+
Then the HTTP status code should be "404"
218+
And user "Brian" should not be able to download file "folderToShare/textfile1.txt" from space "Shares"
205219

206220

207221
Scenario Outline: users list the shares shared with Secure Viewer after the role is disabled (Project Space)
@@ -211,6 +225,7 @@ Feature: enable disable permissions role
211225
And user "Alice" has created a space "new-space" with the default quota using the Graph API
212226
And user "Alice" has uploaded a file inside space "new-space" with content "some content" to "textfile.txt"
213227
And user "Alice" has created a folder "folderToShare" in space "new-space"
228+
And user "Alice" has uploaded a file inside space "new-space" with content "hello world" to "folderToShare/textfile1.txt"
214229
And user "Alice" has sent the following resource share invitation:
215230
| resource | <resource> |
216231
| space | new-space |
@@ -329,10 +344,18 @@ Feature: enable disable permissions role
329344
}
330345
}
331346
"""
347+
And user "Brian" should have a share "<resource>" shared by user "Alice" from space "new-space"
348+
When user "Brian" sends PROPFIND request from the space "Shares" to the resource "<resource>" with depth "0" using the WebDAV API
349+
Then the HTTP status code should be "207"
350+
And as user "Brian" the PROPFIND response should contain a resource "<resource>" with these key and value pairs:
351+
| key | value |
352+
| oc:name | <resource> |
353+
| oc:permissions | SX |
354+
And user "Brian" should not be able to download file "<resource-to-download>" from space "Shares"
332355
Examples:
333-
| resource | resource-type |
334-
| textfile.txt | file |
335-
| folderToShare | folder |
356+
| resource | resource-type | resource-to-download |
357+
| textfile.txt | file | textfile.txt |
358+
| folderToShare | folder | folderToShare/textfile1.txt |
336359

337360

338361
Scenario: users list the shares shared with Denied after the role is disabled (Project Space)
@@ -341,6 +364,7 @@ Feature: enable disable permissions role
341364
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
342365
And user "Alice" has created a space "new-space" with the default quota using the Graph API
343366
And user "Alice" has created a folder "folderToShare" in space "new-space"
367+
And user "Alice" has uploaded a file inside space "new-space" with content "hello world" to "folderToShare/textfile1.txt"
344368
And user "Alice" has sent the following resource share invitation:
345369
| resource | folderToShare |
346370
| space | new-space |
@@ -399,3 +423,127 @@ Feature: enable disable permissions role
399423
}
400424
}
401425
"""
426+
And user "Brian" should not have a share "folderToShare" shared by user "Alice" from space "Personal"
427+
When user "Brian" sends PROPFIND request from the space "Shares" to the resource "folderToShare" with depth "0" using the WebDAV API
428+
Then the HTTP status code should be "404"
429+
And user "Brian" should not be able to download file "folderToShare/textfile1.txt" from space "Shares"
430+
431+
432+
Scenario: sharee lists drives after the share role Space Editor Without Versions has been disabled
433+
Given using spaces DAV path
434+
And the administrator has enabled the permissions role "Space Editor Without Versions"
435+
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
436+
And user "Alice" has created a space "new-space" with the default quota using the Graph API
437+
And user "Alice" has uploaded a file inside space "new-space" with content "hello world" to "textfile1.txt"
438+
And user "Alice" has sent the following space share invitation:
439+
| space | new-space |
440+
| sharee | Brian |
441+
| shareType | user |
442+
| permissionsRole | Space Editor Without Versions |
443+
And the administrator has disabled the permissions role "Space Editor Without Versions"
444+
When user "Brian" lists all available spaces via the Graph API
445+
Then the HTTP status code should be "200"
446+
And the JSON response should contain space called "new-space" and match
447+
"""
448+
{
449+
"type": "object",
450+
"required": [
451+
"driveType",
452+
"driveAlias",
453+
"name",
454+
"id",
455+
"quota",
456+
"root",
457+
"webUrl"
458+
],
459+
"properties": {
460+
"root": {
461+
"type": "object",
462+
"required": [
463+
"eTag",
464+
"id",
465+
"permissions",
466+
"webDavUrl"
467+
],
468+
"properties": {
469+
"permissions": {
470+
"type": "array",
471+
"minItems": 2,
472+
"maxItems": 2,
473+
"uniqueItems": true,
474+
"items": {
475+
"oneOf": [
476+
{
477+
"type": "object",
478+
"required": ["grantedToV2", "roles"],
479+
"properties": {
480+
"grantedToV2": {
481+
"type": "object",
482+
"required": ["user"],
483+
"properties": {
484+
"user" : {
485+
"type": "object",
486+
"required": ["@libre.graph.userType", "displayName", "id"],
487+
"properties": {
488+
"@libre.graph.userType": { "const": "Member" },
489+
"displayName": { "const": "Alice Hansen" },
490+
"id": { "pattern": "^%user_id_pattern%$" }
491+
}
492+
}
493+
}
494+
},
495+
"roles": { "pattern": "^%role_id_pattern%$" }
496+
}
497+
},
498+
{
499+
"type": "object",
500+
"required": ["@libre.graph.permissions.actions", "grantedToV2"],
501+
"properties": {
502+
"@libre.graph.permissions.actions": {
503+
"const": [
504+
"libre.graph/driveItem/children/create",
505+
"libre.graph/driveItem/standard/delete",
506+
"libre.graph/driveItem/path/read",
507+
"libre.graph/driveItem/quota/read",
508+
"libre.graph/driveItem/content/read",
509+
"libre.graph/driveItem/upload/create",
510+
"libre.graph/driveItem/permissions/read",
511+
"libre.graph/driveItem/children/read",
512+
"libre.graph/driveItem/deleted/read",
513+
"libre.graph/driveItem/path/update",
514+
"libre.graph/driveItem/deleted/update",
515+
"libre.graph/driveItem/basic/read"
516+
]
517+
},
518+
"grantedToV2": {
519+
"type": "object",
520+
"required": ["user"],
521+
"properties": {
522+
"user": {
523+
"type": "object",
524+
"required": ["@libre.graph.userType", "displayName", "id"],
525+
"properties": {
526+
"@libre.graph.userType": { "const": "Member" },
527+
"displayName": { "const": "Brian Murphy" },
528+
"id": { "pattern": "^%user_id_pattern%$" }
529+
}
530+
}
531+
}
532+
}
533+
}
534+
}
535+
]
536+
}
537+
}
538+
}
539+
}
540+
}
541+
}
542+
"""
543+
When user "Brian" sends PROPFIND request to space "new-space" with depth "0" using the WebDAV API
544+
Then the HTTP status code should be "207"
545+
And as user "Brian" the PROPFIND response should contain a space "new-space" with these key and value pairs:
546+
| key | value |
547+
| oc:name | new-space |
548+
| oc:permissions | DNVCK |
549+
And user "Brian" should be able to download file "textfile1.txt" from space "new-space"

0 commit comments

Comments
 (0)