Skip to content

Commit

Permalink
Add api acceptance tests for checking the preview of public link shar…
Browse files Browse the repository at this point in the history
…ed file
  • Loading branch information
dpakach committed Dec 11, 2019
1 parent 1cd3125 commit d47fa25
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/acceptance/features/apiShareOperations/accessToShare.feature
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,51 @@ Feature: sharing
| ocs_api_version | ocs_status_code |
| 1 | 100 |
| 2 | 200 |

@public_link_share-feature-required
Scenario: Access to the preview of password protected public link
Given the administrator has enabled DAV tech_preview
And user "user0" has uploaded file "filesForUpload/testavatar.jpg" to "testavatar.jpg"
And user "user0" has created a public link share with settings
| path | /testavatar.jpg |
| permissions | change |
| password | testpass1 |
When the public accesses the preview of file "testavatar.jpg" from the last shared public link using the sharing API
Then the HTTP status code should be "404"

@public_link_share-feature-required
Scenario: Access to the preview of public shared file without password
Given the administrator has enabled DAV tech_preview
And user "user0" has uploaded file "filesForUpload/testavatar.jpg" to "testavatar.jpg"
And user "user0" has created a public link share with settings
| path | /testavatar.jpg |
| permissions | change |
When the public accesses the preview of file "testavatar.jpg" from the last shared public link using the sharing API
Then the HTTP status code should be "200"

@public_link_share-feature-required
Scenario: Access to the preview of password protected public shared file inside a folder
Given the administrator has enabled DAV tech_preview
And user "user0" has uploaded file "filesForUpload/testavatar.jpg" to "FOLDER/testavatar.jpg"
And user "user0" has moved file "textfile0.txt" to "FOLDER/textfile0.txt"
And user "user0" has created a public link share with settings
| path | /FOLDER |
| permissions | change |
| password | testpass1 |
When the public accesses the preview of file "testavatar.jpg" from the last shared public link using the sharing API
Then the HTTP status code should be "404"
When the public accesses the preview of file "textfile0.txt" from the last shared public link using the sharing API
Then the HTTP status code should be "404"

@public_link_share-feature-required
Scenario: Access to the preview of public shared file inside a folder without password
Given the administrator has enabled DAV tech_preview
And user "user0" has uploaded file "filesForUpload/testavatar.jpg" to "FOLDER/testavatar.jpg"
And user "user0" has moved file "textfile0.txt" to "FOLDER/textfile0.txt"
And user "user0" has created a public link share with settings
| path | /FOLDER |
| permissions | change |
When the public accesses the preview of file "testavatar.jpg" from the last shared public link using the sharing API
Then the HTTP status code should be "200"
When the public accesses the preview of file "textfile0.txt" from the last shared public link using the sharing API
Then the HTTP status code should be "200"
29 changes: 29 additions & 0 deletions tests/acceptance/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -1958,6 +1958,35 @@ public function getLastShareToken() {
return $this->lastShareData->data->token;
}

/**
* Send request for preview of a file in a public link
*
* @param string $fileName
* @param string $token
*
* @return void
*/
public function getPublicPreviewOfFile($fileName, $token) {
$url = $this->getBaseUrl() .
"/index.php/apps/files_sharing/ajax/publicpreview.php" .
"?file=$fileName&t=$token";
$resp = HttpRequestHelper::get($url);
$this->setResponse($resp);
}

/**
* @When the public accesses the preview of file :path from the last shared public link using the sharing API
*
* @param string $path
*
* @return void
*/
public function thePublicAccessesThePreviewOfTheSharedFileUsingTheSharingApi($path) {
$shareData = $this->getLastShareData();
$token = (string)$shareData->data->token;
$this->getPublicPreviewOfFile($path, $token);
}

/**
* replace values from table
*
Expand Down

0 comments on commit d47fa25

Please sign in to comment.