diff --git a/tests/acceptance/features/bootstrap/PublicWebDavContext.php b/tests/acceptance/features/bootstrap/PublicWebDavContext.php index 38e9910666..1c4bd50fe4 100644 --- a/tests/acceptance/features/bootstrap/PublicWebDavContext.php +++ b/tests/acceptance/features/bootstrap/PublicWebDavContext.php @@ -115,6 +115,19 @@ class PublicWebDavContext implements Context { $this->featureContext->setResponse($response); } + /** + * @When /^user "([^"]*)" tries to download file "([^"]*)" from the last public link using own basic auth and new public WebDAV API$/ + * + * @param string $user + * @param string $path + * + * @return void + */ + public function userTriesToDownloadFileFromPublicLinkUsingBasicAuthAndPublicWebdav(string $user, string $path): void { + $response = $this->downloadFromPublicLinkAsUser($path, $user); + $this->featureContext->setResponse($response); + } + /** * @When /^the public deletes (?:file|folder|entry) "([^"]*)" from the last public link share using the (old|new) public WebDAV API$/ * @@ -283,6 +296,38 @@ class PublicWebDavContext implements Context { $this->featureContext->setResponse($response); } + /** + * @param string $path + * @param string $user + * @param bool $shareNg + * + * @return ResponseInterface + */ + public function downloadFromPublicLinkAsUser(string $path, string $user, bool $shareNg = false): ResponseInterface { + $path = \ltrim($path, "/"); + if ($shareNg) { + $token = $this->featureContext->shareNgGetLastCreatedLinkShareToken(); + } else { + $token = $this->featureContext->getLastCreatedPublicShareToken(); + } + + $davPath = WebDavHelper::getDavPath( + $token, + 0, + "public-files-new" + ); + + $username = $this->featureContext->getActualUsername($user); + $password = $this->featureContext->getPasswordForUser($user); + $fullUrl = $this->featureContext->getBaseUrl() . "/$davPath$path"; + + return HttpRequestHelper::get( + $fullUrl, + $this->featureContext->getStepLineRef(), + $username, + $password + ); + } /** * @param string $path * @param string $password diff --git a/tests/acceptance/features/coreApiSharePublicLink1/accessToPublicLinkShare.feature b/tests/acceptance/features/coreApiSharePublicLink1/accessToPublicLinkShare.feature index 3e08f07ce5..7c18cbaa60 100644 --- a/tests/acceptance/features/coreApiSharePublicLink1/accessToPublicLinkShare.feature +++ b/tests/acceptance/features/coreApiSharePublicLink1/accessToPublicLinkShare.feature @@ -57,3 +57,14 @@ Feature: accessing a public link share | testavatar.jpg | | textfile0.txt | Then the HTTP status code of responses on all endpoints should be "200" + + @issue-web-10473 + Scenario: user tries to download public link file using own basic auth + And user "Alice" has created folder "FOLDER" + And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "FOLDER/textfile.txt" + And user "Alice" has created a public link share with settings + | path | FOLDER | + | permissions | change | + | password | %public% | + When user "Alice" tries to download file "textfile.txt" from the last public link using own basic auth and new public WebDAV API + Then the HTTP status code should be "401"