From 5cfdfec4de228cebace298530867b958ec52629c Mon Sep 17 00:00:00 2001 From: Prajwol Amatya Date: Tue, 17 Sep 2024 17:05:53 +0545 Subject: [PATCH] added test to create odt file inside folder in public space --- .../bootstrap/CollaborationContext.php | 37 ++++++++-- .../features/apiCollaboration/wopi.feature | 68 +++++++++++++++++++ 2 files changed, 100 insertions(+), 5 deletions(-) diff --git a/tests/acceptance/bootstrap/CollaborationContext.php b/tests/acceptance/bootstrap/CollaborationContext.php index c35a124b98..abf6ae73b9 100644 --- a/tests/acceptance/bootstrap/CollaborationContext.php +++ b/tests/acceptance/bootstrap/CollaborationContext.php @@ -122,18 +122,16 @@ class CollaborationContext implements Context { } /** - * @When the public creates a file :file inside the last shared public link folder with password :password using wopi endpoint - * @When the public tries to create a file :file inside the last shared public link folder with password :password using wopi endpoint - * * @param string $file * @param string $password + * @param string $folder * * @return void * @throws GuzzleException */ - public function thePublicCreatesAFileInsideTheLastSharedPublicLinkFolderWithPasswordUsingWopiEndpoint(string $file, string $password): void { + public function createFile(string $file, string $password, string $folder = ""): void { $token = $this->featureContext->shareNgGetLastCreatedLinkShareToken(); - $davPath = WebDavHelper::getDavPath($token, null, "public-files-new"); + $davPath = WebDavHelper::getDavPath($token, null, "public-files-new") . "/$folder"; $response = HttpRequestHelper::sendRequest( $this->featureContext->getBaseUrl() . "/$davPath", $this->featureContext->getStepLineRef(), @@ -164,6 +162,35 @@ class CollaborationContext implements Context { ); } + /** + * @When the public creates a file :file inside the last shared public link folder with password :password using wopi endpoint + * @When the public tries to create a file :file inside the last shared public link folder with password :password using wopi endpoint + * + * @param string $file + * @param string $password + * + * @return void + * @throws GuzzleException + */ + public function thePublicCreatesAFileInsideTheLastSharedPublicLinkFolderWithPasswordUsingWopiEndpoint(string $file, string $password): void { + $this->createFile($file, $password); + } + + /** + * @When the public creates a file :file inside folder :folder in the last shared public link space with password :password using wopi endpoint + * @When the public tries to create a file :file inside folder :folder in the last shared public link space with password :password using wopi endpoint + * + * @param string $file + * @param string $folder + * @param string $password + * + * @return void + * @throws GuzzleException + */ + public function thePublicCreatesAFileInsideFolderInTheLastSharedPublicLinkSpaceWithPasswordUsingWopiEndpoint(string $file, string $folder, string $password): void { + $this->createFile($file, $password, $folder); + } + /** * @When user :user tries to check the information of file :file of space :space using office :app with invalid file-id * diff --git a/tests/acceptance/features/apiCollaboration/wopi.feature b/tests/acceptance/features/apiCollaboration/wopi.feature index 91a9c41ee6..79e9263f81 100644 --- a/tests/acceptance/features/apiCollaboration/wopi.feature +++ b/tests/acceptance/features/apiCollaboration/wopi.feature @@ -1012,3 +1012,71 @@ Feature: collaboration (wopi) } } """ + + @issue-8691 + Scenario Outline: public user with permission edit/upload/createOnly creates odt file inside folder of public space using wopi endpoint + Given using spaces DAV path + And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And user "Alice" has created a space "new-space" with the default quota using the Graph API + And user "Alice" has created a folder "testFolder" in space "new-space" + And user "Alice" has created the following space link share: + | space | new-space | + | permissionsRole | | + | password | %public% | + When the public creates a file "simple.odt" inside folder "testFolder" in the last shared public link space with password "%public%" using wopi endpoint + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "file_id" + ], + "properties": { + "file_id": { + "type": "string", + "pattern": "^%file_id_pattern%$" + } + } + } + """ + And for user "Alice" folder "testFolder" of the space "new-space" should contain these files: + | simple.odt | + Examples: + | permissions-role | + | edit | + | upload | + | createOnly | + + @issue-8691 + Scenario: public user with permission view tries to create odt file inside folder of public space using wopi endpoint + Given using spaces DAV path + And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API + And user "Alice" has created a space "new-space" with the default quota using the Graph API + And user "Alice" has created a folder "testFolder" in space "new-space" + And user "Alice" has created the following space link share: + | space | new-space | + | permissionsRole | view | + | password | %public% | + When the public tries to create a file "simple.odt" inside folder "testFolder" in the last shared public link space with password "%public%" using wopi endpoint + Then the HTTP status code should be "500" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "const": "SERVER_ERROR" + }, + "message": { + "const": "error calling InitiateFileUpload" + } + } + } + """ + And for user "Alice" folder "testFolder" of the space "new-space" should not contain these files: + | simple.odt |