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
This commit is contained in:
Michael Stingl
2026-07-17 14:20:00 +02:00
committed by GitHub
parent a82aeef2eb
commit 3893be6ed1
2 changed files with 34 additions and 0 deletions

View File

@@ -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

View File

@@ -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-version> 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 |