added test for previewing shared resource inside project space (#7544)

This commit is contained in:
Prajwol Amatya
2023-10-26 12:59:34 +05:45
committed by GitHub
parent 890b8bf991
commit 2bee588977
4 changed files with 61 additions and 0 deletions

View File

@@ -84,6 +84,7 @@ class SharingHelper {
* @param string|null $expireDate An expire date for public link shares.
* This argument expects a date string
* in the format 'YYYY-MM-DD'.
* @param string|null $space_ref
* @param int $ocsApiVersion
* @param int $sharingApiVersion
* @param string $sharingApp
@@ -104,6 +105,7 @@ class SharingHelper {
$permissions = null,
?string $linkName = null,
?string $expireDate = null,
?string $space_ref = null,
int $ocsApiVersion = 1,
int $sharingApiVersion = 1,
string $sharingApp = 'files_sharing'
@@ -157,6 +159,9 @@ class SharingHelper {
if ($expireDate !== null) {
$fd['expireDate'] = $expireDate;
}
if ($space_ref !== null) {
$fd['space_ref'] = $space_ref;
}
$headers = ['OCS-APIREQUEST' => 'true'];
return HttpRequestHelper::post(
$fullUrl,

View File

@@ -41,3 +41,26 @@ Feature: Preview file in project space
| filesForUpload/example.gif | example.gif | 36 | 36 |
| filesForUpload/example.gif | example.gif | 1200 | 1200 |
| filesForUpload/example.gif | example.gif | 1280 | 1280 |
Scenario Outline: download preview of shared file inside project space
Given user "Brian" has been created with default attributes and without skeleton files
And user "Alice" has uploaded a file from "<source>" to "<destination>" via TUS inside of the space "previews of the files" using the WebDAV API
And user "Alice" has shared resource "<destination>" inside space "previews of the files" with user "Brian"
When user "Brian" downloads the preview of shared resource "/Shares/<destination>" with width "32" and height "32" using the WebDAV API
Then the HTTP status code should be "200"
And the downloaded image should be "32" pixels wide and "32" pixels high
Examples:
| source | destination |
| filesForUpload/testavatar.png | testavatar.png |
| filesForUpload/lorem.txt | lorem.txt |
Scenario: download preview of file inside shared folder in project space
Given user "Brian" has been created with default attributes and without skeleton files
And user "Alice" has created a folder "folder" in space "previews of the files"
And user "Alice" has uploaded a file inside space "previews of the files" with content "test" to "/folder/lorem.txt"
And user "Alice" has shared resource "/folder" inside space "previews of the files" with user "Brian"
When user "Brian" downloads the preview of shared resource "Shares/folder/lorem.txt" with width "32" and height "32" using the WebDAV API
Then the HTTP status code should be "200"
And the downloaded image should be "32" pixels wide and "32" pixels high

View File

@@ -806,6 +806,7 @@ trait Sharing {
* @param string|int|string[]|int[]|null $permissions
* @param string|null $linkName
* @param string|null $expireDate
* @param string|null $space_ref
* @param string $sharingApp
*
* @return ResponseInterface
@@ -822,6 +823,7 @@ trait Sharing {
$permissions = null,
?string $linkName = null,
?string $expireDate = null,
?string $space_ref = null,
string $sharingApp = 'files_sharing'
): ResponseInterface {
$userActual = $this->getActualUsername($user);
@@ -842,6 +844,7 @@ trait Sharing {
$permissions,
$linkName,
$expireDate,
$space_ref,
$this->ocsApiVersion,
$this->sharingApiVersion,
$sharingApp

View File

@@ -3704,4 +3704,34 @@ class SpacesContext implements Context {
)
);
}
/**
* @Given user :sharer has shared resource :path inside space :space with user :sharee
*
* @param $sharer string
* @param $path string
* @param $space string
* @param $sharee string
*
* @return void
* @throws GuzzleException
*/
public function userHasSharedResourceInsideSpaceWithUser(string $sharer, string $path, string $space, string $sharee): void {
$sharer = $this->featureContext->getActualUsername($sharer);
$resource_id = $this->getResourceId($sharer, $space, $path);
$response = $this->featureContext->createShare(
$sharer,
$path,
'0',
$this->featureContext->getActualUsername($sharee),
null,
null,
null,
null,
null,
$resource_id
);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
$this->ocsContext->theOCSStatusCodeShouldBe("100,200", "", $response);
}
}