-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add option to disable sharing in user-mounted external storages #28646
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
Conversation
|
|
||
| protected function setUp() { | ||
| $this->config = $this->createMock(IConfig::class); | ||
| // FIXME: cannot mock the interface because the UserTrait functions are not on them |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I'd say it's okay to mock the implementation
| <?php endforeach; ?> | ||
| <br/> | ||
| <input type="checkbox" name="allowUserMountSharing" id="allowUserMountSharing" class="checkbox" | ||
| value="1" <?php if ($_['allowUserMountSharing'] == 'yes') print_unescaped(' checked="checked"'); ?> /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to use '===' unless it's explicitly told otherwise (with the corresponding explanation)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah... this was just copy-pasted from the other block
| * | ||
| * @since 10.0.3 | ||
| */ | ||
| public function wrap(IMountPoint $mountPoint, $storage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this being used? It doesn't appear in the changes of this PR.
Is it the best place for the method? I see 2 different responsabilities for the storage factory: create the objects via getInstance and wrap the storages. From my point of view, the factory should focus on creating objects, if that object is wrapped somehow, that should be an implementation detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it is being used in the StorageFactory implementation, and it seems the calling code is assuming that the method always exists: https://github.com/owncloud/core/blob/master/lib/private/Files/Mount/MountPoint.php#L97
I only added it here to be able to mock it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what to do with this. Bad solutions everywhere. I guess this is the "less bad" option we have.
- Moving the method to the interface -> bad
- Typecasting the interface in the MountPoint class -> bad
- Checking if the implementation has the method -> bad
- Removing the interface and use the class directly -> unexpected consecuences
- Create a new interface and make the implementation implement also the new one -> too much work + adding a non-planned interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only reason I added it is because @DeepDiver1975 said to use this opportunity to add it. I discovered it while testing and do not wish to hold this PR much longer due to this.
My solution would be to resort to mocking StorageFactory instead and raise a tech debt ticket about "review all these weird FS classes where the method wasn't on the interface"
|
I decided to remote IStorageFactory::wrap for now and mocking the StorageFactory class. Please review |
|
Raised StorageFactory tech debt issue here #28656 as it seems to be more complex to fix than just adding the method on the interface |
| } | ||
|
|
||
| public function getAvailability() { | ||
| return ['available' => true]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if the 'last_checked' key is optional. The PHPDoc doesn't say anything, so it should be required.
If it isn't being actively used, we could adjust the PHPDoc to say the 'last_checked' key is optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is supposed to be used only by unit tests. Maybe we should move it to the "tests" folder.
702dd03 to
fc910be
Compare
|
@jvillafanez I've added "last_checked => 0" and squashed. Please rereview. |
|
stable10: #28706 |
|
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. |
Description
Adds a new checkbox to disable sharing in user-mount external storages.
Since ConfigAdapterTest was missing I had to write all of it from scratch.
It turned out that some interfaces had missing methods for mocking (IStorageFactory::wrap), so I added it.
And also added
Temporary::getAvailability()for the temporary test storage to avoid a DB round trip which would fail in this test.Related Issue
Fixes #28636
Motivation and Context
See ticket
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: