From e7dcd95735f05db46d5a667d723eb63093ed54a2 Mon Sep 17 00:00:00 2001 From: Swikriti Tripathi Date: Mon, 19 Dec 2022 15:46:51 +0545 Subject: [PATCH] get resource id as public --- .../publicLinkDownload.feature | 4 ++-- .../features/bootstrap/SpacesContext.php | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/acceptance/features/apiSpacesShares/publicLinkDownload.feature b/tests/acceptance/features/apiSpacesShares/publicLinkDownload.feature index 5593a8803cb..588550aadc4 100644 --- a/tests/acceptance/features/apiSpacesShares/publicLinkDownload.feature +++ b/tests/acceptance/features/apiSpacesShares/publicLinkDownload.feature @@ -20,7 +20,7 @@ Feature: Public can download folders from project space public link And user "Alice" has created a public link share of the space "new-space" with settings: | permissions | 1 | | name | someName | - When public downloads the folder "NewFolder" of space "new-space" from the last created public link of "Alice" + When public downloads the folder "NewFolder" from the last created public link using the public files API Then the HTTP status code should be "200" And the downloaded tar archive should contain these files: | name | content | @@ -36,7 +36,7 @@ Feature: Public can download folders from project space public link | 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" + When public downloads the folder "folder" from the last created public link using the public files API Then the HTTP status code should be "200" And the downloaded tar archive should contain these files: | name | content | diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index a6793b821cc..640cf2602ed 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -2966,19 +2966,24 @@ public function reportResponseShouldContain(string $user, string $space, TableNo } /** - * @When /^public downloads the folder "([^"]*)" of space "([^"]*)" from the last created public link of "([^"]*)"$/ + * @When /^public downloads the folder "([^"]*)" from the last created public link using the public files API$/ * * @param string $resource - * @param string $space - * @param string $owner * * @return void - * @throws GuzzleException + * @throws GuzzleException|JsonException */ - public function publicDownloadsTheFolderFromTheLastCreatedPublicLink(string $resource, string $space, string $owner) { + public function publicDownloadsTheFolderFromTheLastCreatedPublicLink(string $resource) { $token = $this->featureContext->getLastPublicShareToken(); - $resourceId = $this->getFolderId($owner, $space, $resource); - $queryString = 'public-token=' . $token . '&id=' . $resourceId; + $response = $this->featureContext->listFolderAndReturnResponseXml( + $token, + $resource, + '0', + ['oc:fileid'], + $this->featureContext->getDavPathVersion() === 1 ? "public-files" : "public-files-new" + ); + $resourceId = json_decode(json_encode($response->xpath("//d:response/d:propstat/d:prop/oc:fileid")), true, 512, JSON_THROW_ON_ERROR); + $queryString = 'public-token=' . $token . '&id=' . $resourceId[0][0]; $this->featureContext->setResponse( HttpRequestHelper::get( $this->featureContext->getBaseUrl() . '/archiver?' . $queryString,