Adds api tests to download folder from public link

This commit is contained in:
Swikriti Tripathi
2023-01-05 12:58:17 +05:45
committed by Phil Davis
parent 2322d3a1d0
commit 7dbfcf63e0
4 changed files with 79 additions and 0 deletions
@@ -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,
'',
'',
'',
)
);
}
}