diff --git a/tests/acceptance/bootstrap/FeatureContext.php b/tests/acceptance/bootstrap/FeatureContext.php index 5ee1a2f148..455676f4da 100644 --- a/tests/acceptance/bootstrap/FeatureContext.php +++ b/tests/acceptance/bootstrap/FeatureContext.php @@ -1281,6 +1281,34 @@ class FeatureContext extends BehatVariablesContext { $this->setResponse($this->sendingToWithDirectUrl($user, $verb, $url)); } + /** + * @When the public sends HTTP method :method to URL :url with password :password + * + * @param string $method + * @param string $url + * @param string $password + * + * @return void + */ + public function thePublicSendsHttpMethodToUrlWithPassword(string $method, string $url, string $password): void { + $password = $this->getActualPassword($password); + $token = $this->shareNgGetLastCreatedLinkShareToken(); + $fullUrl = $this->getBaseUrl() . $url; + $headers = [ + 'Public-Token' => $token + ]; + $this->setResponse( + HttpRequestHelper::sendRequest( + $fullUrl, + $this->getStepLineRef(), + $method, + "public", + $password, + $headers + ) + ); + } + /** * @When /^user "([^"]*)" sends HTTP method "([^"]*)" to URL "([^"]*)" with headers$/ * diff --git a/tests/acceptance/features/apiCollaboration/wopi.feature b/tests/acceptance/features/apiCollaboration/wopi.feature index 6a468332ff..ca6eff41fe 100644 --- a/tests/acceptance/features/apiCollaboration/wopi.feature +++ b/tests/acceptance/features/apiCollaboration/wopi.feature @@ -171,3 +171,54 @@ Feature: collaboration (wopi) | app-endpoint | | /app/open?file_id=<>&app_name=FakeOffice | | /app/open?file_id=<> | + + + Scenario Outline: public user opens file with .odt extension + Given user "Alice" has uploaded file "filesForUpload/simple.odt" to "simple.odt" + And we save it into "FILEID" + And user "Alice" has created the following resource link share: + | resource | simple.odt | + | space | Personal | + | permissionsRole | view | + | password | %public% | + When the public sends HTTP method "POST" to URL "" with password "%public%" + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "app_url", + "method", + "form_parameters" + ], + "properties": { + "app_url": { + "type": "string", + "pattern": "^.*\\?WOPISrc=.*wopi%2Ffiles%2F[a-fA-F0-9]{64}$" + }, + "method": { + "const": "POST" + }, + "form_parameters": { + "type": "object", + "required": [ + "access_token", + "access_token_ttl" + ], + "properties": { + "access_token": { + "type": "string" + }, + "access_token_ttl": { + "type": "string" + } + } + } + } + } + """ + Examples: + | app-endpoint | + | /app/open?file_id=<>&app_name=FakeOffice | + | /app/open?file_id=<> |