Skip to content

Cleanup federation phase 2#32113

Merged
VicDeo merged 5 commits into
masterfrom
cleanup-federation-phase-2
Aug 1, 2018
Merged

Cleanup federation phase 2#32113
VicDeo merged 5 commits into
masterfrom
cleanup-federation-phase-2

Conversation

@VicDeo

@VicDeo VicDeo commented Jul 20, 2018

Copy link
Copy Markdown
Contributor

Description

Follow up on #32086

  • Separates input params validation and handling external shares
  • Increases code coverage
  • Decreases C&P at some degree

Related Issue

https://github.com/owncloud/enterprise/issues/2564

Motivation and Context

Extract business logic from controller, make it reusable.

How Has This Been Tested?

Testing in progress... basic tests are:

Case 1 ✔️

  • [owner] create a federated share with share permision
  • [recipient] accept it

expectations:
[x] owner see that file is shared
[x] recipient see a file and can reshare

  • [owner] change share permissions

expectations:
[x] recipient can NOT reshare any more

  • [recipient] unshare it
    expectations:
    [x] owner see that file is NOT shared

Case 2 ✔️

  • [owner] create a federated share with sharing perms
  • [recipient] accept it
  • [recipient] reshare it with another user

expectations:
[x] another user see a reshare

  • [owner] revokes a share

expectations:
[x] recipient can NOT see the file any more
[x] another user can NOT see a reshare

Case 3 ✔️

  • [owner] create a federated share
  • [recipient] decline it

expectations:
[x] owner see that file is NOT shared

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests

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)

@VicDeo VicDeo self-assigned this Jul 20, 2018
@VicDeo
VicDeo force-pushed the cleanup-federation-phase-2 branch from 3ec3a84 to 4cdc45c Compare July 23, 2018 12:38
@codecov

codecov Bot commented Jul 23, 2018

Copy link
Copy Markdown

Codecov Report

Merging #32113 into master will increase coverage by 0.39%.
The diff coverage is 70.13%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #32113      +/-   ##
============================================
+ Coverage     63.51%   63.91%   +0.39%     
+ Complexity    18543    18536       -7     
============================================
  Files          1169     1169              
  Lines         69722    69808      +86     
  Branches       1267     1267              
============================================
+ Hits          44286    44615     +329     
+ Misses        25067    24824     -243     
  Partials        369      369
Flag Coverage Δ Complexity Δ
#javascript 52.81% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 65.17% <70.13%> (+0.43%) 18536 <30> (-7) ⬇️
Impacted Files Coverage Δ Complexity Δ
...s/federatedfilesharing/lib/AppInfo/Application.php 63.15% <0%> (-1.71%) 9 <0> (ø)
apps/federatedfilesharing/lib/AddressHandler.php 94.82% <100%> (-0.09%) 20 <1> (-1)
...ederatedfilesharing/lib/FederatedShareProvider.php 58.07% <18.36%> (-5.35%) 81 <3> (+3)
...haring/lib/Controller/RequestHandlerController.php 80.23% <82.17%> (+31.62%) 42 <12> (-23) ⬇️
apps/federatedfilesharing/lib/FedShareManager.php 82.11% <83.83%> (+2.87%) 23 <14> (+14) ⬆️
apps/files_external/lib/Lib/Storage/Swift.php 66.16% <0%> (+66.16%) 0% <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 843c405...18b0d02. Read the comment docs.

@VicDeo
VicDeo force-pushed the cleanup-federation-phase-2 branch from 4cdc45c to 979b389 Compare July 23, 2018 13:17
@VicDeo VicDeo added this to the development milestone Jul 23, 2018
@VicDeo
VicDeo force-pushed the cleanup-federation-phase-2 branch 2 times, most recently from ec75c39 to a59c078 Compare July 26, 2018 18:27
@VicDeo
VicDeo force-pushed the cleanup-federation-phase-2 branch 3 times, most recently from dfb1f2b to 440d9c0 Compare July 30, 2018 18:32
@VicDeo
VicDeo force-pushed the cleanup-federation-phase-2 branch 3 times, most recently from 461c774 to e2a8ffc Compare July 31, 2018 15:29
@VicDeo
VicDeo force-pushed the cleanup-federation-phase-2 branch from e2a8ffc to 18b0d02 Compare July 31, 2018 18:20
@VicDeo
VicDeo requested a review from PVince81 July 31, 2018 19:01

@PVince81 PVince81 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.

👍 looks good to me

see comments for optional changes

if ($ownerFederatedId === null) {
$ownerFederatedId = $owner . '@' . $this->cleanupRemote($remote);
$this->assertIncomingSharingEnabled();
$remote = $this->request->getParam('remote', null);

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.

shouldn't we specify those as method params instead?

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.

probably yes, but I did not test it this way

if (!$share->getPermissions() | ~Constants::PERMISSION_SHARE) {
$reSharingAllowed = $share->getPermissions() & Constants::PERMISSION_SHARE;
if (!$reSharingAllowed) {
return new Result(null, Http::STATUS_BAD_REQUEST);

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.

should we add a message here for clarity ?

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.

Validate all error statuses and messages against the spec is another topic that I don't want to start in this PR
It has enough modifications to be barely readable :)

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.

indeed, I remember chatting about this with you. let's do this separately

* @return void
*/
public function createShare($shareWith,
$remote,

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 guess there's no way currently to pack all this into a nice object ? array doesn't sound that attractive and IShare is likely not suitable.

Just thinking out loud... let's leave this for now

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.

yes, it can be the IShare object with some additional params

*
* @return void
*/
public function unshare($id, $token) {

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.

reShare vs unshare, why not unShare then ? I guess you just copied the inconsistent names from the original handler :-D

* @return int
*/
public function addShare($remote, $token, $name, $owner, $shareWith, $remoteId) {
\OC_Util::setupFS($shareWith);

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.

assuming $shareWith was already validated before as being an existing user ?

I checked setupFS and it seems it wouldn't throw an exception.

If this is from the old code as is, feel free to leave it for now

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.

@VicDeo

VicDeo commented Aug 1, 2018

Copy link
Copy Markdown
Contributor Author

@PVince81 let's merge it for now, I'll put a checkbox into the task to address the comments in the next PR.

@VicDeo
VicDeo merged commit 682625b into master Aug 1, 2018
@VicDeo
VicDeo deleted the cleanup-federation-phase-2 branch August 1, 2018 12:46
@VicDeo

VicDeo commented Oct 5, 2018

Copy link
Copy Markdown
Contributor Author

Stable10: #33027

@lock lock Bot locked as resolved and limited conversation to collaborators Oct 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants