Skip to content

Refactor reShare.feature to use the 'shares file with, with permissions' steps#35551

Merged
phil-davis merged 3 commits into
masterfrom
refactor-reShare-feature
Jun 17, 2019
Merged

Refactor reShare.feature to use the 'shares file with, with permissions' steps#35551
phil-davis merged 3 commits into
masterfrom
refactor-reShare-feature

Conversation

@phil-davis

@phil-davis phil-davis commented Jun 17, 2019

Copy link
Copy Markdown
Contributor

Description

While testing re-sharing, and refactoring some of the test scenarios, I discovered some annoyance and error with test code for steps like Given user "user0" has shared file... and When user "user0" shares file... and similar.

The code was always checking that the share that was created was "correct", e.g. it actually got the stated permissions. For Given that is "a good thing", but for When steps we should let the Then steps do the checking.

The extra checking of the resulting share status was overwriting the initial createShare response. And so test scenarios that did a When followed by some checks of the OCS and HTTP status were not actually seeing and checking the real statuses returned by createShare

I also noticed that when sharing a file, the create and delete permissions are not relevant. You can ask for them in the create share request, and they get masked out in the permissions of the created share. This seems reasonable. It would be nice to have some test scenarios that "document" this behavior.

  1. Fix the acceptance test code.
  2. Refactor reShare.feature to use the fixed-up steps
  3. Fixup the test scenarios related to issue when a user that is excluded from sharing tries to share something a success status is returned #33733
  4. Add scenarios to createShare.feature that ask for create+delete on a file share

Related Issue

#33733
owncloud/user_ldap#378
#35558

Motivation and Context

Have fixed and improved sharing API test scenarios.

How Has This Been Tested?

Local CI runs

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:

Open tasks:

  • Backport (if applicable set "backport-request" label and remove when the backport was done)

$this->response = HttpRequestHelper::get(
$fullUrl, $user1, $this->getPasswordForUser($user1)
if ($getShareData) {
$this->response = HttpRequestHelper::get(

@phil-davis phil-davis Jun 17, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Previously the When step execution would do this get of the (hopefully) updated share information. That would overwrite $this->response that was saved from createShare(). And so that messed up the ability to check the real OCS and HTTP status after doing When user shares...

The refactoring here allows Given steps to do the code that they were always doing (they verify that the requested share seems to now exist), while letting When steps work properly.

| shareType | 0 |
| shareWith | user2 |
| permissions | 15 |
And user "user0" has shared file "/textfile0.txt" with user "user1" with permissions 3

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note: when sharing a file, permissions 4 (create) and 8 (delete) are not relevant. If you ask for them, the response comes back (correctly) with them masked out. e.g. ask for permissions 15, actually you only get 3 (read+update), as for permissions 31 and you only get 19 (can reshare+read+update)
So these re-share tests have been refactored to only ask for valid permissions for files.
I will make other sharing test scenarios that properly and separately demonstrate the special behavior when trying to share a file and sking for create and/or delete.

@codecov

codecov Bot commented Jun 17, 2019

Copy link
Copy Markdown

Codecov Report

Merging #35551 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #35551   +/-   ##
=========================================
  Coverage     65.66%   65.66%           
  Complexity    18756    18756           
=========================================
  Files          1222     1222           
  Lines         70872    70872           
  Branches       1289     1289           
=========================================
  Hits          46540    46540           
  Misses        23954    23954           
  Partials        378      378
Flag Coverage Δ Complexity Δ
#javascript 53.7% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 67.03% <ø> (ø) 18756 <ø> (ø) ⬇️

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 fc3547a...538483b. Read the comment docs.

@codecov

codecov Bot commented Jun 17, 2019

Copy link
Copy Markdown

Codecov Report

Merging #35551 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #35551   +/-   ##
=========================================
  Coverage     65.66%   65.66%           
  Complexity    18756    18756           
=========================================
  Files          1222     1222           
  Lines         70872    70872           
  Branches       1289     1289           
=========================================
  Hits          46540    46540           
  Misses        23954    23954           
  Partials        378      378
Flag Coverage Δ Complexity Δ
#javascript 53.7% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 67.03% <ø> (ø) 18756 <ø> (ø) ⬇️

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 3ddb3bc...d0416f0. Read the comment docs.

*/
public function userSharesFileWithGroupUsingTheSharingApi(
$user, $filepath, $group, $permissions = null
public function shareFileWithGroupUsingTheSharingApi(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The refactoring here makes the "share with group" scenarios in createShare.feature work properly.
Previously the proper OCS and HTTP statuses were getting "lost". So issue #33733 was a test bug.

@phil-davis
phil-davis force-pushed the refactor-reShare-feature branch from 74e8b87 to d0416f0 Compare June 17, 2019 11:07
@phil-davis
phil-davis marked this pull request as ready for review June 17, 2019 11:08
@phil-davis
phil-davis requested a review from individual-it June 17, 2019 11:08
@phil-davis

Copy link
Copy Markdown
Contributor Author

Backport stable10 #35559

@phil-davis
phil-davis merged commit 109928b into master Jun 17, 2019
@delete-merged-branch
delete-merged-branch Bot deleted the refactor-reShare-feature branch June 17, 2019 12:12
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.

4 participants