From a15fe45d6ac45a4f7ee8e76ada09fa6a2d516ebb Mon Sep 17 00:00:00 2001 From: Nalem7 <61624650+nabim777@users.noreply.github.com> Date: Fri, 27 Oct 2023 15:11:32 +0545 Subject: [PATCH] add tests for copy file within shares ucing file-id (#7593) --- .../copyByFileId.feature | 23 +++++++++++++++++++ .../features/bootstrap/FeatureContext.php | 2 +- .../features/bootstrap/SpacesContext.php | 11 +++++++-- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/tests/acceptance/features/apiSpacesDavOperation/copyByFileId.feature b/tests/acceptance/features/apiSpacesDavOperation/copyByFileId.feature index c9e8788be2..f834dc7db9 100644 --- a/tests/acceptance/features/apiSpacesDavOperation/copyByFileId.feature +++ b/tests/acceptance/features/apiSpacesDavOperation/copyByFileId.feature @@ -178,3 +178,26 @@ Feature: copying file using file id | dav-path | | /remote.php/dav/spaces/<> | | /dav/spaces/<> | + + + Scenario Outline: copy a file from sub-folder to root folder inside Shares space + Given user "Brian" has been created with default attributes and without skeleton files + And user "Alice" has created folder "/folder" + And user "Alice" has created folder "folder/sub-folder" + And user "Alice" has uploaded file with content "some data" to "/folder/sub-folder/test.txt" + And we save it into "FILEID" + And user "Alice" has shared folder "/folder" with user "Brian" with permissions "all" + When user "Brian" copies a file "Shares/folder/sub-folder/test.txt" into "Shares/folder" inside space "Shares" using file-id path "" + Then the HTTP status code should be "201" + And for user "Brian" folder "folder" of the space "Shares" should contain these files: + | test.txt | + And for user "Brian" folder "folder/sub-folder" of the space "Shares" should contain these files: + | test.txt | + And for user "Alice" folder "folder" of the space "Personal" should contain these files: + | test.txt | + And for user "Alice" folder "folder/sub-folder" of the space "Personal" should contain these files: + | test.txt | + Examples: + | dav-path | + | /remote.php/dav/spaces/<> | + | /dav/spaces/<> | diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php index c8e364276e..74dd91f2c6 100644 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ b/tests/acceptance/features/bootstrap/FeatureContext.php @@ -610,7 +610,7 @@ class FeatureContext extends BehatVariablesContext { } $logMessage = "## $scenario ($scenarioLine)\n"; - + // Delete previous scenario's log file if (\file_exists(HttpLogger::getScenarioLogPath())) { \unlink(HttpLogger::getScenarioLogPath()); diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index df0f1e3b3c..870fcf0840 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -1965,8 +1965,15 @@ class SpacesContext implements Context { } elseif ($actionType === 'renames') { $fileDestination = $destinationFile; } - $headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName, $url); - $fullUrl = $this->featureContext->getBaseUrl() . $url; + $baseUrl = $this->featureContext->getBaseUrl(); + if ($toSpaceName === 'Shares') { + $sharesPath = $this->featureContext->getMountSharesPath($user, $fileDestination); + $davPath = WebDavHelper::getDavPath($user, $this->featureContext->getDavPathVersion()); + $headers['Destination'] = $baseUrl . $davPath . $sharesPath; + } else { + $headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName, $url); + } + $fullUrl = $baseUrl . $url; if ($actionType === 'copies') { $this->featureContext->setResponse($this->copyFilesAndFoldersRequest($user, $fullUrl, $headers)); } elseif ($actionType === 'moves' || $actionType === 'renames') {