From 82b2a2ff944a230069cf6c9b4e70cdb057c1c71b Mon Sep 17 00:00:00 2001 From: paurakhsharma Date: Tue, 2 Jul 2019 15:14:53 +0545 Subject: [PATCH] Add webUI tests for share only with membership groups --- .../WebUIAdminSharingSettingsContext.php | 11 ++++++ .../features/lib/AdminSharingSettingsPage.php | 24 ++++++++++-- .../shareWithGroups.feature | 38 ++++++++++++++++++- .../shareWithUsers.feature | 30 ++++++++++++++- 4 files changed, 98 insertions(+), 5 deletions(-) diff --git a/tests/acceptance/features/bootstrap/WebUIAdminSharingSettingsContext.php b/tests/acceptance/features/bootstrap/WebUIAdminSharingSettingsContext.php index 96a76e436d4e..070cda19f865 100644 --- a/tests/acceptance/features/bootstrap/WebUIAdminSharingSettingsContext.php +++ b/tests/acceptance/features/bootstrap/WebUIAdminSharingSettingsContext.php @@ -219,6 +219,17 @@ public function theAdministratorEnablesExcludeGroupsFromSharingUsingTheWebui() { ); } + /** + * @When the administrator enables restrict users to only share with groups they are member of using the webUI + * + * @return void + */ + public function theAdministratorEnablesRestrictUsersToOnlyShareWithGroupsTheyAreMemberOfUsingTheWebui() { + $this->adminSharingSettingsPage->restrictUserToOnlyShareWithMembershipGroup( + $this->getSession() + ); + } + /** * @When the administrator adds group :group to the exclude group from sharing list using the webUI * @Given the administrator has added group :group to the exclude group from sharing list from the admin sharing settings page diff --git a/tests/acceptance/features/lib/AdminSharingSettingsPage.php b/tests/acceptance/features/lib/AdminSharingSettingsPage.php index 9401e0f02965..4d8a9dffd45f 100644 --- a/tests/acceptance/features/lib/AdminSharingSettingsPage.php +++ b/tests/acceptance/features/lib/AdminSharingSettingsPage.php @@ -28,13 +28,13 @@ * Admin Sharing Settings page. */ class AdminSharingSettingsPage extends SharingSettingsPage { - + /** * * @var string $path */ protected $path = '/index.php/settings/admin?sectionid=sharing'; - + protected $shareApiCheckboxXpath = '//label[@for="shareAPIEnabled"]'; protected $shareApiCheckboxId = 'shareAPIEnabled'; protected $publicShareCheckboxXpath = '//label[@for="allowLinks"]'; @@ -59,8 +59,10 @@ class AdminSharingSettingsPage extends SharingSettingsPage { protected $onlyShareWithGroupMembersCheckboxId = 'onlyShareWithGroupMembers'; protected $excludeGroupFromSharingCheckboxXpath = '//label[@for="shareapiExcludeGroups"]'; protected $excludeGroupFromSharingCheckboxId = 'shareapiExcludeGroups'; - protected $excludeGroupsFromSharingListFieldXpath = '//p[@id="selectExcludedGroups"]//input[contains(@class,"select2-input")]'; + + protected $onlyShareWithMembershipGroupsCheckboxXpath = '//label[@for="onlyShareWithMembershipGroups"]'; + protected $onlyShareWithMembershipGroupsCheckboxId = 'onlyShareWithMembershipGroups'; protected $excludeGroupFromSharesFieldXpath = '//div[@id="files_sharing"]//input[contains(@class,"select2-input")]'; protected $groupListXpath = '//div[@id="select2-drop"]//li[contains(@class, "select2-result")]'; protected $groupListDropDownXpath = "//div[@id='select2-drop']"; @@ -276,6 +278,22 @@ public function enableExcludeGroupFromSharing(Session $session) { ); } + /** + * enable restrict users to only share with groups they are member of + * + * @param Session $session + * + * @return void + */ + public function restrictUserToOnlyShareWithMembershipGroup(Session $session) { + $this->toggleCheckbox( + $session, + "enables", + $this->onlyShareWithMembershipGroupsCheckboxXpath, + $this->onlyShareWithMembershipGroupsCheckboxId + ); + } + /** * add group to group sharing blacklist * diff --git a/tests/acceptance/features/webUISharingInternalGroups/shareWithGroups.feature b/tests/acceptance/features/webUISharingInternalGroups/shareWithGroups.feature index 1e8edb4fdae4..9ab4a5ae85db 100644 --- a/tests/acceptance/features/webUISharingInternalGroups/shareWithGroups.feature +++ b/tests/acceptance/features/webUISharingInternalGroups/shareWithGroups.feature @@ -254,4 +254,40 @@ Feature: Sharing files and folders with internal groups | group_id1 | group_id2 | group_id3 | | case-sensitive-group | Case-Sensitive-Group | CASE-SENSITIVE-GROUP | | Case-Sensitive-Group | CASE-SENSITIVE-GROUP | case-sensitive-group | - | CASE-SENSITIVE-GROUP | case-sensitive-group | Case-Sensitive-Group | \ No newline at end of file + | CASE-SENSITIVE-GROUP | case-sensitive-group | Case-Sensitive-Group | + + Scenario: sharer should not be able to share a folder to a group which he/she is not member of when share with groups they are member of is enabled + Given group "grp2" has been created + And user "user1" has created folder "/simple-folder" + And the administrator has browsed to the admin sharing settings page + When the administrator enables restrict users to only share with groups they are member of using the webUI + And the user re-logs in as "user1" using the webUI + And the user opens the share dialog for folder "simple-folder" + And the user types "grp2" in the share-with-field + Then a tooltip with the text "No users or groups found for grp2" should be shown near the share-with-field on the webUI + + Scenario: sharer should not be able to share a file to a group which he/she is not member of when share with groups they are member of is enabled + Given group "grp2" has been created + And user "user1" has uploaded file with content "some content" to "lorem.txt" + And the administrator has browsed to the admin sharing settings page + When the administrator enables restrict users to only share with groups they are member of using the webUI + And the user re-logs in as "user1" using the webUI + And the user opens the share dialog for file "lorem.txt" + And the user types "grp2" in the share-with-field + Then a tooltip with the text "No users or groups found for grp2" should be shown near the share-with-field on the webUI + + Scenario: sharer should be able to share a folder to his/her own group when only share with groups they are member of is enabled + Given user "user1" has created folder "/simple-folder" + And the administrator has browsed to the admin sharing settings page + When the administrator enables restrict users to only share with groups they are member of using the webUI + And the user re-logs in as "user1" using the webUI + And the user shares folder "simple-folder" with group "grp1" using the webUI + Then as "user2" folder "/simple-folder" should exist + + Scenario: sharer should be able to share a file to his/her own group when only share with groups they are member of is enabled + Given user "user1" has uploaded file with content "some content" to "lorem.txt" + And the administrator has browsed to the admin sharing settings page + When the administrator enables restrict users to only share with groups they are member of using the webUI + And the user re-logs in as "user1" using the webUI + And the user shares file "lorem.txt" with group "grp1" using the webUI + Then as "user2" file "/lorem.txt" should exist diff --git a/tests/acceptance/features/webUISharingInternalUsers/shareWithUsers.feature b/tests/acceptance/features/webUISharingInternalUsers/shareWithUsers.feature index 0107a7fc6b2a..bd4588c5f745 100644 --- a/tests/acceptance/features/webUISharingInternalUsers/shareWithUsers.feature +++ b/tests/acceptance/features/webUISharingInternalUsers/shareWithUsers.feature @@ -391,4 +391,32 @@ Feature: Sharing files and folders with internal users | user_id1 | user_id2 | user_id3 | | Brand-New-User | brand-new-user | BRAND-NEW-USER | | brand-new-user | BRAND-NEW-USER | Brand-New-User | - | BRAND-NEW-USER | Brand-New-User | brand-new-user | \ No newline at end of file + | BRAND-NEW-USER | Brand-New-User | brand-new-user | + + Scenario: sharer should be able to share a folder to a user when only share with groups they are member of is enabled + Given these users have been created with default attributes and without skeleton files: + | username | + | user1 | + | user2 | + And group "grp1" has been created + And user "user1" has been added to group "grp1" + And user "user1" has created folder "/simple-folder" + And the administrator has browsed to the admin sharing settings page + When the administrator enables restrict users to only share with groups they are member of using the webUI + And the user re-logs in as "user1" using the webUI + And the user shares folder "simple-folder" with user "User Two" using the webUI + Then as "user2" folder "/simple-folder" should exist + + Scenario: sharer should be able to share a file to a user when only share with groups they are member of is enabled + Given these users have been created with default attributes and without skeleton files: + | username | + | user1 | + | user2 | + And group "grp1" has been created + And user "user1" has been added to group "grp1" + And user "user1" has uploaded file with content "some content" to "lorem.txt" + And the administrator has browsed to the admin sharing settings page + When the administrator enables restrict users to only share with groups they are member of using the webUI + And the user re-logs in as "user1" using the webUI + And the user shares file "lorem.txt" with user "User Two" using the webUI + Then as "user2" file "/lorem.txt" should exist