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

Share with group membership only #29241

Merged
merged 6 commits into from
Oct 30, 2017
Merged

Conversation

jvillafanez
Copy link
Member

Description

Add an option to allow user to share only with the groups they belong to. If a user isn't a member of a group, that group won't appear as an option to share with it

Related Issue

#29075

Motivation and Context

Users can share with any group. This option restricts that behaviour in a similar way the "share with users in their groups" option does.

How Has This Been Tested?

Tested quickly with the sharing dialog. Other than that, consider this PR as untested for now. New unittests will be added soon.

Screenshots (if appropriate):

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)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov
Copy link

codecov bot commented Oct 16, 2017

Codecov Report

Merging #29241 into master will increase coverage by <.01%.
The diff coverage is 76.92%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #29241      +/-   ##
============================================
+ Coverage     59.39%    59.4%   +<.01%     
- Complexity    17165    17168       +3     
============================================
  Files          1027     1027              
  Lines         57223    57232       +9     
============================================
+ Hits          33990    33998       +8     
- Misses        23233    23234       +1
Impacted Files Coverage Δ Complexity Δ
settings/templates/panels/admin/filesharing.php 100% <ø> (ø) 0 <0> (ø) ⬇️
...files_sharing/lib/Controller/ShareesController.php 16.22% <0%> (-0.08%) 93 <0> (ø)
lib/private/Share/Share.php 66.87% <100%> (+0.09%) 502 <2> (+2) ⬆️
apps/files_sharing/lib/Capabilities.php 100% <100%> (ø) 6 <0> (ø) ⬇️
settings/Panels/Admin/FileSharing.php 100% <100%> (ø) 6 <0> (ø) ⬇️
lib/private/Share20/Manager.php 97.25% <100%> (+0.01%) 198 <1> (+1) ⬆️

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 67c8e05...b48e96e. Read the comment docs.

@codecov
Copy link

codecov bot commented Oct 16, 2017

Codecov Report

Merging #29241 into master will increase coverage by 1.13%.
The diff coverage is 66.66%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #29241      +/-   ##
============================================
+ Coverage     59.39%   60.53%   +1.13%     
- Complexity    17165    17191      +26     
============================================
  Files          1027     1031       +4     
  Lines         57223    57284      +61     
============================================
+ Hits          33990    34677     +687     
+ Misses        23233    22607     -626
Impacted Files Coverage Δ Complexity Δ
settings/templates/panels/admin/filesharing.php 100% <ø> (ø) 0 <0> (ø) ⬇️
core/Migrations/Version20171026130750.php 0% <0%> (ø) 2 <2> (?)
lib/private/Share20/Manager.php 97.25% <100%> (+0.01%) 198 <1> (+1) ⬆️
apps/files_sharing/lib/Capabilities.php 100% <100%> (ø) 6 <0> (ø) ⬇️
settings/Panels/Admin/FileSharing.php 100% <100%> (ø) 6 <0> (ø) ⬇️
lib/private/Share/Share.php 66.87% <100%> (+0.09%) 502 <2> (+2) ⬆️
...files_sharing/lib/Controller/ShareesController.php 89.03% <66.66%> (+72.73%) 93 <0> (ø) ⬇️
apps/dav/lib/Server.php 48.33% <0%> (-4.35%) 11% <0%> (-5%)
lib/private/Installer.php 46.92% <0%> (-3.79%) 89% <0%> (+3%)
lib/private/legacy/api.php 41.88% <0%> (-0.55%) 80% <0%> (+2%)
... and 40 more

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 67c8e05...ad3f111. Read the comment docs.

@jvillafanez
Copy link
Member Author

@phil-davis @individual-it could you check if the failing test is related with this PR's changes? I'm not sure if it's "just" a random failure or if it's something that needs to be fixed.

@phil-davis
Copy link
Contributor

@jvillafanez I scanned through your code diffs and there is nothing touching the front-end that should make the test fail like it did (cannot even find the "share with" element on the page). So I restarted the job and we will see.

@PVince81
Copy link
Contributor

@jvillafanez can you also add integration tests ? Feel free to ask @SergioBertolinSG for some assistance.

@jvillafanez
Copy link
Member Author

I'll check what we can add easily during today and tomorrow.

@felixboehm felixboehm added the p2-high Escalation, on top of current planning, release blocker label Oct 17, 2017
@felixboehm
Copy link
Contributor

Need an assignment here, who continues work on this?

@PVince81
Copy link
Contributor

Assigned to @jvillafanez

@jvillafanez
Copy link
Member Author

I've found a problem with the share API (probably known) that affects to all the sharing tests. The problem is that the response of the sharing API is different depending on the number of results it needs to return.

For only one group available in the results:

