get resource id as public

This commit is contained in:
Swikriti Tripathi
2023-01-05 12:58:17 +05:45
committed by Phil Davis
parent ea9bf8d80b
commit 03139c3ac2
2 changed files with 14 additions and 9 deletions
@@ -3091,19 +3091,24 @@ class SpacesContext implements Context {
}
/**
* @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,