Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/files_sharing/js/dist/files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/files_sharing/js/dist/files_sharing_tab.js.map

Large diffs are not rendered by default.

56 changes: 52 additions & 4 deletions apps/files_sharing/src/components/SharingEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
ref="canEdit"
:checked.sync="canEdit"
:value="permissionsEdit"
:disabled="saving">
:disabled="saving || !canSetEdit">
{{ t('files_sharing', 'Allow editing') }}
</ActionCheckbox>

Expand All @@ -49,7 +49,7 @@
ref="canCreate"
:checked.sync="canCreate"
:value="permissionsCreate"
:disabled="saving">
:disabled="saving || !canSetCreate">
{{ t('files_sharing', 'Allow creating') }}
</ActionCheckbox>

Expand All @@ -59,7 +59,7 @@
ref="canDelete"
:checked.sync="canDelete"
:value="permissionsDelete"
:disabled="saving">
:disabled="saving || !canSetDelete">
{{ t('files_sharing', 'Allow deleting') }}
</ActionCheckbox>

Expand All @@ -68,7 +68,7 @@
ref="canReshare"
:checked.sync="canReshare"
:value="permissionsShare"
:disabled="saving">
:disabled="saving || !canSetReshare">
{{ t('files_sharing', 'Allow resharing') }}
</ActionCheckbox>

Expand Down Expand Up @@ -215,6 +215,54 @@ export default {
&& this.share.type !== this.SHARE_TYPES.SHARE_TYPE_REMOTE_GROUP
},

/**
* Can the sharer set whether the sharee can edit the file ?
*
* @returns {boolean}
*/
canSetEdit() {
// If the owner revoked the permission after the resharer granted it
// the share still has the permission, and the resharer is still
// allowed to revoke it too (but not to grant it again).
return (this.fileInfo.sharePermissions & OC.PERMISSION_UPDATE) || this.canEdit
},

/**
* Can the sharer set whether the sharee can create the file ?
*
* @returns {boolean}
*/
canSetCreate() {
// If the owner revoked the permission after the resharer granted it
// the share still has the permission, and the resharer is still
// allowed to revoke it too (but not to grant it again).
return (this.fileInfo.sharePermissions & OC.PERMISSION_CREATE) || this.canCreate
},

/**
* Can the sharer set whether the sharee can delete the file ?
*
* @returns {boolean}
*/
canSetDelete() {
// If the owner revoked the permission after the resharer granted it
// the share still has the permission, and the resharer is still
// allowed to revoke it too (but not to grant it again).
return (this.fileInfo.sharePermissions & OC.PERMISSION_DELETE) || this.canDelete
},

/**
* Can the sharer set whether the sharee can reshare the file ?
*
* @returns {boolean}
*/
canSetReshare() {
// If the owner revoked the permission after the resharer granted it
// the share still has the permission, and the resharer is still
// allowed to revoke it too (but not to grant it again).
return (this.fileInfo.sharePermissions & OC.PERMISSION_SHARE) || this.canReshare
},

/**
* Can the sharee edit the shared file ?
*/
Expand Down
83 changes: 83 additions & 0 deletions tests/acceptance/features/app-files-sharing.feature
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,86 @@ Feature: app-files-sharing
And I open the "Sharing" tab in the details view
And I see that the "Sharing" tab in the details view is eventually loaded
And I see that resharing the file is not allowed

Scenario: sharee can not reshare a file with edit permission if the sharer disables it
Given I act as John
And I am logged in as the admin
And I act as Jane
And I am logged in
And I act as John
And I rename "welcome.txt" to "farewell.txt"
And I see that the file list contains a file named "farewell.txt"
And I share "farewell.txt" with "user0"
And I see that the file is shared with "user0"
And I set the share with "user0" as not editable
And I see that "user0" can not edit the share
When I act as Jane
# The Files app is open again to reload the file list
And I open the Files app
And I share "farewell.txt" with "user1"
Then I see that the file is shared with "user1"
And I see that "user1" can not edit the share
And I see that "user1" can not be allowed to edit the share

