From b8e8d740b24e18da4e951b99302d2034f2e7215d Mon Sep 17 00:00:00 2001 From: Artur Neumann Date: Thu, 1 Jul 2021 13:22:30 +0200 Subject: [PATCH] test downloading old versions of a file --- .../features/apiVersions/fileVersions.feature | 38 +++++++++++++++++++ .../fileVersionsSharingToShares.feature | 21 ++++++++++ ...eVersionsSharingToSharesIssue36228.feature | 28 ++++++++++++++ .../bootstrap/FilesVersionsContext.php | 32 ++++++++++++++++ 4 files changed, 119 insertions(+) create mode 100644 tests/acceptance/features/apiVersions/fileVersionsSharingToSharesIssue36228.feature diff --git a/tests/acceptance/features/apiVersions/fileVersions.feature b/tests/acceptance/features/apiVersions/fileVersions.feature index b6b514cb2348..59299019a0df 100644 --- a/tests/acceptance/features/apiVersions/fileVersions.feature +++ b/tests/acceptance/features/apiVersions/fileVersions.feature @@ -415,3 +415,41 @@ Feature: dav-versions Then the HTTP status code should be "207" And the number of etag elements in the response should be "2" And the number of versions should be "2" + + + Scenario: download old versions of a file + Given user "Alice" has uploaded file with content "uploaded content" to "textfile0.txt" + And user "Alice" has uploaded file with content "version 1" to "textfile0.txt" + And user "Alice" has uploaded file with content "version 2" to "textfile0.txt" + When user "Alice" downloads the version of file "textfile0.txt" with the index "1" + Then the HTTP status code should be "200" + And the following headers should be set + | header | value | + | Content-Disposition | attachment; filename*=UTF-8''textfile0.txt; filename="textfile0.txt" | + And the downloaded content should be "version 1" + When user "Alice" downloads the version of file "textfile0.txt" with the index "2" + Then the HTTP status code should be "200" + And the following headers should be set + | header | value | + | Content-Disposition | attachment; filename*=UTF-8''textfile0.txt; filename="textfile0.txt" | + And the downloaded content should be "uploaded content" + + + Scenario: download an old version of a of a restored file + Given user "Alice" has uploaded file with content "uploaded content" to "textfile0.txt" + And user "Alice" has uploaded file with content "version 1" to "textfile0.txt" + And user "Alice" has uploaded file with content "version 2" to "textfile0.txt" + And user "Alice" has restored version index "1" of file "textfile0.txt" + When user "Alice" downloads the version of file "textfile0.txt" with the index "1" + Then the HTTP status code should be "200" + And the following headers should be set + | header | value | + | Content-Disposition | attachment; filename*=UTF-8''textfile0.txt; filename="textfile0.txt" | + And the downloaded content should be "version 2" + When user "Alice" downloads the version of file "textfile0.txt" with the index "2" + Then the HTTP status code should be "200" + And the following headers should be set + | header | value | + | Content-Disposition | attachment; filename*=UTF-8''textfile0.txt; filename="textfile0.txt" | + And the downloaded content should be "uploaded content" + diff --git a/tests/acceptance/features/apiVersions/fileVersionsSharingToShares.feature b/tests/acceptance/features/apiVersions/fileVersionsSharingToShares.feature index 97efdac5de72..e1366006aabf 100644 --- a/tests/acceptance/features/apiVersions/fileVersionsSharingToShares.feature +++ b/tests/acceptance/features/apiVersions/fileVersionsSharingToShares.feature @@ -296,3 +296,24 @@ Feature: dav-versions Then the HTTP status code should be "204" And the version folder of file "/Shares/sharefile.txt" for user "Brian" should contain "1" element And the version folder of file "/sharefile.txt" for user "Alice" should contain "1" element + + @issue-36228 @skipOnOcV10 + Scenario: download old versions of a shared file as share receiver + Given user "Brian" has been created with default attributes and without skeleton files + And user "Alice" has uploaded file with content "uploaded content" to "textfile0.txt" + And user "Alice" has uploaded file with content "version 1" to "textfile0.txt" + And user "Alice" has uploaded file with content "version 2" to "textfile0.txt" + And user "Alice" has shared file "textfile0.txt" with user "Brian" + And user "Brian" has accepted share "/textfile0.txt" offered by user "Alice" + When user "Brian" downloads the version of file "/Shares/textfile0.txt" with the index "1" + Then the HTTP status code should be "200" + And the following headers should be set + | header | value | + | Content-Disposition | attachment; filename*=UTF-8''textfile0.txt; filename="textfile0.txt" | + And the downloaded content should be "version 1" + When user "Brian" downloads the version of file "/Shares/textfile0.txt" with the index "2" + Then the HTTP status code should be "200" + And the following headers should be set + | header | value | + | Content-Disposition | attachment; filename*=UTF-8''textfile0.txt; filename="textfile0.txt" | + And the downloaded content should be "uploaded content" diff --git a/tests/acceptance/features/apiVersions/fileVersionsSharingToSharesIssue36228.feature b/tests/acceptance/features/apiVersions/fileVersionsSharingToSharesIssue36228.feature new file mode 100644 index 000000000000..44d452650de1 --- /dev/null +++ b/tests/acceptance/features/apiVersions/fileVersionsSharingToSharesIssue36228.feature @@ -0,0 +1,28 @@ +@api @files_versions-app-required @issue-36228 @notToImplementOnOCIS + +Feature: dav-versions + + Background: + Given the administrator has set the default folder for received shares to "Shares" + And auto-accept shares has been disabled + And user "Alice" has been created with default attributes and without skeleton files + + Scenario: download an old version of a of a restored file + Given user "Brian" has been created with default attributes and without skeleton files + And user "Alice" has uploaded file with content "uploaded content" to "textfile0.txt" + And user "Alice" has uploaded file with content "version 1" to "textfile0.txt" + And user "Alice" has uploaded file with content "version 2" to "textfile0.txt" + And user "Alice" has shared file "textfile0.txt" with user "Brian" + And user "Brian" has accepted share "/textfile0.txt" offered by user "Alice" + When user "Brian" downloads the version of file "/Shares/textfile0.txt" with the index "1" + Then the HTTP status code should be "200" + And the following headers should be set + | header | value | + | Content-Disposition | attachment; filename*=UTF-8''; filename="" | + And the downloaded content should be "version 1" + When user "Brian" downloads the version of file "/Shares/textfile0.txt" with the index "2" + Then the HTTP status code should be "200" + And the following headers should be set + | header | value | + | Content-Disposition | attachment; filename*=UTF-8''; filename="" | + And the downloaded content should be "uploaded content" diff --git a/tests/acceptance/features/bootstrap/FilesVersionsContext.php b/tests/acceptance/features/bootstrap/FilesVersionsContext.php index a6e0e16ae195..9636a2e2e988 100644 --- a/tests/acceptance/features/bootstrap/FilesVersionsContext.php +++ b/tests/acceptance/features/bootstrap/FilesVersionsContext.php @@ -202,6 +202,38 @@ public function theContentLengthOfFileForUserInVersionsFolderIs( ); } + /** + * @When user :user downloads the version of file :path with the index :index + * + * @param string $user + * @param string $path + * @param string $index + * + * @return void + */ + public function downloadVersion(string $user, string $path, string $index) { + $user = $this->featureContext->getActualUsername($user); + $fileId = $this->featureContext->getFileIdForPath($user, $path); + $index = (int)$index; + $responseXml = $this->listVersionFolder($user, $fileId, 1); + $xmlPart = $responseXml->xpath("//d:response/d:href"); + if (!isset($xmlPart[$index])) { + Assert::fail( + 'could not find version of path "' . $path . '" with index "' . $index . '"' + ); + } + // the href already contains the path + $url = WebDavHelper::sanitizeUrl( + $this->featureContext->getBaseUrlWithoutPath() . $xmlPart[$index] + ); + $response = HttpRequestHelper::get( + $url, + $user, + $this->featureContext->getPasswordForUser($user) + ); + $this->featureContext->setResponse($response); + } + /** * returns the result parsed into an SimpleXMLElement * with an registered namespace with 'd' as prefix and 'DAV:' as namespace