X Tutup
Skip to content

Commit b3a51c4

Browse files
committed
Add to and refactor filtered shares tests
1 parent 3ec0f89 commit b3a51c4

File tree

5 files changed

+298
-10
lines changed

5 files changed

+298
-10
lines changed

tests/acceptance/features/apiShareOperationsToRoot/gettingSharesSharedFiltered.feature

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Feature: sharing
3333
When user "Alice" gets the user shares shared by him using the sharing API
3434
Then the OCS status code should be "<ocs_status_code>"
3535
And the HTTP status code should be "200"
36+
And exactly 2 files or folders should be included in the response
3637
And folder "folderToShareWithUser" should be included in the response
3738
And file "fileToShareWithUser.txt" should be included in the response
3839
But folder "folderToShareWithGroup" should not be included in the response
@@ -49,12 +50,9 @@ Feature: sharing
4950
When user "Alice" gets the group shares shared by him using the sharing API
5051
Then the OCS status code should be "<ocs_status_code>"
5152
And the HTTP status code should be "200"
53+
And exactly 2 files or folders should be included in the response
5254
And folder "folderToShareWithGroup" should be included in the response
5355
And folder "fileToShareWithGroup.txt" should be included in the response
54-
But folder "folderToShareWithUser" should not be included in the response
55-
And file "fileToShareWithUser.txt" should not be included in the response
56-
And folder "folderToShareWithPublic" should not be included in the response
57-
And folder "fileToShareWithPublic.txt" should not be included in the response
5856
Examples:
5957
| ocs_api_version | ocs_status_code |
6058
| 1 | 100 |
@@ -65,12 +63,9 @@ Feature: sharing
6563
When user "Alice" gets the public link shares shared by him using the sharing API
6664
Then the OCS status code should be "<ocs_status_code>"
6765
And the HTTP status code should be "200"
66+
And exactly 2 files or folders should be included in the response
6867
And folder "folderToShareWithPublic" should be included in the response
6968
And folder "fileToShareWithPublic.txt" should be included in the response
70-
But folder "folderToShareWithUser" should not be included in the response
71-
And file "fileToShareWithUser.txt" should not be included in the response
72-
And folder "folderToShareWithGroup" should not be included in the response
73-
And folder "fileToShareWithGroup.txt" should not be included in the response
7469
Examples:
7570
| ocs_api_version | ocs_status_code |
7671
| 1 | 100 |
@@ -81,12 +76,11 @@ Feature: sharing
8176
When user "Alice" gets the user and group shares shared by him using the sharing API
8277
Then the OCS status code should be "<ocs_status_code>"
8378
And the HTTP status code should be "200"
79+
And exactly 4 files or folders should be included in the response
8480
And folder "folderToShareWithUser" should be included in the response
8581
And file "fileToShareWithUser.txt" should be included in the response
8682
And folder "folderToShareWithGroup" should be included in the response
8783
And folder "fileToShareWithGroup.txt" should be included in the response
88-
But folder "folderToShareWithPublic" should not be included in the response
89-
And folder "fileToShareWithPublic.txt" should not be included in the response
9084
Examples:
9185
| ocs_api_version | ocs_status_code |
9286
| 1 | 100 |
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
@api @files_sharing-app-required @notToImplementOnOCIS
2+
Feature: sharing
3+
As a user
4+
I want to be able to know the shares that I have made of a particular type (user, group etc)
5+
So that I can reduce the amount of data that has to be transferred to be just the data that I need
6+
7+
Background:
8+
Given these users have been created with default attributes and without skeleton files:
9+
| username |
10+
| Alice |
11+
| Brian |
12+
And group "grp1" has been created
13+
And user "Brian" has been added to group "grp1"
14+
And user "Alice" has created folder "/folderToShareWithUser"
15+
And user "Alice" has created folder "/folderToShareWithGroup"
16+
And user "Alice" has created folder "/folderToShareWithPublic"
17+
And user "Alice" has uploaded file with content "file to share with user" to "/fileToShareWithUser.txt"
18+
And user "Alice" has uploaded file with content "file to share with group" to "/fileToShareWithGroup.txt"
19+
And user "Alice" has uploaded file with content "file to share with public" to "/fileToShareWithPublic.txt"
20+
21+
Scenario Outline: getting shares shared to users when there are none
22+
Given using OCS API version "<ocs_api_version>"
23+
And user "Alice" has shared folder "/folderToShareWithGroup" with group "grp1"
24+
And user "Alice" has created a public link share with settings
25+
| path | /folderToShareWithPublic |
26+
| permissions | read |
27+
And user "Alice" has shared file "/fileToShareWithGroup.txt" with group "grp1"
28+
And user "Alice" has created a public link share with settings
29+
| path | /fileToShareWithPublic.txt |
30+
| permissions | read |
31+
When user "Alice" gets the user shares shared by him using the sharing API
32+
Then the OCS status code should be "<ocs_status_code>"
33+
And the HTTP status code should be "200"
34+
And no files or folders should be included in the response
35+
Examples:
36+
| ocs_api_version | ocs_status_code |
37+
| 1 | 100 |
38+
| 2 | 200 |
39+
40+
Scenario Outline: getting shares shared to groups when there are none
41+
Given using OCS API version "<ocs_api_version>"
42+
And user "Alice" has shared folder "/folderToShareWithUser" with user "Brian"
43+
And user "Alice" has created a public link share with settings
44+
| path | /folderToShareWithPublic |
45+
| permissions | read |
46+
And user "Alice" has shared file "/fileToShareWithUser.txt" with user "Brian"
47+
And user "Alice" has created a public link share with settings
48+
| path | /fileToShareWithPublic.txt |
49+
| permissions | read |
50+
When user "Alice" gets the group shares shared by him using the sharing API
51+
Then the OCS status code should be "<ocs_status_code>"
52+
And the HTTP status code should be "200"
53+
And no files or folders should be included in the response
54+
Examples:
55+
| ocs_api_version | ocs_status_code |
56+
| 1 | 100 |
57+
| 2 | 200 |
58+
59+
Scenario Outline: getting shares shared to public links when there are none
60+
Given using OCS API version "<ocs_api_version>"
61+
And user "Alice" has shared folder "/folderToShareWithUser" with user "Brian"
62+
And user "Alice" has shared folder "/folderToShareWithGroup" with group "grp1"
63+
And user "Alice" has shared file "/fileToShareWithUser.txt" with user "Brian"
64+
And user "Alice" has shared file "/fileToShareWithGroup.txt" with group "grp1"
65+
When user "Alice" gets the public link shares shared by him using the sharing API
66+
Then the OCS status code should be "<ocs_status_code>"
67+
And the HTTP status code should be "200"
68+
And no files or folders should be included in the response
69+
Examples:
70+
| ocs_api_version | ocs_status_code |
71+
| 1 | 100 |
72+
| 2 | 200 |
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
@api @files_sharing-app-required
2+
Feature: sharing
3+
As a user
4+
I want to be able to know the shares that I have made of a particular type (user, group etc)
5+
So that I can reduce the amount of data that has to be transferred to be just the data that I need
6+
7+
Background:
8+
Given the administrator has set the default folder for received shares to "Shares"
9+
And auto-accept shares has been disabled
10+
And these users have been created with default attributes and without skeleton files:
11+
| username |
12+
| Alice |
13+
| Brian |
14+
And group "grp1" has been created
15+
And user "Brian" has been added to group "grp1"
16+
And user "Alice" has created folder "/folderToShareWithUser"
17+
And user "Alice" has created folder "/folderToShareWithGroup"
18+
And user "Alice" has created folder "/folderToShareWithPublic"
19+
And user "Alice" has uploaded file with content "file to share with user" to "/fileToShareWithUser.txt"
20+
And user "Alice" has uploaded file with content "file to share with group" to "/fileToShareWithGroup.txt"
21+
And user "Alice" has uploaded file with content "file to share with public" to "/fileToShareWithPublic.txt"
22+
And user "Alice" has shared folder "/folderToShareWithUser" with user "Brian"
23+
And user "Brian" has accepted share "/folderToShareWithUser" offered by user "Alice"
24+
And user "Alice" has shared folder "/folderToShareWithGroup" with group "grp1"
25+
And user "Brian" has accepted share "/folderToShareWithGroup" offered by user "Alice"
26+
And user "Alice" has created a public link share with settings
27+
| path | /folderToShareWithPublic |
28+
| permissions | read |
29+
And user "Alice" has shared file "/fileToShareWithUser.txt" with user "Brian"
30+
And user "Brian" has accepted share "/fileToShareWithUser.txt" offered by user "Alice"
31+
And user "Alice" has shared file "/fileToShareWithGroup.txt" with group "grp1"
32+
And user "Brian" has accepted share "/fileToShareWithGroup.txt" offered by user "Alice"
33+
And user "Alice" has created a public link share with settings
34+
| path | /fileToShareWithPublic.txt |
35+
| permissions | read |
36+
37+
Scenario Outline: getting shares shared to users
38+
Given using OCS API version "<ocs_api_version>"
39+
When user "Alice" gets the user shares shared by him using the sharing API
40+
Then the OCS status code should be "<ocs_status_code>"
41+
And the HTTP status code should be "200"
42+
And exactly 2 files or folders should be included in the response
43+
And folder "/Shares/folderToShareWithUser" should be included in the response
44+
And file "/Shares/fileToShareWithUser.txt" should be included in the response
45+
Examples:
46+
| ocs_api_version | ocs_status_code |
47+
| 1 | 100 |
48+
| 2 | 200 |
49+
50+
Scenario Outline: getting shares shared to groups
51+
Given using OCS API version "<ocs_api_version>"
52+
When user "Alice" gets the group shares shared by him using the sharing API
53+
Then the OCS status code should be "<ocs_status_code>"
54+
And the HTTP status code should be "200"
55+
And exactly 2 files or folders should be included in the response
56+
And folder "/Shares/folderToShareWithGroup" should be included in the response
57+
And folder "/Shares/fileToShareWithGroup.txt" should be included in the response
58+
Examples:
59+
| ocs_api_version | ocs_status_code |
60+
| 1 | 100 |
61+
| 2 | 200 |
62+
63+
Scenario Outline: getting shares shared to public links
64+
Given using OCS API version "<ocs_api_version>"
65+
When user "Alice" gets the public link shares shared by him using the sharing API
66+
Then the OCS status code should be "<ocs_status_code>"
67+
And the HTTP status code should be "200"
68+
And exactly 2 files or folders should be included in the response
69+
And folder "/Shares/folderToShareWithPublic" should be included in the response
70+
And folder "/Shares/fileToShareWithPublic.txt" should be included in the response
71+
Examples:
72+
| ocs_api_version | ocs_status_code |
73+
| 1 | 100 |
74+
| 2 | 200 |
75+
76+
Scenario Outline: getting shares shared to users and groups
77+
Given using OCS API version "<ocs_api_version>"
78+
When user "Alice" gets the user and group shares shared by him using the sharing API
79+
Then the OCS status code should be "<ocs_status_code>"
80+
And the HTTP status code should be "200"
81+
And exactly 4 files or folders should be included in the response
82+
And folder "/Shares/folderToShareWithUser" should be included in the response
83+
And file "/Shares/fileToShareWithUser.txt" should be included in the response
84+
And folder "/Shares/folderToShareWithGroup" should be included in the response
85+
And folder "/Shares/fileToShareWithGroup.txt" should be included in the response
86+
Examples:
87+
| ocs_api_version | ocs_status_code |
88+
| 1 | 100 |
89+
| 2 | 200 |
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
@api @files_sharing-app-required
2+
Feature: sharing
3+
As a user
4+
I want to be able to know the shares that I have made of a particular type (user, group etc)
5+
So that I can reduce the amount of data that has to be transferred to be just the data that I need
6+
7+
Background:
8+
Given these users have been created with default attributes and without skeleton files:
9+
| username |
10+
| Alice |
11+
| Brian |
12+
And group "grp1" has been created
13+
And user "Brian" has been added to group "grp1"
14+
And user "Alice" has created folder "/folderToShareWithUser"
15+
And user "Alice" has created folder "/folderToShareWithGroup"
16+
And user "Alice" has created folder "/folderToShareWithPublic"
17+
And user "Alice" has uploaded file with content "file to share with user" to "/fileToShareWithUser.txt"
18+
And user "Alice" has uploaded file with content "file to share with group" to "/fileToShareWithGroup.txt"
19+
And user "Alice" has uploaded file with content "file to share with public" to "/fileToShareWithPublic.txt"
20+
21+
Scenario Outline: getting shares shared to users when there are none
22+
Given using OCS API version "<ocs_api_version>"
23+
And user "Alice" has shared folder "/folderToShareWithGroup" with group "grp1"
24+
And user "Brian" has accepted share "/folderToShareWithGroup" offered by user "Alice"
25+
And user "Alice" has created a public link share with settings
26+
| path | /folderToShareWithPublic |
27+
| permissions | read |
28+
And user "Alice" has shared file "/fileToShareWithGroup.txt" with group "grp1"
29+
And user "Brian" has accepted share "/fileToShareWithGroup.txt" offered by user "Alice"
30+
And user "Alice" has created a public link share with settings
31+
| path | /fileToShareWithPublic.txt |
32+
| permissions | read |
33+
When user "Alice" gets the user shares shared by him using the sharing API
34+
Then the OCS status code should be "<ocs_status_code>"
35+
And the HTTP status code should be "200"
36+
And no files or folders should be included in the response
37+
Examples:
38+
| ocs_api_version | ocs_status_code |
39+
| 1 | 100 |
40+
| 2 | 200 |
41+
42+
Scenario Outline: getting shares shared to groups when there are none
43+
Given using OCS API version "<ocs_api_version>"
44+
And user "Alice" has shared folder "/folderToShareWithUser" with user "Brian"
45+
And user "Brian" has accepted share "/folderToShareWithUser" offered by user "Alice"
46+
And user "Alice" has created a public link share with settings
47+
| path | /folderToShareWithPublic |
48+
| permissions | read |
49+
And user "Alice" has shared file "/fileToShareWithUser.txt" with user "Brian"
50+
And user "Brian" has accepted share "/fileToShareWithUser.txt" offered by user "Alice"
51+
And user "Alice" has created a public link share with settings
52+
| path | /fileToShareWithPublic.txt |
53+
| permissions | read |
54+
When user "Alice" gets the group shares shared by him using the sharing API
55+
Then the OCS status code should be "<ocs_status_code>"
56+
And the HTTP status code should be "200"
57+
And no files or folders should be included in the response
58+
Examples:
59+
| ocs_api_version | ocs_status_code |
60+
| 1 | 100 |
61+
| 2 | 200 |
62+
63+
Scenario Outline: getting shares shared to public links when there are none
64+
Given using OCS API version "<ocs_api_version>"
65+
And user "Alice" has shared folder "/folderToShareWithUser" with user "Brian"
66+
And user "Brian" has accepted share "/folderToShareWithUser" offered by user "Alice"
67+
And user "Alice" has shared folder "/folderToShareWithGroup" with group "grp1"
68+
And user "Brian" has accepted share "/folderToShareWithGroup" offered by user "Alice"
69+
And user "Alice" has shared file "/fileToShareWithUser.txt" with user "Brian"
70+
And user "Brian" has accepted share "/fileToShareWithUser.txt" offered by user "Alice"
71+
And user "Alice" has shared file "/fileToShareWithGroup.txt" with group "grp1"
72+
And user "Brian" has accepted share "/fileToShareWithGroup.txt" offered by user "Alice"
73+
When user "Alice" gets the public link shares shared by him using the sharing API
74+
Then the OCS status code should be "<ocs_status_code>"
75+
And the HTTP status code should be "200"
76+
And no files or folders should be included in the response
77+
Examples:
78+
| ocs_api_version | ocs_status_code |
79+
| 1 | 100 |
80+
| 2 | 200 |

tests/acceptance/features/bootstrap/Sharing.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,31 @@ public function isFieldInResponse($field, $contentExpected, $expectSuccess = tru
10441044
return false;
10451045
}
10461046

1047+
/**
1048+
* @Then no files or folders should be included in the response
1049+
*
1050+
* @return void
1051+
*/
1052+
public function checkNoFilesFoldersInResponse() {
1053+
$data = $this->getResponseXml(null, __METHOD__)->data[0];
1054+
Assert::assertIsObject($data, __METHOD__ . " data not found in response XML");
1055+
Assert::assertCount(0, $data);
1056+
}
1057+
1058+
/**
1059+
* @Then exactly :count file/files or folder/folders should be included in the response
1060+
*
1061+
* @param string $count
1062+
*
1063+
* @return void
1064+
*/
1065+
public function checkCountFilesFoldersInResponse($count) {
1066+
$count = (int) $count;
1067+
$data = $this->getResponseXml(null, __METHOD__)->data[0];
1068+
Assert::assertIsObject($data, __METHOD__ . " data not found in response XML");
1069+
Assert::assertCount($count, $data);
1070+
}
1071+
10471072
/**
10481073
* @Then /^(?:file|folder|entry) "([^"]*)" should be included in the response$/
10491074
*
@@ -1709,6 +1734,34 @@ public function userGetsAllTheSharesSharedWithHimUsingTheSharingApi($user) {
17091734
);
17101735
}
17111736

1737+
/**
1738+
* @When /^user "([^"]*)" gets the (user|group|user and group|public link) shares shared with him using the sharing API$/
1739+
*
1740+
* @param string $user
1741+
* @param string $shareType
1742+
*
1743+
* @return void
1744+
*/
1745+
public function userGetsFilteredSharesSharedWithHimUsingTheSharingApi($user, $shareType) {
1746+
$user = $this->getActualUsername($user);
1747+
if ($shareType === 'public link') {
1748+
$shareType = 'public_link';
1749+
}
1750+
if ($shareType === 'user and group') {
1751+
$rawShareTypes = SharingHelper::SHARE_TYPES['user'] . "," . SharingHelper::SHARE_TYPES['group'];
1752+
} else {
1753+
$rawShareTypes = SharingHelper::SHARE_TYPES[$shareType];
1754+
}
1755+
$this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody(
1756+
$user,
1757+
'GET',
1758+
$this->getSharesEndpointPath(
1759+
"?shared_with_me=true&share_types=" . $rawShareTypes
1760+
),
1761+
null
1762+
);
1763+
}
1764+
17121765
/**
17131766
* @When /^user "([^"]*)" gets all the shares shared with him that are received as (?:file|folder|entry) "([^"]*)" using the provisioning API$/
17141767
*

0 commit comments

Comments
 (0)
X Tutup