Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Stable10] api test api sharing v1 #31423

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ matrix:

- PHP_VERSION: 7.1
TEST_SUITE: api
BEHAT_SUITE: apiSharing
BEHAT_SUITE: apiSharing-v1
DB_TYPE: mariadb
USE_SERVER: true
INSTALL_SERVER: true
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ default:
contexts:
- ShareesContext: *common_feature_context_params

apiSharing:
apiSharing-v1:
paths:
- %paths.base%/../features/apiSharing
- %paths.base%/../features/apiSharing-v1
contexts:
- FeatureContext: *common_feature_context_params

Expand Down
46 changes: 46 additions & 0 deletions tests/acceptance/features/apiSharing-v1/accessToShare.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@api
Feature: sharing
Background:
Given using API version "1"
And using old DAV path


Scenario: Sharee can see the share
Given user "user0" has been created
And user "user1" has been created
And user "user0" has shared file "textfile0.txt" with user "user1"
When user "user1" sends HTTP method "GET" to API endpoint "/apps/files_sharing/api/v1/shares?shared_with_me=true"
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the last share_id should be included in the response

Scenario: Sharee can see the filtered share
Given user "user0" has been created
And user "user1" has been created
And user "user0" has shared file "textfile0.txt" with user "user1"
And user "user0" has shared file "textfile1.txt" with user "user1"
When user "user1" sends HTTP method "GET" to API endpoint "/apps/files_sharing/api/v1/shares?shared_with_me=true&path=textfile1 (2).txt"
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the last share_id should be included in the response

Scenario: Sharee can't see the share that is filtered out
Given user "user0" has been created
And user "user1" has been created
And user "user0" has shared file "textfile0.txt" with user "user1"
And user "user0" has shared file "textfile1.txt" with user "user1"
When user "user1" sends HTTP method "GET" to API endpoint "/apps/files_sharing/api/v1/shares?shared_with_me=true&path=textfile0 (2).txt"
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the last share_id should not be included in the response

Scenario: Sharee can see the group share
Given user "user0" has been created
And user "user1" has been created
And group "group0" has been created
And user "user1" has been added to group "group0"
And user "user0" has shared file "textfile0.txt" with group "group0"
When user "user1" sends HTTP method "GET" to API endpoint "/apps/files_sharing/api/v1/shares?shared_with_me=true"
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the last share_id should be included in the response
40 changes: 40 additions & 0 deletions tests/acceptance/features/apiSharing-v1/changingFilesShare.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@api
Feature: sharing
Background:
Given using API version "1"
And using old DAV path

Scenario: moving a file into a share as recipient
Given user "user0" has been created
And user "user1" has been created
And user "user0" has created a folder "/shared"
And user "user0" has shared folder "/shared" with user "user1"
When user "user1" moves file "/textfile0.txt" to "/shared/shared_file.txt" using the API
Then as "user1" the file "/shared/shared_file.txt" should exist
And as "user0" the file "/shared/shared_file.txt" should exist

Scenario: moving a file out of a share as recipient creates a backup for the owner
Given user "user0" has been created
And user "user1" has been created
And user "user0" has created a folder "/shared"
And user "user0" has moved file "/textfile0.txt" to "/shared/shared_file.txt"
And user "user0" has shared file "/shared" with user "user1"
And user "user1" has moved folder "/shared" to "/shared_renamed"
When user "user1" moves file "/shared_renamed/shared_file.txt" to "/taken_out.txt" using the API
Then as "user1" the file "/taken_out.txt" should exist
And as "user0" the file "/shared/shared_file.txt" should not exist
And as "user0" the file "/shared_file.txt" should exist in trash

Scenario: moving a folder out of a share as recipient creates a backup for the owner
Given user "user0" has been created
And user "user1" has been created
And user "user0" has created a folder "/shared"
And user "user0" has created a folder "/shared/sub"
And user "user0" has moved file "/textfile0.txt" to "/shared/sub/shared_file.txt"
And user "user0" has shared file "/shared" with user "user1"
And user "user1" has moved folder "/shared" to "/shared_renamed"
When user "user1" moves folder "/shared_renamed/sub" to "/taken_out" using the API
Then as "user1" the file "/taken_out" should exist
And as "user0" the folder "/shared/sub" should not exist
And as "user0" the folder "/sub" should exist in trash
And as "user0" the file "/sub/shared_file.txt" should exist in trash
278 changes: 278 additions & 0 deletions tests/acceptance/features/apiSharing-v1/createShare.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
@api
Feature: sharing
Background:
Given using API version "1"
And using old DAV path

