Skip to content

[tests-only] test webdav previews - #37166

Merged
phil-davis merged 8 commits into
masterfrom
testWebDaVPreviews
Apr 9, 2020
Merged

[tests-only] test webdav previews#37166
phil-davis merged 8 commits into
masterfrom
testWebDaVPreviews

Conversation

@individual-it

@individual-it individual-it commented Mar 25, 2020

Copy link
Copy Markdown
Member

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?

  • locally

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

@phil-davis

Copy link
Copy Markdown
Contributor

@individual-it @swoichha
PR #37173 has been merge to master. That should have fixed this issue. You will need to rebase this PR and then write the test scenarios so that they pass (with current master you should get "nice" 400 responses)

Remember that the scenarios will fail on older ownCloud. So skipOnOcV10.3 and skipOnOcV10.4.0

@codecov

codecov Bot commented Mar 30, 2020

Copy link
Copy Markdown

Codecov Report

Merging #37166 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@            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           
Flag Coverage Δ Complexity Δ
#javascript 54.14% <ø> (ø) 0.00 <ø> (ø)
#phpunit 66.12% <ø> (ø) 19148.00 <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8ff9f92...0cc0426. Read the comment docs.

@swoichha
swoichha force-pushed the testWebDaVPreviews branch 3 times, most recently from 5a7e60e to 0b10f8a Compare March 31, 2020 05:33
Comment thread tests/acceptance/features/apiWebdavPreviews/previews.feature
@swoichha
swoichha force-pushed the testWebDaVPreviews branch 2 times, most recently from 12c67b9 to 978de97 Compare April 2, 2020 07:52
Comment thread tests/TestHelpers/WebDavHelper.php Outdated
$path = \str_replace($urlSpecialChar[0], $urlSpecialChar[1], $path);

if (!empty($urlParameter)) {
$urlParameter = http_build_query($urlParameter, '', '&');

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this step only downloads own previews not other users previews. We need an other step. something like

Suggested change
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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@swoichha
swoichha force-pushed the testWebDaVPreviews branch 2 times, most recently from 4c7eadb to bed149d Compare April 3, 2020 08:07
@@ -0,0 +1,129 @@
@api @TestAlsoOnExternalUserBackend
Feature: previews of files downloaded thought the webdav API

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Feature: previews of files downloaded thought the webdav API
Feature: previews of files downloaded through the webdav API

@jasson99
jasson99 marked this pull request as ready for review April 3, 2020 10:51
Comment thread tests/TestHelpers/WebDavHelper.php Outdated
Comment on lines +346 to +347
* @param array $urlParameter
* @param string $user2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write a line what these arguments are. Not really clear what it is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I think $user2 does not need to be documented. If it should be then can you suggest something?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mention that the DAV request is sent to the dav-path of $user2's file

@swoichha
swoichha force-pushed the testWebDaVPreviews branch from bed149d to b863ba0 Compare April 3, 2020 11:47
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Scenario: disable previews
Scenario: Download file previews when it is disabled by the administrator

Comment thread tests/TestHelpers/WebDavHelper.php Outdated
$client = null
$client = null,
$urlParameter = [],
$user2 = null

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$user2 = null
$doDavRequestAsUser = null

Comment thread tests/TestHelpers/WebDavHelper.php Outdated
* @param int $timeout
* @param Client|null $client
* @param array $urlParameter to concatenate with path
* @param string $user2

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param string $user2
* @param string $doDavRequestAsUser run the DAV as this user, if null its same as $user

Talank
Talank previously approved these changes Apr 8, 2020

@Talank Talank left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@jasson99
jasson99 dismissed Talank’s stale review April 8, 2020 04:02

more reviews needed

$password = null
$password = null,
$urlParameter = [],
$user2 = null

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets rename that variable like in the helper

*
* @param $user1
* @param $path
* @param $user2

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, lets have better variable names

@individual-it individual-it left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better variable names would make the code easier to understand

@swoichha
swoichha force-pushed the testWebDaVPreviews branch from 6bbc098 to bd5a965 Compare April 8, 2020 06:45
Comment thread tests/acceptance/features/apiWebdavPreviews/previews.feature
@swoichha
swoichha requested a review from phil-davis April 8, 2020 09:10

@phil-davis phil-davis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few little things, and suggested refactoring to DRY code a bit.

Comment thread tests/TestHelpers/WebDavHelper.php
Comment on lines +2943 to +2966
$urlParameter = [
'x' => $width,
'y' => $height,
'forceIcon' => '0',
'preview' => '1'
];
$this->response = $this->makeDavRequest(
$user, "GET", $path, [], null, "files", 2, false, null, $urlParameter
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$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.

Comment thread tests/acceptance/features/bootstrap/WebDav.php
}

/**
* @Then the downloaded image should be :width pixel wide and :height pixel high

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

@swoichha
swoichha force-pushed the testWebDaVPreviews branch from a6ad4f8 to 0031158 Compare April 8, 2020 12:49
@swoichha
swoichha requested a review from phil-davis April 8, 2020 12:49
Comment thread tests/acceptance/features/apiWebdavPreviews/previews.feature
@swoichha
swoichha force-pushed the testWebDaVPreviews branch from 0031158 to 2b98989 Compare April 9, 2020 03:29
@swoichha
swoichha force-pushed the testWebDaVPreviews branch from 2b98989 to 0cc0426 Compare April 9, 2020 07:05
@swoichha
swoichha requested a review from phil-davis April 9, 2020 08:22

@phil-davis phil-davis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this merged, and then extra scenarios can be added in a later PR to test setting the maximum size of previews.

Comment on lines +136 to +137
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that the test would be something like:

Suggested change
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.

@phil-davis
phil-davis merged commit f78f3a8 into master Apr 9, 2020
@delete-merged-branch
delete-merged-branch Bot deleted the testWebDaVPreviews branch April 9, 2020 09:02
@phil-davis

Copy link
Copy Markdown
Contributor

Ooops - I meant to get this squashed, and forgot before merging. Too late now!

@phil-davis

Copy link
Copy Markdown
Contributor

The new apiWebdavPreviews did not get added to .drone.star CI. So actually these tests are not running in CI. Fixed in PR #37274

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants