[tests-only] test webdav previews - #37166
Conversation
|
@individual-it @swoichha Remember that the scenarios will fail on older ownCloud. So |
Codecov Report
@@ Coverage Diff @@
## master #37166 +/- ##
=========================================
Coverage 64.92% 64.92%
Complexity 19148 19148
=========================================
Files 1267 1267
Lines 74895 74895
Branches 1331 1331
=========================================
Hits 48626 48626
Misses 25877 25877
Partials 392 392
Continue to review full report at Codecov.
|
5a7e60e to
0b10f8a
Compare
12c67b9 to
978de97
Compare
| $path = \str_replace($urlSpecialChar[0], $urlSpecialChar[1], $path); | ||
|
|
||
| if (!empty($urlParameter)) { | ||
| $urlParameter = http_build_query($urlParameter, '', '&'); |
There was a problem hiding this comment.
| $urlParameter = http_build_query($urlParameter, '', '&'); | |
| $urlParameter = \http_build_query($urlParameter, '', '&'); |
| Scenario: download previews of other users files | ||
| Given user "user1" has been created with default attributes and without skeleton files | ||
| And user "user0" has uploaded file "filesForUpload/lorem.txt" to "/parent.txt" | ||
| When user "user1" downloads the preview of "/parent.txt" with width "32" and height "32" using the WebDAV API |
There was a problem hiding this comment.
this step only downloads own previews not other users previews. We need an other step. something like
| When user "user1" downloads the preview of "/parent.txt" with width "32" and height "32" using the WebDAV API | |
| When user "user1" downloads the preview of "/parent.txt" of user "user0" with width "32" and height "32" using the WebDAV API |
| Then the HTTP status code should be "404" | ||
| And the value of the item "/d:error/s:exception" in the response should be "Sabre\DAV\Exception\NotFound" | ||
|
|
||
| Scenario: set maximum size of previews |
There was a problem hiding this comment.
this scenario should set preview_max_x & preview_max_y and see what happens when a bigger preview is requested
see https://doc.owncloud.com/server/admin_manual/configuration/files/previews_configuration.html#maximum-preview-size
4c7eadb to
bed149d
Compare
| @@ -0,0 +1,129 @@ | |||
| @api @TestAlsoOnExternalUserBackend | |||
| Feature: previews of files downloaded thought the webdav API | |||
There was a problem hiding this comment.
| Feature: previews of files downloaded thought the webdav API | |
| Feature: previews of files downloaded through the webdav API |
| * @param array $urlParameter | ||
| * @param string $user2 |
There was a problem hiding this comment.
Please write a line what these arguments are. Not really clear what it is.
There was a problem hiding this comment.
Okay. I think $user2 does not need to be documented. If it should be then can you suggest something?
There was a problem hiding this comment.
Please mention that the DAV request is sent to the dav-path of $user2's file
bed149d to
b863ba0
Compare
| Then the HTTP status code should be "200" | ||
| And the downloaded image should be "32" pixel wide and "32" pixel high | ||
|
|
||
| Scenario Outline: download previews of different file types |
There was a problem hiding this comment.
| Scenario Outline: download previews of different file types | |
| Scenario Outline: download previews of file types that doesn't support preview |
| And the value of the item "/d:error/s:message" in the response should be "File with name parent.txt could not be located" | ||
| And the value of the item "/d:error/s:exception" in the response should be "Sabre\DAV\Exception\NotFound" | ||
|
|
||
| Scenario: disable previews |
There was a problem hiding this comment.
| Scenario: disable previews | |
| Scenario: Download file previews when it is disabled by the administrator |
| $client = null | ||
| $client = null, | ||
| $urlParameter = [], | ||
| $user2 = null |
There was a problem hiding this comment.
| $user2 = null | |
| $doDavRequestAsUser = null |
| * @param int $timeout | ||
| * @param Client|null $client | ||
| * @param array $urlParameter to concatenate with path | ||
| * @param string $user2 |
There was a problem hiding this comment.
| * @param string $user2 | |
| * @param string $doDavRequestAsUser run the DAV as this user, if null its same as $user |
| $password = null | ||
| $password = null, | ||
| $urlParameter = [], | ||
| $user2 = null |
There was a problem hiding this comment.
lets rename that variable like in the helper
| * | ||
| * @param $user1 | ||
| * @param $path | ||
| * @param $user2 |
There was a problem hiding this comment.
same here, lets have better variable names
individual-it
left a comment
There was a problem hiding this comment.
better variable names would make the code easier to understand
6bbc098 to
bd5a965
Compare
phil-davis
left a comment
There was a problem hiding this comment.
A few little things, and suggested refactoring to DRY code a bit.
| $urlParameter = [ | ||
| 'x' => $width, | ||
| 'y' => $height, | ||
| 'forceIcon' => '0', | ||
| 'preview' => '1' | ||
| ]; | ||
| $this->response = $this->makeDavRequest( | ||
| $user, "GET", $path, [], null, "files", 2, false, null, $urlParameter | ||
| ); |
There was a problem hiding this comment.
| $urlParameter = [ | |
| 'x' => $width, | |
| 'y' => $height, | |
| 'forceIcon' => '0', | |
| 'preview' => '1' | |
| ]; | |
| $this->response = $this->makeDavRequest( | |
| $user, "GET", $path, [], null, "files", 2, false, null, $urlParameter | |
| ); | |
| $this->downloadPreviewOfOtherUser($user, $path, $user, $width, $height); |
IMO this will work and avoid duplicating the $urlParameter variable setting.
| } | ||
|
|
||
| /** | ||
| * @Then the downloaded image should be :width pixel wide and :height pixel high |
There was a problem hiding this comment.
| * @Then the downloaded image should be :width pixel wide and :height pixel high | |
| * @Then the downloaded image should be :width pixels wide and :height pixels high |
| Then the HTTP status code should be "200" | ||
| And the downloaded image should be "32" pixel wide and "32" pixel high | ||
|
|
||
| Scenario Outline: download previews of file types that doesn't support preview |
There was a problem hiding this comment.
| Scenario Outline: download previews of file types that doesn't support preview | |
| Scenario Outline: download previews of file types that don't support preview |
| Then the HTTP status code should be "404" | ||
| And the value of the item "/d:error/s:exception" in the response should be "Sabre\DAV\Exception\NotFound" | ||
|
|
||
| Scenario: set maximum size of previews |
There was a problem hiding this comment.
| Scenario: set maximum size of previews | |
| Scenario: unset maximum size of previews |
This scenario is actually testing that the maximum size of previews can be undefined.
Then, as @individual-it says, in another PR we can add test scenarios that set the max size to various values and check what happens when we ask for a bigger-size preview. Or you can add those now, since there are some changes to do anyway.
a6ad4f8 to
0031158
Compare
0031158 to
2b98989
Compare
2b98989 to
0cc0426
Compare
phil-davis
left a comment
There was a problem hiding this comment.
Let's get this merged, and then extra scenarios can be added in a later PR to test setting the maximum size of previews.
| When the administrator updates system config key "preview_max_x" with value "null" using the occ command | ||
| And the administrator updates system config key "preview_max_y" with value "null" using the occ command |
There was a problem hiding this comment.
I thought that the test would be something like:
| When the administrator updates system config key "preview_max_x" with value "null" using the occ command | |
| And the administrator updates system config key "preview_max_y" with value "null" using the occ command | |
| When the administrator updates system config key "preview_max_x" with value "32" using the occ command | |
| And the administrator updates system config key "preview_max_y" with value "32" using the occ command |
And then try to download a preview of size 64x64.
And see what happens.
|
Ooops - I meant to get this squashed, and forgot before merging. Too late now! |
|
The new |
Description
WebDAV API test for testing the previews of different types of files like text, images, pdf, etc. with valid as well as invalid preview size.
Related Issue
#37156
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: