From 1fe5d0fc80b765d02b1eec6d6bdf5de447619a54 Mon Sep 17 00:00:00 2001 From: Viktor Scharf Date: Thu, 24 Mar 2022 11:19:12 +0100 Subject: [PATCH] added some checking/separate share file and creating link --- .../apiSpaces/shareSubItemOfSpace.feature | 117 +++++++++--------- .../shareSubItemOfSpaceViaPublicLink.feature | 86 +++++++++++++ .../features/bootstrap/SpacesContext.php | 13 +- 3 files changed, 153 insertions(+), 63 deletions(-) create mode 100644 tests/acceptance/features/apiSpaces/shareSubItemOfSpaceViaPublicLink.feature diff --git a/tests/acceptance/features/apiSpaces/shareSubItemOfSpace.feature b/tests/acceptance/features/apiSpaces/shareSubItemOfSpace.feature index 9419245208b..6c5545feb05 100644 --- a/tests/acceptance/features/apiSpaces/shareSubItemOfSpace.feature +++ b/tests/acceptance/features/apiSpaces/shareSubItemOfSpace.feature @@ -1,13 +1,13 @@ @api @skipOnOcV10 Feature: Share a file or folder that is inside a space - As an user with manager space role - I want to be able to share the data inside the space + As an user with manager space role + I want to be able to share the data inside the space - | role | permissions | - | viewer | 1 | - | uploader | 4 | - | contributor | 5 | - | editor | 15 | + | role | permissions | + | viewer | 1 | + | uploader | 4 | + | contributor | 5 | + | editor | 15 | Note - this feature is run in CI with ACCOUNTS_HASH_DIFFICULTY set to the default for production See https://github.com/owncloud/ocis/issues/1542 and https://github.com/owncloud/ocis/pull/839 @@ -24,70 +24,69 @@ Feature: Share a file or folder that is inside a space And user "Alice" has uploaded a file inside space "share sub-item" with content "some content" to "folder/file.txt" - Scenario Outline: An user-owner can share an entrity inside project space to another user with role: - When user "Alice" shares the following entity "" inside of space "share sub-item" with user "Brian" with role "" + Scenario Outline: An user-owner can share a folder inside project space to another user with role: + When user "Alice" shares the following entity "folder" inside of space "share sub-item" with user "Brian" with role "" Then the HTTP status code should be "200" And the OCS status code should be "200" And the OCS status message should be "OK" + And user "Brian" accepts share "/folder" offered by user "Alice" using the sharing API + And as "Brian" folder "Shares/folder" should exist Examples: - | entity | role | statusCode | - | folder | viewer | 200 | - | folder | editor | 200 | - | folder/file.txt | viewer | 200 | - | folder/file.txt | editor | 200 | - + | role | + | viewer | + | editor | - Scenario Outline: An user participant of the project space tries to share an entity to another user - Given user "Alice" has shared a space "share sub-item" to user "Brian" with role "" - When user "Brian" shares the following entity "" inside of space "share sub-item" with user "Bob" with role "editor" - Then the HTTP status code should be "" - And the OCS status code should be "" + + Scenario Outline: An user-owner can share a file inside project space to another user with role: + When user "Alice" shares the following entity "folder/file.txt" inside of space "share sub-item" with user "Brian" with role "" + Then the HTTP status code should be "200" + And the OCS status code should be "200" + And the OCS status message should be "OK" + And user "Brian" accepts share "/file.txt" offered by user "Alice" using the sharing API + Then as "Brian" file "Shares/file.txt" should exist + Examples: + | role | + | viewer | + | editor | + + + Scenario Outline: An user participant of the project space with manager role can share a folder to another user + Given user "Alice" has shared a space "share sub-item" to user "Brian" with role "manager" + When user "Brian" shares the following entity "folder" inside of space "share sub-item" with user "Bob" with role "" + Then the HTTP status code should be "200" + And the OCS status code should be "200" + And the OCS status message should be "OK" + And user "Bob" accepts share "/folder" offered by user "Brian" using the sharing API + And as "Bob" folder "Shares/folder" should exist Examples: - | entity | spaceRole | statusCode | - | folder | manager | 200 | - | folder/file.txt | manager | 200 | - | folder | editor | 404 | - | folder/file.txt | editor | 404 | - | folder/file.txt | viewer | 404 | - | folder | viewer | 404 | + | role | + | viewer | + | editor | - Scenario Outline: An user-owner can share an entrity inside project space via public link - When user "Alice" creates a public link share inside of space "share sub-item" with settings: - | path | | - | shareType | 3 | - | permissions | | - | password | | - | name | | - | expireDate | 2042-03-25T23:59:59+0100 | + Scenario Outline: An user participant of the project space with manager role can share a file to another user + Given user "Alice" has shared a space "share sub-item" to user "Brian" with role "manager" + When user "Brian" shares the following entity "folder/file.txt" inside of space "share sub-item" with user "Bob" with role "" Then the HTTP status code should be "200" And the OCS status code should be "200" + And the OCS status message should be "OK" + And user "Bob" accepts share "/file.txt" offered by user "Brian" using the sharing API + Then as "Bob" file "Shares/file.txt" should exist Examples: - | entity | permissions | password | name | expireDate | - | folder | 1 | 123 | link | 2042-03-25T23:59:59+0100 | - | folder | 4 | | | | - | folder | 5 | 200 | | 2042-03-25T23:59:59+0100 | - | folder | 15 | | link | | - | folder/file.txt | 1 | 123 | link | 2042-03-25T23:59:59+0100 | - - - Scenario Outline: An user participant of the project space tries to share an entrity inside project space via public link + | role | + | viewer | + | editor | + + + Scenario Outline: An user participant of the project space without space manager role cannot share an entity to another user Given user "Alice" has shared a space "share sub-item" to user "Brian" with role "" - When user "Brian" creates a public link share inside of space "share sub-item" with settings: - | path | | - | shareType | 3 | - | permissions | 1 | - | password | 123 | - | name | public link | - | expireDate | 2042-03-25T23:59:59+0100 | + When user "Brian" shares the following entity "" inside of space "share sub-item" with user "Bob" with role "editor" Then the HTTP status code should be "" And the OCS status code should be "" + And the OCS status message should be "" Examples: - | entity | spaceRole | statusCode | - | folder | manager | 200 | - | folder | editor | 404 | - | folder | viewer | 404 | - | folder/file.txt | manager | 200 | - | folder/file.txt | editor | 404 | - | folder/file.txt | viewer | 404 | - \ No newline at end of file + | entity | spaceRole | statusCode | statusMessage | + | folder | editor | 404 | No share permission | + | folder/file.txt | editor | 404 | No share permission | + | folder/file.txt | viewer | 404 | No share permission | + | folder | viewer | 404 | No share permission | diff --git a/tests/acceptance/features/apiSpaces/shareSubItemOfSpaceViaPublicLink.feature b/tests/acceptance/features/apiSpaces/shareSubItemOfSpaceViaPublicLink.feature new file mode 100644 index 00000000000..d40d5944f8b --- /dev/null +++ b/tests/acceptance/features/apiSpaces/shareSubItemOfSpaceViaPublicLink.feature @@ -0,0 +1,86 @@ +@api @skipOnOcV10 +Feature: Share a file or folder that is inside a space via public link + As an user with manager space role + I want to be able to share the data inside the space via public link + + | role | permissions | + | viewer | 1 | + | uploader | 4 | + | contributor | 5 | + | editor | 15 | + + Note - this feature is run in CI with ACCOUNTS_HASH_DIFFICULTY set to the default for production + See https://github.com/owncloud/ocis/issues/1542 and https://github.com/owncloud/ocis/pull/839 + + Background: + Given these users have been created with default attributes and without skeleton files: + | username | + | Alice | + | Brian | + | Bob | + And the administrator has given "Alice" the role "Admin" using the settings api + And user "Alice" has created a space "share sub-item" with the default quota using the GraphApi + And user "Alice" has created a folder "folder" in space "share sub-item" + And user "Alice" has uploaded a file inside space "share sub-item" with content "some content" to "folder/file.txt" + + + Scenario Outline: An user-owner can share an entrity inside project space via public link + When user "Alice" creates a public link share inside of space "share sub-item" with settings: + | path | | + | shareType | 3 | + | permissions | | + | password | | + | name | | + | expireDate | | + Then the HTTP status code should be "200" + And the OCS status code should be "200" + And the OCS status message should be "OK" + And the fields of the last response to user "Alice" should include + | path | / | + Examples: + | entity | permissions | password | name | expireDate | + | folder | 1 | 123 | link | 2042-03-25T23:59:59+0100 | + | folder | 4 | | | | + | folder | 5 | 200 | | 2042-03-25T23:59:59+0100 | + | folder | 15 | | link | | + | folder/file.txt | 1 | 123 | link | 2042-03-25T23:59:59+0100 | + + + Scenario Outline: An user participant of the project space with space manager role can share an entrity inside project space via public link + Given user "Alice" has shared a space "share sub-item" to user "Brian" with role "manager" + When user "Brian" creates a public link share inside of space "share sub-item" with settings: + | path | | + | shareType | 3 | + | permissions | 1 | + | password | 123 | + | name | public link | + | expireDate | 2042-03-25T23:59:59+0100 | + Then the HTTP status code should be "200" + And the OCS status code should be "200" + And the OCS status message should be "OK" + And the fields of the last response to user "Alice" should include + | path | / | + Examples: + | entity | + | folder | + | folder/file.txt | + + + Scenario Outline: An user participant of the project space without space manager role cannot share an entrity inside project space via public link + Given user "Alice" has shared a space "share sub-item" to user "Brian" with role "" + When user "Brian" creates a public link share inside of space "share sub-item" with settings: + | path | | + | shareType | 3 | + | permissions | 1 | + | password | 123 | + | name | public link | + | expireDate | 2042-03-25T23:59:59+0100 | + Then the HTTP status code should be "404" + And the OCS status code should be "404" + And the OCS status message should be "No share permission" + Examples: + | entity | spaceRole | + | folder | editor | + | folder | viewer | + | folder/file.txt | editor | + | folder/file.txt | viewer | diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 692d54fc4ba..6936ad34ff8 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -56,6 +56,11 @@ class SpacesContext implements Context { */ private array $createdSpaces; + /** + * @var string + */ + private $ocsApiUrl = '/ocs/v2.php/apps/files_sharing/api/v1/shares'; + /** * @param string $spaceName * @@ -1551,7 +1556,7 @@ public function sendShareSpaceRequest( "role" => $role // role overrides the permissions parameter ]; - $fullUrl = $this->baseUrl . "/ocs/v2.php/apps/files_sharing/api/v1/shares"; + $fullUrl = $this->baseUrl . $this->ocsApiUrl; $this->featureContext->setResponse( HttpRequestHelper::post( @@ -1592,7 +1597,7 @@ public function sendShareEntityInsideOfSpaceRequest( "role" => $role ]; - $fullUrl = $this->baseUrl . "/ocs/v2.php/apps/files_sharing/api/v1/shares"; + $fullUrl = $this->baseUrl . $this->ocsApiUrl; $this->featureContext->setResponse( HttpRequestHelper::post( @@ -1640,7 +1645,7 @@ public function createPublicLinkToEntityInsideOfSpaceRequest( "expireDate" => $rows["expireDate"] ]; - $fullUrl = $this->baseUrl . "/ocs/v2.php/apps/files_sharing/api/v1/shares"; + $fullUrl = $this->baseUrl . $this->ocsApiUrl; $this->featureContext->setResponse( HttpRequestHelper::post( @@ -1698,7 +1703,7 @@ public function sendUnshareSpaceRequest( string $userRecipient ): void { $space = $this->getSpaceByName($user, $spaceName); - $fullUrl = $this->baseUrl . "/ocs/v2.php/apps/files_sharing/api/v1/shares/" . $space['id'] . "?shareWith=" . $userRecipient; + $fullUrl = $this->baseUrl . $this->ocsApiUrl . "/" . $space['id'] . "?shareWith=" . $userRecipient; $this->featureContext->setResponse( HttpRequestHelper::delete(