Skip to content

Commit

Permalink
added test for previewing shared resource inside project space (#7544)
Browse files Browse the repository at this point in the history
  • Loading branch information
PrajwolAmatya authored Oct 26, 2023
1 parent 890b8bf commit 2bee588
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/TestHelpers/SharingHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -104,6 +105,7 @@ public static function createShare(
$permissions = null,
?string $linkName = null,
?string $expireDate = null,
?string $space_ref = null,
int $ocsApiVersion = 1,
int $sharingApiVersion = 1,
string $sharingApp = 'files_sharing'
Expand Down Expand Up @@ -157,6 +159,9 @@ public static function createShare(
if ($expireDate !== null) {
$fd['expireDate'] = $expireDate;
}
if ($space_ref !== null) {
$fd['space_ref'] = $space_ref;
}
$headers = ['OCS-APIREQUEST' => 'true'];
return HttpRequestHelper::post(
$fullUrl,
Expand Down
23 changes: 23 additions & 0 deletions tests/acceptance/features/apiSpaces/filePreviews.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions tests/acceptance/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ public function userHasUpdatedTheLastShareOfWith(string $user, string $shareOwne
* @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
Expand All @@ -822,6 +823,7 @@ public function createShare(
$permissions = null,
?string $linkName = null,
?string $expireDate = null,
?string $space_ref = null,
string $sharingApp = 'files_sharing'
): ResponseInterface {
$userActual = $this->getActualUsername($user);
Expand All @@ -842,6 +844,7 @@ public function createShare(
$permissions,
$linkName,
$expireDate,
$space_ref,
$this->ocsApiVersion,
$this->sharingApiVersion,
$sharingApp
Expand Down
30 changes: 30 additions & 0 deletions tests/acceptance/features/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -3704,4 +3704,34 @@ public function userDownloadsTheSpaceUsingTheWebdavApi(string $user, string $spa
)
);
}

/**
* @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);
}
}

0 comments on commit 2bee588

Please sign in to comment.