From 42dffaf1b638850d124189d2b9e99eecf44d481b Mon Sep 17 00:00:00 2001 From: pradip Date: Thu, 5 Sep 2024 15:09:53 +0545 Subject: [PATCH] test: add tests for opening file with non-existing fileId --- tests/acceptance/bootstrap/FeatureContext.php | 1 + .../features/apiCollaboration/wopi.feature | 50 +++++++++++++++---- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/tests/acceptance/bootstrap/FeatureContext.php b/tests/acceptance/bootstrap/FeatureContext.php index f7a16ef3c..a2385f3d8 100644 --- a/tests/acceptance/bootstrap/FeatureContext.php +++ b/tests/acceptance/bootstrap/FeatureContext.php @@ -1247,6 +1247,7 @@ class FeatureContext extends BehatVariablesContext { /** * @When /^user "([^"]*)" sends HTTP method "([^"]*)" to URL "([^"]*)"$/ + * @When /^user "([^"]*)" tries to send HTTP method "([^"]*)" to URL "([^"]*)"$/ * * @param string $user * @param string $verb diff --git a/tests/acceptance/features/apiCollaboration/wopi.feature b/tests/acceptance/features/apiCollaboration/wopi.feature index 5977edbec..3b9d38701 100644 --- a/tests/acceptance/features/apiCollaboration/wopi.feature +++ b/tests/acceptance/features/apiCollaboration/wopi.feature @@ -98,10 +98,10 @@ Feature: collaboration (wopi) """ @issue-9928 - Scenario: open text file without app name in url query (MIME type not registered in app-registry) + Scenario: user tries to open text file without app name in url query (MIME type not registered in app-registry) Given user "Alice" has uploaded file "filesForUpload/lorem.txt" to "lorem.txt" And we save it into "FILEID" - When user "Alice" sends HTTP method "POST" to URL "/app/open?file_id=<>" + When user "Alice" tries to send HTTP method "POST" to URL "/app/open?file_id=<>" Then the HTTP status code should be "500" And the JSON data of the response should match """ @@ -226,10 +226,10 @@ Feature: collaboration (wopi) | /app/open?file_id=<> | @issue-9928 - Scenario Outline: open unsupported file format + Scenario Outline: user tries to open unsupported file format Given user "Alice" has uploaded file "filesForUpload/simple.pdf" to "simple.pdf" And we save it into "FILEID" - When user "Alice" sends HTTP method "POST" to URL "" + When user "Alice" tries to send HTTP method "POST" to URL "" Then the HTTP status code should be "500" And the JSON data of the response should match """ @@ -255,11 +255,11 @@ Feature: collaboration (wopi) | /app/open?file_id=<> | - Scenario Outline: open file with non-existing file id + Scenario Outline: user tries to open deleted file Given user "Alice" has uploaded file "filesForUpload/simple.odt" to "simple.odt" And we save it into "FILEID" And user "Alice" has deleted file "/simple.odt" - When user "Alice" sends HTTP method "POST" to URL "" + When user "Alice" tries to send HTTP method "POST" to URL "" Then the HTTP status code should be "404" And the JSON data of the response should match """ @@ -380,10 +380,10 @@ Feature: collaboration (wopi) """ @issue-9928 - Scenario: open text file using open-with-web without app name in url query (MIME type not registered in app-registry) + Scenario: user tries to open text file using open-with-web without app name in url query (MIME type not registered in app-registry) Given user "Alice" has uploaded file "filesForUpload/lorem.txt" to "lorem.txt" And we save it into "FILEID" - When user "Alice" sends HTTP method "POST" to URL "/app/open-with-web?file_id=<>" + When user "Alice" tries to send HTTP method "POST" to URL "/app/open-with-web?file_id=<>" Then the HTTP status code should be "500" And the JSON data of the response should match """ @@ -495,10 +495,10 @@ Feature: collaboration (wopi) | /app/open-with-web?file_id=<>&app_name=FakeOffice&view_mode=write | @issue-9928 - Scenario Outline: open unsupported file format (open-with-web) + Scenario Outline: user tries to open unsupported file format (open-with-web) Given user "Alice" has uploaded file "filesForUpload/simple.pdf" to "simple.pdf" And we save it into "FILEID" - When user "Alice" sends HTTP method "POST" to URL "" + When user "Alice" tries to send HTTP method "POST" to URL "" Then the HTTP status code should be "500" And the JSON data of the response should match """ @@ -522,3 +522,33 @@ Feature: collaboration (wopi) | app-endpoint | | /app/open-with-web?file_id=<>&app_name=FakeOffice | | /app/open-with-web?file_id=<> | + + + Scenario Outline: user tries to open deleted file (open-with-web) + Given user "Alice" has uploaded file "filesForUpload/simple.odt" to "simple.odt" + And we save it into "FILEID" + And user "Alice" has deleted file "/simple.odt" + When user "Alice" tries to send HTTP method "POST" to URL "" + Then the HTTP status code should be "404" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "const": "RESOURCE_NOT_FOUND" + }, + "message": { + "const": "file does not exist" + } + } + } + """ + Examples: + | app-endpoint | + | /app/open-with-web?file_id=<>&app_name=FakeOffice | + | /app/open-with-web?file_id=<> |