From 7dbfcf63e0506de51d51c55279f739599285608d Mon Sep 17 00:00:00 2001 From: Swikriti Tripathi Date: Thu, 15 Dec 2022 14:20:04 +0545 Subject: [PATCH] Adds api tests to download folder from public link --- tests/acceptance/config/behat.yml | 1 + ...ected-failures-localAPI-on-OCIS-storage.md | 3 ++ .../publicLinkDownload.feature | 43 +++++++++++++++++++ .../features/bootstrap/SpacesContext.php | 32 ++++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 tests/acceptance/features/apiSpacesShares/publicLinkDownload.feature diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 4c83ec6859..3a9fc84427 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -73,6 +73,7 @@ default: - WebDavPropertiesContext: - TUSContext: - SpacesTUSContext: + - ArchiverContext: apiContract: paths: diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index 4073214d05..e1ed48cff3 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -79,5 +79,8 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiCors/cors.feature:67](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiCors/cors.feature#L67) - [apiCors/cors.feature:68](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiCors/cors.feature#L68) +#### [Public cannot download folder via the public link of the folder inside the project space](https://github.com/owncloud/ocis/issues/5229) +- [apiSpacesShares/publicLinkDownload.feature:31](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/publicLinkDownload.feature#L31) + #### [A User can get information of another user with Graph API](https://github.com/owncloud/ocis/issues/5125) - [apiGraph/getUser.feature:23](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L23) diff --git a/tests/acceptance/features/apiSpacesShares/publicLinkDownload.feature b/tests/acceptance/features/apiSpacesShares/publicLinkDownload.feature new file mode 100644 index 0000000000..754bbd9e5d --- /dev/null +++ b/tests/acceptance/features/apiSpacesShares/publicLinkDownload.feature @@ -0,0 +1,43 @@ +@api @skipOnOcV10 +Feature: Public can download folders from project space public link + As a public + I want to be able to download folder from public link + So that I can gain access to it's contents + + Background: + Given these users have been created with default attributes and without skeleton files: + | username | + | Alice | + | Brian | + And using spaces DAV path + And the administrator has given "Alice" the role "Space Admin" using the settings api + And user "Alice" has created a space "new-space" with the default quota using the GraphApi + + + Scenario: download a folder from public link of a space + Given user "Alice" has created a public link share of the space "new-space" with settings: + | permissions | 1 | + | name | someName | + And user "Alice" has created a folder "NewFolder" in space "new-space" + And user "Alice" has uploaded a file inside space "new-space" with content "some content" to "NewFolder/test.txt" + When public downloads the folder "NewFolder" of space "new-space" from the last created public link of "Alice" using the resource id + Then the HTTP status code should be "200" + And the downloaded tar archive should contain these files: + | name | content | + | NewFolder/test.txt | some content | + + @issue-5229 + Scenario: download a folder from public link of a folder inside a space + Given user "Alice" has created a folder "NewFolder" in space "new-space" + And user "Alice" has created a folder "NewFolder/folder" in space "new-space" + And user "Alice" has uploaded a file inside space "new-space" with content "some content" to "NewFolder/folder/test.txt" + And user "Alice" has created a public link share inside of space "new-space" with settings: + | path | NewFolder | + | shareType | 3 | + | permissions | 1 | + | name | public link | + When public downloads the folder "NewFolder/folder" of space "new-space" from the last created public link of "Alice" using the resource id + Then the HTTP status code should be "200" + And the downloaded tar archive should contain these files: + | name | content | + | folder/test.txt | some content | diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 7a57335933..fbe4cd44f4 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -73,6 +73,12 @@ class SpacesContext implements Context { * @var FilesVersionsContext */ private FilesVersionsContext $filesVersionsContext; + + /** + * @var ArchiverContext + */ + private ArchiverContext $archiverContext; + /** * @var string */ @@ -457,6 +463,7 @@ class SpacesContext implements Context { $this->favoritesContext = $environment->getContext('FavoritesContext'); $this->checksumContext = $environment->getContext('ChecksumContext'); $this->filesVersionsContext = $environment->getContext('FilesVersionsContext'); + $this->archiverContext = $environment->getContext('ArchiverContext'); // Run the BeforeScenario function in OCSContext to set it up correctly $this->ocsContext->before($scope); $this->baseUrl = \trim($this->featureContext->getBaseUrl(), "/"); @@ -3088,4 +3095,29 @@ class SpacesContext implements Context { } } } + + /** + * @When /^public downloads the folder "([^"]*)" of space "([^"]*)" from the last created public link of "([^"]*)" using the resource id$/ + * @param string $resource + * @param string $space + * @param string $owner + * + * @return void + * @throws GuzzleException + */ + public function publicDownloadsTheFolderFromTheLastCreatedPublicLink(string $resource, string $space, string $owner) + { + $token = $this->featureContext->getLastPublicShareToken(); + $resourceId = $this->getFolderId($owner, $space, $resource); + $queryString = 'public-token='.$token.'&id='.$resourceId; + $this->featureContext->setResponse( + HttpRequestHelper::get( + $this->featureContext->getBaseUrl() . '/archiver?' . $queryString, + '', + '', + '', + ) + ); + } + }