From 3893be6ed16ddc5f839e1a2d5080bc65fd99440c Mon Sep 17 00:00:00 2001 From: Michael Stingl Date: Fri, 17 Jul 2026 14:20:00 +0200 Subject: [PATCH] test(coreApiWebdavOperations): download a file with a literal "%" via its oc:downloadURL (#3079) A file whose name contains a literal "%" 404s on download because the server-built oc:downloadURL did not percent-encode the path (#2852, fixed in reva by https://github.com/opencloud-eu/reva/pull/653). Add a scenario mirroring the web client download flow: read the oc:downloadURL from PROPFIND and GET it as-is (the signature in the URL authenticates it), asserting 200 and the content. The new step "user X downloads the P file via its oc:downloadURL" lives in WebDavPropertiesContext; a regex annotation avoids the ":" in oc:downloadURL colliding with the turnip :placeholder syntax. Verified red->green on posix and decomposed: red on an opencloud built on a reva with the fix reverted (the download 404s), green on the shipped reva. https://github.com/opencloud-eu/opencloud/issues/2852 --- .../bootstrap/WebDavPropertiesContext.php | 21 +++++++++++++++++++ .../downloadFile.feature | 13 ++++++++++++ 2 files changed, 34 insertions(+) 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 |