Scenario: Creating a new share with user
Given user "user0" has been created
And user "user1" has been created
When user "user0" sends HTTP method "POST" to API endpoint "/apps/files_sharing/api/v1/shares" with body
| path | welcome.txt |
| shareWith | user1 |
| shareType | 0 |
Then the OCS status code should be "100"
And the HTTP status code should be "200"

Scenario: Creating a share with a group
Given user "user0" has been created
And user "user1" has been created
And group "sharing-group" has been created
When user "user0" sends HTTP method "POST" to API endpoint "/apps/files_sharing/api/v1/shares" with body
| path | welcome.txt |
| shareWith | sharing-group |
| shareType | 1 |
Then the OCS status code should be "100"
And the HTTP status code should be "200"

Scenario: Creating a new share with user who already received a share through their group
Given user "user0" has been created
And user "user1" has been created
And group "sharing-group" has been created
And user "user1" has been added to group "sharing-group"
And user "user0" has shared file "welcome.txt" with group "sharing-group"
When user "user0" sends HTTP method "POST" to API endpoint "/apps/files_sharing/api/v1/shares" with body
| path | welcome.txt |
| shareWith | user1 |
| shareType | 0 |
Then the OCS status code should be "100"
And the HTTP status code should be "200"

Scenario: Creating a new public share
Given user "user0" has been created
When user "user0" creates a share using the API with settings
| path | welcome.txt |
| shareType | 3 |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the last public shared file should be able to be downloaded without a password

Scenario: Creating a new public share with password
Given user "user0" has been created
When user "user0" creates a share using the API with settings
| path | welcome.txt |
| shareType | 3 |
| password | publicpw |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the last public shared file should be able to be downloaded with password "publicpw"

Scenario: Creating a new public share of a folder
Given user "user0" has been created
When user "user0" creates a share using the API with settings
| path | FOLDER |
| shareType | 3 |
| password | publicpw |
| expireDate | +3 days |
| publicUpload | true |
| permissions | 7 |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the share fields of the last share should include
| id | A_NUMBER |
| permissions | 15 |
| expiration | +3 days |
| url | AN_URL |
| token | A_TOKEN |
| mimetype | httpd/unix-directory |

Scenario: Creating a new share with a disabled user
Given user "user0" has been created
And user "user1" has been created
And user "user0" has been disabled
When user "user0" sends HTTP method "POST" to API endpoint "/apps/files_sharing/api/v1/shares" with body
| path | welcome.txt |
| shareWith | user1 |
| shareType | 0 |
Then the OCS status code should be "997"
And the HTTP status code should be "401"

Scenario: Creating a link share with no specified permissions defaults to read permissions
Given user "user0" has been created
And user "user0" has created a folder "/afolder"
When user "user0" creates a share using the API with settings
| path | /afolder |
| shareType | 3 |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the share fields of the last share should include
| id | A_NUMBER |
| share_type | 3 |
| permissions | 1 |

Scenario: Creating a link share with no specified permissions defaults to read permissions when public upload disabled globally
Given parameter "shareapi_allow_public_upload" of app "core" has been set to "no"
And user "user0" has been created
And user "user0" has created a folder "/afolder"
When user "user0" creates a share using the API with settings
| path | /afolder |
| shareType | 3 |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the share fields of the last share should include
| id | A_NUMBER |
| share_type | 3 |
| permissions | 1 |

Scenario: Creating a link share with edit permissions keeps it
Given user "user0" has been created
And user "user0" has created a folder "/afolder"
When user "user0" creates a share using the API with settings
| path | /afolder |
| shareType | 3 |
| permissions | 15 |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the share fields of the last share should include
| id | A_NUMBER |
| share_type | 3 |
| permissions | 15 |

Scenario: Share of folder and sub-folder to same user - core#20645
Given user "user0" has been created
And user "user1" has been created
And group "group0" has been created
And user "user1" has been added to group "group0"
When user "user0" shares file "/PARENT" with user "user1" using the API
And user "user0" shares file "/PARENT/CHILD" with group "group0" using the API
Then user "user1" should see the following elements
| /FOLDER/ |
| /PARENT/ |
| /PARENT/parent.txt |
| /PARENT%20(2)/ |
| /PARENT%20(2)/parent.txt |
| /CHILD/ |
| /CHILD/child.txt |
And the HTTP status code should be "200"