Array
(
    [exact] => Array
        (
            [users] => Array
                (
                )

            [groups] => Array
                (
                )

            [remotes] => Array
                (
                )

        )

    [users] => Array
        (
            [element] => Array
                (
                    [label] => Sharee1
                    [value] => Array
                        (
                            [shareType] => 0
                            [shareWith] => Sharee1
                        )

                )

        )

    [groups] => Array
        (
            [element] => Array
                (
                    [label] => ShareeGroup
                    [value] => Array
                        (
                            [shareType] => 1
                            [shareWith] => ShareeGroup
                        )

                )

        )

    [remotes] => Array
        (
        )

)

If there are several results:

Array
(
    [exact] => Array
        (
            [users] => Array
                (
                )

            [groups] => Array
                (
                )

            [remotes] => Array
                (
                )

        )

    [users] => Array
        (
            [element] => Array
                (
                    [label] => Sharee1
                    [value] => Array
                        (
                            [shareType] => 0
                            [shareWith] => Sharee1
                        )

                )

        )

    [groups] => Array
        (
            [element] => Array
                (
                    [0] => Array
                        (
                            [label] => ShareeGroup
                            [value] => Array
                                (
                                    [shareType] => 1
                                    [shareWith] => ShareeGroup
                                )

                        )

                    [1] => Array
                        (
                            [label] => ShareeGroup2
                            [value] => Array
                                (
                                    [shareType] => 1
                                    [shareWith] => ShareeGroup2
                                )

                        )

                )

        )

    [remotes] => Array
        (
        )

)

Note that if there is only one element available, that element is returned under the "element" key, but if there are several elements, the "element" key returns an array of elements. This will likely happen with the users, although I haven't checked.

This problem affects the new tests because we need at least 2 groups. In order to do so, we'll need to patch the underlying test code to accept both possibilities so the parsing is properly done (this will error prone since we can't distinguish both options in a clear way, checking if the key is an integer is ugly but there isn't any other easy way).

The best option would be to fix the problem in the sharing API, but that's out of the scope of this PR (it will also need to fix the tests).

@jvillafanez
Copy link
Member Author

@SergioBertolinSG could you take over for the integration tests? Note my last comment.

@phil-davis
Copy link
Contributor

And (I think) @individual-it put his hand up to add some UI tests for this. There are already UI tests of this sharing area, so it should be just a matter of setting the new system option and then testing that the sharing dropdown now contains just the expected items.

@SergioBertolinSG
Copy link
Contributor

@jvillafanez I can take care after finishing the pending tasks I have (which are several). Is that ok? Otherwise you should continue.

@jvillafanez
Copy link
Member Author

Waiting for automatic testing.... other than that, this should be ready

Copy link
Contributor

@SergioBertolinSG SergioBertolinSG left a comment

Choose a reason for hiding this comment

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

👍 for the behat tests

@PVince81
Copy link
Contributor

@jvillafanez seems to work fine.

One thing that bothers me is that the behavior will change on update.

To recreate the old behavior, one needs to check both checkboxes.

We should write a migration to automatically tick the second checkbox if the first one was checked on update to avoid surprising admins with a sudden change of behavior. Then the admin can decide to tweak if needed.

@jvillafanez does that make sense ?

@jvillafanez
Copy link
Member Author

Migration incomming!

@jvillafanez
Copy link
Member Author

Migration added (not tested yet)

I don't think we need to check the OC version as long as the migrations are run only once (which is what I expect). Under these circumstances, copy the value from one key to another should do the trick.

@PVince81
Copy link
Contributor

@jvillafanez migrations are run only once, yes. Keep in mind that migrations also run at install time so make sure it also works in that situation.

@jvillafanez
Copy link
Member Author

  • Fresh install -> migration runs without doing anything (key is missing so nothing to do)
  • Update from 10.0.3 with checkbox active -> key is duplicated
  • Update from 9.1.6 with checkbox active -> key is duplicated

LGTM

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

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

👍

@PVince81
Copy link
Contributor

@jvillafanez seems codecov is not happy, might be missing some test coverage ?

@PVince81
Copy link
Contributor

@jvillafanez I checked the report. Not all is coverable (ignore the migration), please write tests for the changes in ShareesController.

@PVince81 PVince81 merged commit e320296 into master Oct 30, 2017
@PVince81 PVince81 deleted the share_with_group_membership_only branch October 30, 2017 10:51
@PVince81
Copy link
Contributor

@jvillafanez please backport to stable10

@jvillafanez
Copy link
Member Author

stable10 backport in #29391

@individual-it
Copy link
Member

UI tests in #29406

@lock
Copy link

lock bot commented Aug 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3 - To Review feature:sharing p2-high Escalation, on top of current planning, release blocker settings:admin status/STALE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants