From b398cb1b4b742797c29b316ba408c8f0fdc39a54 Mon Sep 17 00:00:00 2001 From: Prajwol Amatya Date: Wed, 21 Aug 2024 16:44:55 +0545 Subject: [PATCH] add test coverage for /app/ endpoint --- tests/acceptance/config/behat.yml | 7 +++ .../apiAppProvider/appProvider.feature | 43 +++++++++++++++++++ .../features/bootstrap/SpacesContext.php | 22 ++++++++++ 3 files changed, 72 insertions(+) create mode 100644 tests/acceptance/features/apiAppProvider/appProvider.feature diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index a587cc247..7bcecc6b3 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -414,6 +414,13 @@ default: - TagContext: - TrashbinContext: + apiAppProvider: + paths: + - "%paths.base%/../features/apiAppProvider" + context: *common_ldap_suite_context + contexts: + - FeatureContext: *common_feature_context_params + extensions: rdx\behatvars\BehatVariablesExtension: ~ diff --git a/tests/acceptance/features/apiAppProvider/appProvider.feature b/tests/acceptance/features/apiAppProvider/appProvider.feature new file mode 100644 index 000000000..1c39b9dee --- /dev/null +++ b/tests/acceptance/features/apiAppProvider/appProvider.feature @@ -0,0 +1,43 @@ +Feature: App Provider + + + Scenario: open file with Collabora + Given user "Alice" has been created with default attributes and without skeleton files + And user "Alice" has uploaded file "filesForUpload/simple.odt" to "simple.odt" + When user "Alice" opens file "simple.odt" with Collabora service + 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": "^https:\\/\\/host\\.docker\\.internal:9980\\/browser\\/8ec5fda\\/cool\\.html\\?WOPISrc=https%3A%2F%2Fhost\\.docker\\.internal%3A9300%2Fwopi%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" + } + } + } + } + } + """ diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 9cf94d860..bbf0de5e7 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -4131,4 +4131,26 @@ class SpacesContext implements Context { ) ); } + + /** + * @When user :user opens file :filename with Collabora service + * + * @param string $user + * @param string $filename + * + * @return void + */ + public function userOpensFileWithCollaboraService(string $user, string $filename): void + { + $fileId = $this->getFileId($user, "Personal", $filename); + $url = $this->featureContext->getBaseUrl() . "/app/open?file_id=$fileId&app_name=Collabora"; + $this->featureContext->setResponse( + HttpRequestHelper::post( + $url, + $this->featureContext->getStepLineRef(), + $user, + $this->featureContext->getPasswordForUser($user) + ) + ); + } }