diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2020-06-24 22:20:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-24 22:20:17 +0300 |
commit | 7d4682da4008300c01f5745b438811032317e4c1 (patch) | |
tree | 85edad6257a8f8627604456f2cdb7ea09500265a /tests/acceptance | |
parent | fab1fdc7fa75011581f7e0f5e9008fa67b6a460a (diff) | |
parent | 3ffb482b4e22aea92ec7fc17557080267bff4770 (diff) |
Merge pull request #21379 from nextcloud/fix-share-permission-checkboxes-enabled-when-permissions-can-not-be-set
Fix share permission checkboxes enabled when permissions can not be set
Diffstat (limited to 'tests/acceptance')
-rw-r--r-- | tests/acceptance/features/app-files-sharing.feature | 83 | ||||
-rw-r--r-- | tests/acceptance/features/bootstrap/FilesAppSharingContext.php | 142 |
2 files changed, 216 insertions, 9 deletions
diff --git a/tests/acceptance/features/app-files-sharing.feature b/tests/acceptance/features/app-files-sharing.feature index e3b0ec30cf8..e0701efd9f2 100644 --- a/tests/acceptance/features/app-files-sharing.feature +++ b/tests/acceptance/features/app-files-sharing.feature @@ -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 diff --git a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php index 6b30d49d71e..80d21a0faf9 100644 --- a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php @@ -103,22 +103,64 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { /** * @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'); } /** @@ -359,6 +401,28 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { } /** + * @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 */ public function iSetTheShareWithAsNotReshareable($shareWithName) { @@ -396,6 +460,66 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { } /** + * @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 */ public function iSeeThatCanReshareTheShare($sharedWithName) { |