Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add share type to the verifyExpirationDate hook #37135

Merged
merged 2 commits into from
Mar 18, 2020
Merged

Conversation

VicDeo
Copy link
Member

@VicDeo VicDeo commented Mar 17, 2020

Description

add type of the share to the verifyExpirationDate hook

Related Issue

Motivation and Context

it is not possible to distinguish public links from other share types

How Has This Been Tested?

  1. Set public link expiration policies in the password policy app according to Cannot create ordinary share with users when public link expiry is set password_policy#287

  2. Create a user or group share

expected

share is created

actual

share creation is blocked due to public link policies

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
Contributor

phil-davis commented Mar 17, 2020

This looks like "a good thing" (tm). Can a changelog be added? - done.

In the morning I can make some acceptance tests in password_policy that demonstrate the bug and then that the fix works.

@codecov
Copy link

codecov bot commented Mar 17, 2020

Codecov Report

Merging #37135 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #37135      +/-   ##
============================================
+ Coverage     64.78%   64.78%   +<.01%     
  Complexity    19130    19130              
============================================
  Files          1267     1267              
  Lines         74912    74913       +1     
  Branches       1328     1328              
============================================
+ Hits          48533    48534       +1     
  Misses        25989    25989              
  Partials        390      390
Flag Coverage Δ Complexity Δ
#javascript 54.18% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 65.96% <100%> (ø) 19130 <0> (ø) ⬇️
Impacted Files Coverage Δ Complexity Δ
lib/private/Share20/Manager.php 96.31% <100%> (ø) 273 <0> (ø) ⬇️

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 ccfb9e1...bc7aad7. Read the comment docs.

@codecov
Copy link

codecov bot commented Mar 17, 2020

Codecov Report

Merging #37135 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #37135   +/-   ##
=========================================
  Coverage     64.78%   64.78%           
  Complexity    19130    19130           
=========================================
  Files          1267     1267           
  Lines         74912    74913    +1     
  Branches       1328     1328           
=========================================
+ Hits          48533    48534    +1     
  Misses        25989    25989           
  Partials        390      390           
Flag Coverage Δ Complexity Δ
#javascript 54.18% <ø> (ø) 0.00 <ø> (ø)
#phpunit 65.96% <100.00%> (+<0.01%) 19130.00 <0.00> (ø)
Impacted Files Coverage Δ Complexity Δ
lib/private/Share20/Manager.php 96.31% <100.00%> (+<0.01%) 273.00 <0.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 ccfb9e1...e4d16f0. Read the comment docs.

@owncloud owncloud deleted a comment from update-docs bot Mar 18, 2020
@phil-davis
Copy link
Contributor

@VicDeo I added a changelog.

What about unit test changes/additions?

For example, https://github.com/owncloud/core/blob/master/tests/lib/Share20/ManagerTest.php#L1130 could have:

$share->setShareType(\OCP\Share::SHARE_TYPE_LINK);

and the expects for listener can be:

		$hookListner->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) {
			return $data['expirationDate'] == $expected && $data['passwordSet'] === false && $data['shareType'] == \OCP\Share::SHARE_TYPE_LINK;
		}));

The existing tests (which are really for public links) could be adjusted so they explicitly setShareType.

And add some tests to check what happens to the hook when share type is SHARE_TYPE_USER and SHARE_TYPE_GROUP ?

Whatever you think.

For me it would be nice to get this PR merged ASAP. It makes drone CI testing from password_policy app much easier.

@phil-davis
Copy link
Contributor

Tested locally/manually along with owncloud/password_policy#293 and works.

@VicDeo
Copy link
Member Author

VicDeo commented Mar 18, 2020

@phil-davis this oneliner is not worthy an unit test for me.
The coverage is already at 100% and removing this line will break acceptance tests anyway.

Copy link
Contributor

@phil-davis phil-davis left a comment

Choose a reason for hiding this comment

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

This has been discussed and tested - approving.

@phil-davis phil-davis merged commit b7b9d50 into master Mar 18, 2020
@delete-merged-branch delete-merged-branch bot deleted the bugfix/pp287 branch March 18, 2020 09:03
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.

2 participants