Skip to content

Commit

Permalink
add tests to check activites of file after public edits it
Browse files Browse the repository at this point in the history
Signed-off-by: prashant-gurung899 <[email protected]>
  • Loading branch information
prashant-gurung899 committed Oct 2, 2024
1 parent 879dfa7 commit df1da2c
Show file tree
Hide file tree
Showing 3 changed files with 501 additions and 14 deletions.
50 changes: 36 additions & 14 deletions tests/acceptance/bootstrap/PublicWebDavContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,23 @@ public function thePublicDeletesFileFolderFromTheLastPublicLinkShareUsingThePubl

/**
* @param string $fileName
* @param string $publicWebDAVAPIVersion
* @param string $password
*
* @return ResponseInterface
*/
public function deleteFileFromPublicShare(string $fileName, string $publicWebDAVAPIVersion, string $password = ""):ResponseInterface {
public function deleteFileFromPublicShare(string $fileName, string $password = ""):ResponseInterface {
$token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken();
$davPath = WebDavHelper::getDavPath(
$token,
0,
"public-files-$publicWebDAVAPIVersion"
"public-files-new"
);
$password = $this->featureContext->getActualPassword($password);
$fullUrl = $this->featureContext->getBaseUrl() . "/$davPath$fileName";
$userName = $this->getUsernameForPublicWebdavApi(
$token,
$password,
$publicWebDAVAPIVersion
"new"
);
$headers = [
'X-Requested-With' => 'XMLHttpRequest'
Expand All @@ -154,6 +153,19 @@ public function deleteFileFromPublicShare(string $fileName, string $publicWebDAV
);
}

/**
* @Given /^the public has deleted (?:file|folder|entry) "([^"]*)" from the last public link share with password "([^"]*)" using the public WebDAV API$/
*
* @param string $file
* @param string $password
*
* @return void
*/
public function thePublicHasDeletedFileFromTheLastPublicLinkShareUsingThePasswordAndNewPublicWebdavApi(string $file, string $password): void {
$response = $this->deleteFileFromPublicShare($file, $password);
$this->featureContext->theHTTPStatusCodeShouldBe([201, 204], "", $response);
}

/**
* @When /^the public deletes (?:file|folder|entry) "([^"]*)" from the last public link share using the password "([^"]*)" and (old|new) public WebDAV API$/
*
Expand Down Expand Up @@ -534,26 +546,41 @@ public function thePublicHasUploadedFileWithContentWithAutoRenameMode(string $fi
* @param string $filename target file name
* @param string $password
* @param string $body content to upload
* @param string $publicWebDAVAPIVersion
*
* @return ResponseInterface
*/
public function publiclyUploadingContentWithPassword(
string $filename,
string $password = '',
string $body = 'test',
string $publicWebDAVAPIVersion = "old"
):ResponseInterface {
return $this->publicUploadContent(
$filename,
$password,
$body,
true,
[],
$publicWebDAVAPIVersion
);
}

/**
* @Given /^the public has uploaded file "([^"]*)" with content "([^"]*)" and password "([^"]*)" to the last link share using the public WebDAV API$/
*
* @param string $filename
* @param string $content
* @param string $password
*
* @return void
*/
public function thePublicHasUploadedFileWithPasswordAndContentUsingTheNewPublicWebdavApi(string $filename, string $content = 'test', string $password = ''): void {
$response = $this->publiclyUploadingContentWithPassword(
$filename,
$password,
$content,
);
$this->featureContext->theHTTPStatusCodeShouldBe([201, 204], "", $response);
}

/**
* @When /^the public uploads file "([^"]*)" with password "([^"]*)" and content "([^"]*)" using the (old|new) public WebDAV API$/
*
Expand Down Expand Up @@ -1690,7 +1717,6 @@ public function theMtimeOfFileInTheLastSharedPublicLinkUsingTheWebdavApiShouldNo
* @param string $body
* @param bool $autoRename
* @param array $additionalHeaders
* @param string $publicWebDAVAPIVersion
*
* @return ResponseInterface|null
*/
Expand All @@ -1700,11 +1726,7 @@ public function publicUploadContent(
string $body = 'test',
bool $autoRename = false,
array $additionalHeaders = [],
string $publicWebDAVAPIVersion = "old"
):?ResponseInterface {
if ($publicWebDAVAPIVersion === "old") {
return null;
}
$password = $this->featureContext->getActualPassword($password);
if ($this->featureContext->isUsingSharingNG()) {
$token = $this->featureContext->shareNgGetLastCreatedLinkShareToken();
Expand All @@ -1714,13 +1736,13 @@ public function publicUploadContent(
$davPath = WebDavHelper::getDavPath(
$token,
0,
"public-files-$publicWebDAVAPIVersion"
"public-files-new"
);
$url = $this->featureContext->getBaseUrl() . "/$davPath";
$userName = $this->getUsernameForPublicWebdavApi(
$token,
$password,
$publicWebDAVAPIVersion
"new"
);

$filename = \implode(
Expand Down
1 change: 1 addition & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ default:
- FeatureContext: *common_feature_context_params
- SharingNgContext:
- GraphContext:
- PublicWebDavContext:

apiCollaboration:
paths:
Expand Down
Loading

0 comments on commit df1da2c

Please sign in to comment.