Scenario: Share of folder to a group
Given user "user0" has been created
And user "user1" has been created
And user "user2" has been created
And group "group0" has been created
And user "user1" has been added to group "group0"
And user "user2" has been added to group "group0"
And user "user0" shares file "/PARENT" with group "group0" using the API
Then user "user1" should see the following elements
| /FOLDER/ |
| /PARENT/ |
| /PARENT/parent.txt |
| /PARENT%20(2)/ |
| /PARENT%20(2)/parent.txt |
And the HTTP status code should be "200"
And user "user2" should see the following elements
| /FOLDER/ |
| /PARENT/ |
| /PARENT/parent.txt |
| /PARENT%20(2)/ |
| /PARENT%20(2)/parent.txt |
And the HTTP status code should be "200"

Scenario: Don't allow sharing of the root
Given user "user0" has been created
When user "user0" creates a share using the API with settings
| path | / |
| shareType | 3 |
Then the OCS status code should be "403"

Scenario: Only allow 1 link share per file/folder
Given user "user0" has been created
And as user "user0"
And the user has created a share with settings
| path | welcome.txt |
| shareType | 3 |
And the last share id has been remembered
When the user creates a share using the API with settings
| path | welcome.txt |
| shareType | 3 |
Then the share ids should match

Scenario: unique target names for incoming shares
Given user "user0" has been created
And user "user1" has been created
And user "user2" has been created
And user "user0" has created a folder "/foo"
And user "user1" has created a folder "/foo"
When user "user0" shares file "/foo" with user "user2" using the API
And user "user1" shares file "/foo" with user "user2" using the API
Then user "user2" should see the following elements
| /foo/ |
| /foo%20(2)/ |

Scenario: sharing again an own file while belonging to a group
Given user "user0" has been created
And group "sharing-group" has been created
And user "user0" has been added to group "sharing-group"
And user "user0" has shared file "welcome.txt" with group "sharing-group"
And user "user0" has deleted the last share
When user "user0" sends HTTP method "POST" to API endpoint "/apps/files_sharing/api/v1/shares" with body
| path | welcome.txt |
| shareWith | sharing-group |
| shareType | 1 |
Then the OCS status code should be "100"
And the HTTP status code should be "200"

Scenario: sharing subfolder when parent already shared
Given user "user0" has been created
Given user "user1" has been created
And group "sharing-group" has been created
And user "user0" has created a folder "/test"
And user "user0" has created a folder "/test/sub"
And user "user0" has shared file "/test" with group "sharing-group"
When user "user0" sends HTTP method "POST" to API endpoint "/apps/files_sharing/api/v1/shares" with body
| path | /test/sub |
| shareWith | user1 |
| shareType | 0 |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And as "user1" the folder "/sub" should exist

Scenario: sharing subfolder when parent already shared with group of sharer
Given user "user0" has been created
And user "user1" has been created
And group "sharing-group" has been created
And user "user0" has been added to group "sharing-group"
And user "user0" has created a folder "/test"
And user "user0" has created a folder "/test/sub"
And user "user0" has shared file "/test" with group "sharing-group"
When user "user0" sends HTTP method "POST" to API endpoint "/apps/files_sharing/api/v1/shares" with body
| path | /test/sub |
| shareWith | user1 |
| shareType | 0 |
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And as "user1" the folder "/sub" should exist

Scenario: sharing subfolder of already shared folder, GET result is correct
Given user "user0" has been created
And user "user1" has been created
And user "user2" has been created
And user "user3" has been created
And user "user4" has been created
And user "user0" has created a folder "/folder1"
And user "user0" has shared file "/folder1" with user "user1"
And user "user0" has shared file "/folder1" with user "user2"
And user "user0" has created a folder "/folder1/folder2"
And user "user0" has shared file "/folder1/folder2" with user "user3"
And user "user0" has shared file "/folder1/folder2" with user "user4"
And as user "user0"
When the user sends HTTP method "GET" to API endpoint "/apps/files_sharing/api/v1/shares"
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the response should contain 4 entries
And file "/folder1" should be included as path in the response
And file "/folder1/folder2" should be included as path in the response
And the user sends HTTP method "GET" to API endpoint "/apps/files_sharing/api/v1/shares?path=/folder1/folder2"
And the response should contain 2 entries
And file "/folder1" should not be included as path in the response
And file "/folder1/folder2" should be included as path in the response

Scenario: Cannot create share with zero permissions
Given user "user0" has been created
And user "user1" has been created
When user "user0" sends HTTP method "POST" to API endpoint "/apps/files_sharing/api/v1/shares" with body
| path | welcome.txt |
| shareWith | user1 |
| shareType | 0 |
| permissions | 0 |
Then the OCS status code should be "400"
Loading