diff --git a/tests/acceptance/bootstrap/WebDavPropertiesContext.php b/tests/acceptance/bootstrap/WebDavPropertiesContext.php index 3bc0ec09db..2a5f66b48f 100644 --- a/tests/acceptance/bootstrap/WebDavPropertiesContext.php +++ b/tests/acceptance/bootstrap/WebDavPropertiesContext.php @@ -140,6 +140,27 @@ class WebDavPropertiesContext implements Context { $this->featureContext->pushToLastStatusCodesArrays(); } + /** + * @param string $user + * @param string $path + * + * @return void + * @throws Exception + */ + #[When('/^user "([^"]*)" downloads the "([^"]*)" file via its oc:downloadURL$/')] + public function userDownloadsFileViaItsDownloadUrl(string $user, string $path): void { + $propertiesTable = new TableNode([["propertyName"], ["oc:downloadURL"]]); + $propfindResponse = $this->getPropertiesOfFolder($user, $path, null, $propertiesTable); + $downloadUrl = (string)$this->checkResponseContainsProperty($propfindResponse, "oc:downloadURL"); + // GET the server-built URL as-is, the way the web client does: the signature + // in the URL authenticates the request, so no credentials are sent. + $response = HttpRequestHelper::get( + $downloadUrl, + $this->featureContext->getStepLineRef() + ); + $this->featureContext->setResponse($response); + } + /** * * @param string $username diff --git a/tests/acceptance/features/coreApiWebdavOperations/downloadFile.feature b/tests/acceptance/features/coreApiWebdavOperations/downloadFile.feature index c0bd588dee..41ffd88baf 100644 --- a/tests/acceptance/features/coreApiWebdavOperations/downloadFile.feature +++ b/tests/acceptance/features/coreApiWebdavOperations/downloadFile.feature @@ -316,3 +316,16 @@ Feature: download file | spaces | "C++ file.cpp" | | spaces | "file #2.txt" | | spaces | "file ?2.pdf" | + + @issue-2852 + Scenario Outline: download a file whose name contains a literal "%" via its oc:downloadURL + Given using DAV path + And user "Alice" has uploaded file with content "test file" to "firstword%20secondword.txt" + When user "Alice" downloads the "firstword%20secondword.txt" file via its oc:downloadURL + Then the HTTP status code should be "200" + And the downloaded content should be "test file" + Examples: + | dav-path-version | + | old | + | new | + | spaces |