From 34f979844b5cf5d25cfbfbebc1993a92387f6203 Mon Sep 17 00:00:00 2001 From: Prajwol Amatya <83579989+PrajwolAmatya@users.noreply.github.com> Date: Fri, 18 Aug 2023 11:15:03 +0545 Subject: [PATCH] added tests for reading content of a file by fileId using WebDav API (#7064) --- .drone.star | 1 + tests/acceptance/config/behat.yml | 7 ++ .../getFileByFileId.feature | 108 ++++++++++++++++++ .../features/bootstrap/SpacesContext.php | 13 ++- 4 files changed, 123 insertions(+), 6 deletions(-) create mode 100644 tests/acceptance/features/apiSpacesDavOperation/getFileByFileId.feature diff --git a/.drone.star b/.drone.star index 7577291b471..895d9a7c72f 100644 --- a/.drone.star +++ b/.drone.star @@ -111,6 +111,7 @@ config = { "apiAsyncUpload", "apiDownloads", "apiReshare", + "apiSpacesDavOperation", ], "skip": False, }, diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index e1557b8f4b7..2b11684eb3a 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -219,6 +219,13 @@ default: - FeatureContext: *common_feature_context_params - OcisConfigContext: + apiSpacesDavOperation: + paths: + - '%paths.base%/../features/apiSpacesDavOperation' + context: *common_ldap_suite_context + contexts: + - FeatureContext: *common_feature_context_params + extensions: rdx\behatvars\BehatVariablesExtension: ~ diff --git a/tests/acceptance/features/apiSpacesDavOperation/getFileByFileId.feature b/tests/acceptance/features/apiSpacesDavOperation/getFileByFileId.feature new file mode 100644 index 00000000000..87b3839a308 --- /dev/null +++ b/tests/acceptance/features/apiSpacesDavOperation/getFileByFileId.feature @@ -0,0 +1,108 @@ +Feature: accessing files using file id + As a user + I want to access the files using file id + So that I can get the content of a file + + Background: + Given using spaces DAV path + And user "Alice" has been created with default attributes and without skeleton files + + + Scenario Outline: get content of a file + Given user "Alice" has uploaded file with content "some data" to "/textfile.txt" + And we save it into "FILEID" + When user "Alice" sends HTTP method "GET" to URL "" + Then the HTTP status code should be "200" + And the downloaded content should be "some data" + Examples: + | dav-path | + | /remote.php/dav/spaces/<> | + | /dav/spaces/<> | + + + Scenario Outline: get content of a file inside a folder + Given user "Alice" has created folder "uploadFolder" + And user "Alice" has uploaded file with content "some data" to "uploadFolder/textfile.txt" + And we save it into "FILEID" + When user "Alice" sends HTTP method "GET" to URL "" + Then the HTTP status code should be "200" + And the downloaded content should be "some data" + Examples: + | dav-path | + | /remote.php/dav/spaces/<> | + | /dav/spaces/<> | + + + Scenario Outline: get content of a file inside a project space + Given 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 GraphApi + And user "Alice" has uploaded a file inside space "new-space" with content "some data" to "textfile.txt" + And we save it into "FILEID" + When user "Alice" sends HTTP method "GET" to URL "" + Then the HTTP status code should be "200" + And the downloaded content should be "some data" + Examples: + | dav-path | + | /remote.php/dav/spaces/<> | + | /dav/spaces/<> | + + + Scenario Outline: sharee gets content of a shared file + Given user "Brian" has been created with default attributes and without skeleton files + And user "Alice" has uploaded file with content "some data" to "/textfile.txt" + And we save it into "FILEID" + And user "Alice" has shared file "/textfile.txt" with user "Brian" + And user "Brian" has accepted share "/textfile.txt" offered by user "Alice" + When user "Brian" sends HTTP method "GET" to URL "" + Then the HTTP status code should be "200" + And the downloaded content should be "some data" + Examples: + | dav-path | + | /remote.php/dav/spaces/<> | + | /dav/spaces/<> | + + + Scenario Outline: sharee gets content of a file inside a shared folder + Given user "Brian" has been created with default attributes and without skeleton files + And user "Alice" has created folder "uploadFolder" + And user "Alice" has uploaded file with content "some data" to "uploadFolder/textfile.txt" + And we save it into "FILEID" + And user "Alice" has shared folder "/uploadFolder" with user "Brian" + And user "Brian" has accepted share "/uploadFolder" offered by user "Alice" + When user "Brian" sends HTTP method "GET" to URL "" + Then the HTTP status code should be "200" + And the downloaded content should be "some data" + Examples: + | dav-path | + | /remote.php/dav/spaces/<> | + | /dav/spaces/<> | + + + Scenario Outline: sharee gets content of a file inside a shared space + Given user "Brian" has been created with default attributes and without skeleton files + 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 GraphApi + And user "Alice" has uploaded a file inside space "new-space" with content "some data" to "textfile.txt" + And we save it into "FILEID" + And user "Alice" has shared a space "new-space" with settings: + | shareWith | Brian | + | role | viewer | + When user "Brian" sends HTTP method "GET" to URL "" + Then the HTTP status code should be "200" + And the downloaded content should be "some data" + Examples: + | dav-path | + | /remote.php/dav/spaces/<> | + | /dav/spaces/<> | + + + Scenario Outline: user tries to get content of file owned by others + Given user "Brian" has been created with default attributes and without skeleton files + And user "Alice" has uploaded file with content "some data" to "/textfile.txt" + And we save it into "FILEID" + When user "Brian" sends HTTP method "GET" to URL "" + Then the HTTP status code should be "404" + Examples: + | dav-path | + | /remote.php/dav/spaces/<> | + | /dav/spaces/<> | diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 438641598da..97cbf35a084 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -1160,7 +1160,7 @@ public function theUserCreatesAFolderToAnotherOwnerSpaceUsingTheGraphApi( * @param string $content * @param string $destination * - * @return void + * @return string[] * @throws GuzzleException * @throws Exception */ @@ -1169,9 +1169,9 @@ public function theUserUploadsAFileToSpace( string $spaceName, string $content, string $destination - ): void { + ): array { $this->setSpaceIDByName($user, $spaceName); - $this->featureContext->uploadFileWithContent($user, $content, $destination); + return $this->featureContext->uploadFileWithContent($user, $content, $destination); } /** @@ -1784,7 +1784,7 @@ public function copyFilesAndFoldersRequest(string $user, string $fullUrl, array * @param string $fileContent * @param string $destination * - * @return void + * @return string[] * @throws GuzzleException */ public function userHasUploadedFile( @@ -1792,10 +1792,11 @@ public function userHasUploadedFile( string $spaceName, string $fileContent, string $destination - ): void { + ): array { $this->theUserListsAllHisAvailableSpacesUsingTheGraphApi($user); - $this->theUserUploadsAFileToSpace($user, $spaceName, $fileContent, $destination); + $fileId = $this->theUserUploadsAFileToSpace($user, $spaceName, $fileContent, $destination); $this->featureContext->theHTTPStatusCodeShouldBeOr(201, 204); + return $fileId; } /**