Scenario: sharee can not reshare a folder with create permission if the sharer disables it
Given I act as John
And I am logged in as the admin
And I act as Jane
And I am logged in
And I act as John
And I create a new folder named "Shared folder"
And I see that the file list contains a file named "Shared folder"
And I share "Shared folder" with "user0"
And I see that the file is shared with "user0"
And I set the share with "user0" as not creatable
And I see that "user0" can not create in the share
When I act as Jane
# The Files app is open again to reload the file list
And I open the Files app
And I share "Shared folder" with "user1"
Then I see that the file is shared with "user1"
And I see that "user1" can not create in the share
And I see that "user1" can not be allowed to create in the share

Scenario: sharee can revoke create permission from reshare after the sharer disabled it
Given I act as John
And I am logged in as the admin
And I act as Jane
And I am logged in
And I act as Jim
And I am logged in as "user1"
And I act as John
And I create a new folder named "Shared folder"
And I see that the file list contains a file named "Shared folder"
And I share "Shared folder" with "user0"
And I see that the file is shared with "user0"
And I act as Jane
# The Files app is open again to reload the file list
And I open the Files app
And I share "Shared folder" with "user1"
And I see that the file is shared with "user1"
And I act as John
And I set the share with "user0" as not creatable
And I see that "user0" can not create in the share
And I act as Jim
# The Files app is open again to reload the file list
And I open the Files app
And I enter in the folder named "Shared folder"
# Creation is still allowed in already created reshares
And I create a new folder named "Subfolder"
And I see that the file list contains a file named "Subfolder"
When I act as Jane
# The Files app is open again to reload the file list
And I open the Files app
And I open the details view for "Shared folder"
And I see that the details view is open
And I open the "Sharing" tab in the details view
And I see that the "Sharing" tab in the details view is eventually loaded
And I set the share with "user1" as not creatable
Then I see that "user1" can not create in the share
And I see that "user1" can not be allowed to create in the share
And I act as Jim
# The Files app is open again to reload the file list
And I open the Files app
And I enter in the folder named "Shared folder"
And I see that it is not possible to create new files
142 changes: 133 additions & 9 deletions tests/acceptance/features/bootstrap/FilesAppSharingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,64 @@ public static function shareWithMenu($sharedWithName) {
/**
* @return Locator
*/
public static function canReshareCheckbox($sharedWithName) {
// forThe()->checkbox("Can reshare") can not be used here; that would
// return the checkbox itself, but the element that the user interacts
// with is the label.
return Locator::forThe()->xpath("//label[normalize-space() = 'Allow resharing']")->
public static function permissionCheckboxFor($sharedWithName, $itemText) {
// forThe()->checkbox($itemText) can not be used here; that would return
// the checkbox itself, but the element that the user interacts with is
// the label.
return Locator::forThe()->xpath("//label[normalize-space() = '$itemText']")->
descendantOf(self::shareWithMenu($sharedWithName))->
describedAs("Allow resharing checkbox in the share with $sharedWithName menu in the details view in Files app");
describedAs("$itemText checkbox in the share with $sharedWithName menu in the details view in Files app");
}

/**
* @return Locator
*/
public static function canReshareCheckboxInput($sharedWithName) {
return Locator::forThe()->checkbox("Allow resharing")->
public static function permissionCheckboxInputFor($sharedWithName, $itemText) {
return Locator::forThe()->checkbox($itemText)->
descendantOf(self::shareWithMenu($sharedWithName))->
describedAs("Allow resharing checkbox input in the share with $sharedWithName menu in the details view in Files app");
describedAs("$itemText checkbox input in the share with $sharedWithName menu in the details view in Files app");
}

/**
* @return Locator
*/
public static function canEditCheckbox($sharedWithName) {
return self::permissionCheckboxFor($sharedWithName, 'Allow editing');
}

/**
* @return Locator
*/
public static function canEditCheckboxInput($sharedWithName) {
return self::permissionCheckboxInputFor($sharedWithName, 'Allow editing');
}

/**
* @return Locator
*/
public static function canCreateCheckbox($sharedWithName) {
return self::permissionCheckboxFor($sharedWithName, 'Allow creating');
}

/**
* @return Locator
*/
public static function canCreateCheckboxInput($sharedWithName) {
return self::permissionCheckboxInputFor($sharedWithName, 'Allow creating');
}

/**
* @return Locator
*/
public static function canReshareCheckbox($sharedWithName) {
return self::permissionCheckboxFor($sharedWithName, 'Allow resharing');
}

/**
* @return Locator
*/
public static function canReshareCheckboxInput($sharedWithName) {
return self::permissionCheckboxInputFor($sharedWithName, 'Allow resharing');
}

/**
Expand Down Expand Up @@ -359,6 +401,28 @@ public function iSetThePasswordOfTheSharedLinkAsNotProtectedByTalk() {
$this->actor->find(self::passwordProtectByTalkCheckbox(), 2)->click();
}

/**
* @When I set the share with :shareWithName as not editable
*/
public function iSetTheShareWithAsNotEditable($shareWithName) {
$this->showShareWithMenuIfNeeded($shareWithName);

$this->iSeeThatCanEditTheShare($shareWithName);

$this->actor->find(self::canEditCheckbox($shareWithName), 2)->click();
}

/**
* @When I set the share with :shareWithName as not creatable
*/
public function iSetTheShareWithAsNotCreatable($shareWithName) {
$this->showShareWithMenuIfNeeded($shareWithName);

$this->iSeeThatCanCreateInTheShare($shareWithName);

$this->actor->find(self::canCreateCheckbox($shareWithName), 2)->click();
}

/**
* @When I set the share with :shareWithName as not reshareable
*/
Expand Down Expand Up @@ -396,6 +460,66 @@ public function iSeeThatResharingTheFileIsNotAllowed() {
$this->actor->find(self::shareWithInput(), 10)->getWrappedElement()->getAttribute("placeholder"), "Resharing is not allowed");
}

/**
* @Then I see that :sharedWithName can not be allowed to edit the share
*/
public function iSeeThatCanNotBeAllowedToEditTheShare($sharedWithName) {
$this->showShareWithMenuIfNeeded($sharedWithName);

PHPUnit_Framework_Assert::assertEquals(
$this->actor->find(self::canEditCheckboxInput($sharedWithName), 10)->getWrappedElement()->getAttribute("disabled"), "disabled");
}

/**
* @Then I see that :sharedWithName can edit the share
*/
public function iSeeThatCanEditTheShare($sharedWithName) {
$this->showShareWithMenuIfNeeded($sharedWithName);

PHPUnit_Framework_Assert::assertTrue(
$this->actor->find(self::canEditCheckboxInput($sharedWithName), 10)->isChecked());
}

/**
* @Then I see that :sharedWithName can not edit the share
*/
public function iSeeThatCanNotEditTheShare($sharedWithName) {
$this->showShareWithMenuIfNeeded($sharedWithName);

PHPUnit_Framework_Assert::assertFalse(
$this->actor->find(self::canEditCheckboxInput($sharedWithName), 10)->isChecked());
}

/**
* @Then I see that :sharedWithName can not be allowed to create in the share
*/
public function iSeeThatCanNotBeAllowedToCreateInTheShare($sharedWithName) {
$this->showShareWithMenuIfNeeded($sharedWithName);

PHPUnit_Framework_Assert::assertEquals(
$this->actor->find(self::canCreateCheckboxInput($sharedWithName), 10)->getWrappedElement()->getAttribute("disabled"), "disabled");
}

/**
* @Then I see that :sharedWithName can create in the share
*/
public function iSeeThatCanCreateInTheShare($sharedWithName) {
$this->showShareWithMenuIfNeeded($sharedWithName);

PHPUnit_Framework_Assert::assertTrue(
$this->actor->find(self::canCreateCheckboxInput($sharedWithName), 10)->isChecked());
}

/**
* @Then I see that :sharedWithName can not create in the share
*/
public function iSeeThatCanNotCreateInTheShare($sharedWithName) {
$this->showShareWithMenuIfNeeded($sharedWithName);

PHPUnit_Framework_Assert::assertFalse(
$this->actor->find(self::canCreateCheckboxInput($sharedWithName), 10)->isChecked());
}

/**
* @Then I see that :sharedWithName can reshare the share
*/
Expand Down