diff --git a/tests/acceptance/features/apiSpaces/copySpaces.feature b/tests/acceptance/features/apiSpaces/copySpaces.feature index f5f75d3e0d1..18da8d41265 100644 --- a/tests/acceptance/features/apiSpaces/copySpaces.feature +++ b/tests/acceptance/features/apiSpaces/copySpaces.feature @@ -42,7 +42,7 @@ Feature: copy file And user "Brian" has uploaded a file inside space "Project1" with content "Project1 content" to "project1.txt" And user "Brian" has shared a space "Project2" to user "Alice" with role "manager" And user "Brian" has shared a space "Project1" to user "Alice" with role "" - When user "Alice" copies file "project1.txt" from space "Project1" to "project1.txt" in space "Project2" using the WebDAV API + When user "Alice" copies file "project1.txt" from space "Project1" to "project1.txt" inside space "Project2" using the WebDAV API And the HTTP status code should be "201" And for user "Alice" the content of the file "project1.txt" of the space "Project2" should be "Project1 content" Examples: @@ -59,7 +59,7 @@ Feature: copy file And user "Brian" has uploaded a file inside space "Project1" with content "Project1 content" to "project1.txt" And user "Brian" has shared a space "Project2" to user "Alice" with role "editor" And user "Brian" has shared a space "Project1" to user "Alice" with role "" - When user "Alice" copies file "project1.txt" from space "Project1" to "project1.txt" in space "Project2" using the WebDAV API + When user "Alice" copies file "project1.txt" from space "Project1" to "project1.txt" inside space "Project2" using the WebDAV API And the HTTP status code should be "201" And for user "Alice" the content of the file "project1.txt" of the space "Project2" should be "Project1 content" Examples: @@ -75,7 +75,7 @@ Feature: copy file And user "Brian" has uploaded a file inside space "Project1" with content "Project1 content" to "project1.txt" And user "Brian" has shared a space "Project2" to user "Alice" with role "viewer" And user "Brian" has shared a space "Project1" to user "Alice" with role "" - When user "Alice" copies file "project1.txt" from space "Project1" to "project1.txt" in space "Project2" using the WebDAV API + When user "Alice" copies file "project1.txt" from space "Project1" to "project1.txt" inside space "Project2" using the WebDAV API And the HTTP status code should be "403" Examples: | role | @@ -88,8 +88,8 @@ Feature: copy file And user "Brian" has created a space "Project" with the default quota using the GraphApi And user "Brian" has uploaded a file inside space "Project" with content "Project content" to "project.txt" And user "Brian" has shared a space "Project" to user "Alice" with role "" - When user "Alice" copies file "project.txt" from space "Project" to "project.txt" inside personal using the WebDAV API - And the HTTP status code should be "201" + When user "Alice" copies file "project.txt" from space "Project" to "project.txt" inside space "Personal" using the WebDAV API + Then the HTTP status code should be "201" And as "Alice" file "/project.txt" should exist And the content of file "project.txt" for user "Alice" should be "Project content" Examples: @@ -97,3 +97,38 @@ Feature: copy file | manager | | editor | | viewer | + + Scenario Outline: User copy a file from space project with different role to shares jail with editor role + Given the administrator has given "Brian" the role "Space Admin" using the settings api + And user "Brian" has created a space "Project" with the default quota using the GraphApi + And user "Brian" has created folder "/testshare" + And user "Brian" has uploaded a file inside space "Project" with content "Project content" to "project.txt" + And user "Brian" has shared a space "Project" to user "Alice" with role "" + And user "Brian" has shared folder "/testshare" with user "Alice" with permissions "31" + And user "Alice" has accepted share "/testshare" offered by user "Brian" + When user "Alice" copies file "project.txt" from space "Project" to "/testshare/project.txt" inside space "Shares Jail" using the WebDAV API + Then the HTTP status code should be "201" + And as "Alice" file "/Shares/testshare/project.txt" should exist + And the content of file "/Shares/testshare/project.txt" for user "Alice" should be "Project content" + Examples: + | role | + | manager | + | editor | + | viewer | + + + Scenario Outline: User copy a file from space project with different role to shares jail with viewer role + Given the administrator has given "Brian" the role "Space Admin" using the settings api + And user "Brian" has created a space "Project" with the default quota using the GraphApi + And user "Brian" has created folder "/testshare" + And user "Brian" has uploaded a file inside space "Project" with content "Project content" to "project.txt" + And user "Brian" has shared a space "Project" to user "Alice" with role "" + And user "Brian" has shared folder "/testshare" with user "Alice" with permissions "17" + And user "Alice" has accepted share "/testshare" offered by user "Brian" + When user "Alice" copies file "project.txt" from space "Project" to "/testshare/project.txt" inside space "Shares Jail" using the WebDAV API + Then the HTTP status code should be "403" + Examples: + | role | + | manager | + | editor | + | viewer | diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index a4aa14ff4b9..ba74967ee24 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -1736,7 +1736,7 @@ public function userCopiesFileUsingTheAPI( } /** - * @When /^user "([^"]*)" copies (?:file|folder) "([^"]*)" from space "([^"]*)" to "([^"]*)" in space "([^"]*)" using the WebDAV API$/ + * @When /^user "([^"]*)" copies (?:file|folder) "([^"]*)" from space "([^"]*)" to "([^"]*)" inside space "([^"]*)" using the WebDAV API$/ * * @param string $user * @param string $fileSource @@ -1753,38 +1753,28 @@ public function userCopiesFileFromAndToSpaceBetweenProjects( string $fileDestination, string $toSpaceName ):void { - $space = $this->getSpaceByName($user, $fromSpaceName); - $headers['Destination'] = $this->destinationHeaderValueWithSpaceName( - $user, - $fileDestination, - $toSpaceName - ); - $fullUrl = $this->baseUrl . "/dav/spaces/" . $space['id'] . '/' . $fileSource; - $this->copyFilesAndFoldersRequest($user, $fullUrl, $headers); - } - /** - * @When /^user "([^"]*)" copies (?:file|folder) "([^"]*)" from space "([^"]*)" to "([^"]*)" inside personal using the WebDAV API$/ - * - * @param string $user - * @param string $fileSource - * @param string $spaceName - * @param string $fileDestination - * - * @return void - */ - public function userCopiesFileFromProjectToPersonal( - string $user, - string $fileSource, - string $spaceName, - string $fileDestination - ):void { - $space = $this->getSpaceByName($user, $spaceName); - $headers['Destination'] = $this->destinationHeaderValueWithUserPersonalSpaceID( - $user, - $fileDestination, - ); - $fullUrl = $this->baseUrl . "/dav/spaces/" . $space['id'] . '/' . $fileSource; +// get headers + if($toSpaceName === "Personal"){ + $headers['Destination'] = $this->destinationHeaderValueWithUserPersonalSpaceID( + $user, + $fileDestination, + ); + } else { + $headers['Destination'] = $this->destinationHeaderValueWithSpaceName( + $user, + $fileDestination, + $toSpaceName + ); + } + + if($fromSpaceName === "Personal"){ + $userPersonalSpaceID = $this->featureContext->getPersonalSpaceIdForUser($user, true); + $fullUrl = $this->baseUrl . "/dav/spaces/" . $userPersonalSpaceID . '/' . $fileSource; + }else { + $space = $this->getSpaceByName($user, $fromSpaceName); + $fullUrl = $this->baseUrl . "/dav/spaces/" . $space['id'] . '/' . $fileSource; + } $this->copyFilesAndFoldersRequest($user, $fullUrl, $headers); }