diff --git a/tests/acceptance/features/bootstrap/PublicWebDavContext.php b/tests/acceptance/features/bootstrap/PublicWebDavContext.php index bdcb48f675..71e2d3ada8 100644 --- a/tests/acceptance/features/bootstrap/PublicWebDavContext.php +++ b/tests/acceptance/features/bootstrap/PublicWebDavContext.php @@ -1658,4 +1658,55 @@ class PublicWebDavContext implements Context { $this->featureContext = $environment->getContext('FeatureContext'); $this->occContext = $environment->getContext('OccContext'); } + + /** + * @When /^the public sends "([^"]*)" request to the last public link share using the (old|new) public WebDAV API(?: with password "([^"]*)")?$/ + * + * @param string $method + * @param string $publicWebDAVAPIVersion + * @param string $password + * + * @return void + * @throws GuzzleException + */ + public function publicSendsRequestToLastPublicShare(string $method, string $publicWebDAVAPIVersion, ?string $password = ''):void { + if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") { + return; + } + if ($method === "PROPFIND") { + $body = ' + + + + + + + + + + '; + } + $token = $this->featureContext->getLastPublicShareToken(); + $davPath = WebDavHelper::getDavPath( + null, + null, + "public-files-$publicWebDAVAPIVersion" + ); + $username = $this->getUsernameForPublicWebdavApi( + $token, + $password, + $publicWebDAVAPIVersion + ); + $fullUrl = $this->featureContext->getBaseUrl() . "/$davPath$token"; + $response = HttpRequestHelper::sendRequest( + $fullUrl, + $this->featureContext->getStepLineRef(), + $method, + $username, + $password, + null, + $body + ); + $this->featureContext->setResponse($response); + } } diff --git a/tests/acceptance/features/bootstrap/WebDavPropertiesContext.php b/tests/acceptance/features/bootstrap/WebDavPropertiesContext.php index 6aa673e1b0..08cdec9a64 100644 --- a/tests/acceptance/features/bootstrap/WebDavPropertiesContext.php +++ b/tests/acceptance/features/bootstrap/WebDavPropertiesContext.php @@ -886,7 +886,15 @@ class WebDavPropertiesContext implements Context { $pattern = $this->featureContext->substituteInLineCodes( $pattern, $user, - ['preg_quote' => ['/']] + ['preg_quote' => ['/']], + [ + [ + "code" => "%public_token%", + "function" => + [$this->featureContext, "getLastPublicShareToken"], + "parameter" => [] + ], + ] ); Assert::assertMatchesRegularExpression( $pattern, diff --git a/tests/acceptance/features/coreApiWebdavOperations/propfind.feature b/tests/acceptance/features/coreApiWebdavOperations/propfind.feature index 7994cdcf58..ff3598b684 100644 --- a/tests/acceptance/features/coreApiWebdavOperations/propfind.feature +++ b/tests/acceptance/features/coreApiWebdavOperations/propfind.feature @@ -47,4 +47,53 @@ Feature: PROPFIND Examples: | dav_path | depth_infinity_allowed | depth | http_status | | /remote.php/dav/spaces/%spaceid% | 1 | 0 | 207 | - | /remote.php/dav/spaces/%spaceid% | 1 | infinity | 207 | \ No newline at end of file + | /remote.php/dav/spaces/%spaceid% | 1 | infinity | 207 | + + + Scenario: send PROPFIND request to a public link + Given user "Alice" has been created with default attributes and without skeleton files + And user "Alice" has created folder "/PARENT" + And user "Alice" has created a public link share with settings + | path | /PARENT | + | permissions | read | + When the public sends "PROPFIND" request to the last public link share using the new public WebDAV API + Then the HTTP status code should be "207" + And the value of the item "//d:href" in the response should match "/%base_path%\/remote.php\/dav\/public-files\/%public_token%\/$/" + And the value of the item "//oc:public-link-share-owner" in the response should be "Alice" + + + Scenario: send PROPFIND request to a public link shared with password + Given user "Alice" has been created with default attributes and without skeleton files + And user "Alice" has created folder "/PARENT" + And user "Alice" has created a public link share with settings + | path | /PARENT | + | permissions | read | + | password | 1111 | + When the public sends "PROPFIND" request to the last public link share using the new public WebDAV API with password "1111" + Then the HTTP status code should be "207" + And the value of the item "//d:href" in the response should match "/%base_path%\/remote.php\/dav\/public-files\/%public_token%\/$/" + And the value of the item "//oc:public-link-share-owner" in the response should be "Alice" + + + Scenario: send PROPFIND request to a public link shared with password (request without password) + Given user "Alice" has been created with default attributes and without skeleton files + And user "Alice" has created folder "/PARENT" + And user "Alice" has created a public link share with settings + | path | /PARENT | + | permissions | read | + | password | 1111 | + When the public sends "PROPFIND" request to the last public link share using the new public WebDAV API + Then the HTTP status code should be "401" + And the value of the item "/d:error/s:exception" in the response should be "Sabre\DAV\Exception\NotAuthenticated" + + + Scenario: send PROPFIND request to a public link shared with password (request with incorrect password) + Given user "Alice" has been created with default attributes and without skeleton files + And user "Alice" has created folder "/PARENT" + And user "Alice" has created a public link share with settings + | path | /PARENT | + | permissions | read | + | password | 1111 | + When the public sends "PROPFIND" request to the last public link share using the new public WebDAV API with password "1234" + Then the HTTP status code should be "401" + And the value of the item "/d:error/s:exception" in the response should be "Sabre\DAV\Exception\NotAuthenticated" \ No newline at end of file