Skip to content

Commit

Permalink
WebUI test check blacklisted group sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
paurakhsharma authored and phil-davis committed Oct 6, 2018
1 parent 402637e commit c346db7
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 2 deletions.
1 change: 1 addition & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ default:
- WebUIGeneralContext:
- WebUILoginContext:
- WebUISharingContext:
- WebUIAdminSharingSettingsContext:

webUISharingInternalUsers:
paths:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,21 @@ public function theAdminRestrictsUsersToOnlyShareWithTheirGroupMemberUsingTheWeb
$this->getSession()
);
}


/**
* @When the administrator adds the group :group to the group sharing blacklist using the webUI
*
* @param string $group
*
* @return void
*/
public function theAdministratorAddsTheGroupToTheGroupSharingBlacklistUsingTheWebui($group) {
$this->adminSharingSettingsPage->addGroupToGroupSharingBlacklist($group);
$this->adminSharingSettingsPage->waitForAjaxCallsToStartAndFinish(
$this->getSession()
);
}

/**
* This will run before EVERY scenario.
* It will set the properties for this object.
Expand Down
6 changes: 6 additions & 0 deletions tests/acceptance/features/bootstrap/WebUIGeneralContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,9 @@ public function setUpScenario(BeforeScenarioScope $scope) {
);
}
}
SetupHelper::runOcc(
['config:app:set files_sharing blacklisted_receiver_groups --value=']
);
}

/**
Expand Down Expand Up @@ -808,5 +811,8 @@ public function reportResult(AfterScenarioScope $afterScenarioScope) {
} else {
\error_log("SCENARIO RESULT: ($passOrFail)");
}
SetupHelper::runOcc(
["config:app:set files_sharing blacklisted_receiver_groups --value"]
);
}
}
38 changes: 38 additions & 0 deletions tests/acceptance/features/lib/AdminSharingSettingsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class AdminSharingSettingsPage extends OwncloudPage {
protected $onlyShareWithGroupMembersCheckboxXpath = '//label[@for="onlyShareWithGroupMembers"]';
protected $onlyShareWithGroupMembersCheckboxId = 'onlyShareWithGroupMembers';

protected $groupSharingBlackListFieldXpath = '//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']";

/**
* toggle checkbox
*
Expand Down Expand Up @@ -265,6 +269,40 @@ public function toggleRestrictUsersToOnlyShareWithTheirGroupMembers($action) {
);
}

/**
* add group to group sharing blacklist
*
* @param string $groupName
*
* @return void
*/
public function addGroupToGroupSharingBlacklist($groupName) {
$groupSharingBlackListField = $this->find("xpath", $this->groupSharingBlackListFieldXpath);
if ($groupSharingBlackListField === null) {
throw new ElementNotFoundException(
__METHOD__ .
" xpath $this->groupSharingBlackListFieldXpath " .
"could not input field"
);
}
$groupSharingBlackListField->click();
$this->waitTillElementIsNotNull($this->groupListDropDownXpath);
$this->waitTillElementIsNotNull($this->groupListXpath);
$groupList = $this->findAll("xpath", $this->groupListXpath);
if ($groupSharingBlackListField === null) {
throw new ElementNotFoundException(
__METHOD__ .
" xpath $this->groupListXpath " .
"could not find group list"
);
}
foreach ($groupList as $group) {
if ($this->getTrimmedText($group) === $groupName) {
$group->click();
}
}
}

/**
* waits till at least one Ajax call is active and
* then waits till all outstanding ajax calls finish
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ Feature: Sharing files and folders with internal groups
| grp1 |
And user "user1" has been added to group "grp1"
And user "user2" has been added to group "grp1"
And user "user3" has logged in using the webUI

@TestAlsoOnExternalUserBackend
@smokeTest
Scenario: share a folder with an internal group
Given user "user3" has logged in using the webUI
When the user shares the folder "simple-folder" with the group "grp1" using the webUI
And the user shares the file "testimage.jpg" with the group "grp1" using the webUI
And the user re-logs in as "user1" using the webUI
Expand All @@ -35,6 +35,7 @@ Feature: Sharing files and folders with internal groups

@TestAlsoOnExternalUserBackend
Scenario: share a file with an internal group a member overwrites and unshares the file
Given user "user3" has logged in using the webUI
When the user renames the file "lorem.txt" to "new-lorem.txt" using the webUI
And the user shares the file "new-lorem.txt" with the group "grp1" using the webUI
And the user re-logs in as "user1" using the webUI
Expand All @@ -55,6 +56,7 @@ Feature: Sharing files and folders with internal groups

@TestAlsoOnExternalUserBackend
Scenario: share a folder with an internal group and a member uploads, overwrites and deletes files
Given user "user3" has logged in using the webUI
When the user renames the folder "simple-folder" to "new-simple-folder" using the webUI
And the user shares the folder "new-simple-folder" with the group "grp1" using the webUI
And the user re-logs in as "user1" using the webUI
Expand Down Expand Up @@ -86,6 +88,7 @@ Feature: Sharing files and folders with internal groups
@TestAlsoOnExternalUserBackend
@smokeTest
Scenario: share a folder with an internal group and a member unshares the folder
Given user "user3" has logged in using the webUI
When the user renames the folder "simple-folder" to "new-simple-folder" using the webUI
And the user shares the folder "new-simple-folder" with the group "grp1" using the webUI
# unshare the received shared folder and check it is gone
Expand All @@ -104,3 +107,13 @@ Feature: Sharing files and folders with internal groups
When the user opens the folder "new-simple-folder" using the webUI
Then the file "lorem.txt" should be listed on the webUI
And the content of "lorem.txt" should be the same as the original "simple-folder/lorem.txt"

Scenario: user tries to share a file in a group which is blacklisted from sharing
Given the administrator has browsed to the admin sharing settings page
When the administrator adds the group "grp1" to the group sharing blacklist using the webUI
Then user "user3" should not be able to share folder "lorem.txt" with group "grp1" using the sharing API

Scenario: user tries to share a folder in a group which is blacklisted from sharing
Given the administrator has browsed to the admin sharing settings page
When the administrator adds the group "grp1" to the group sharing blacklist using the webUI
Then user "user3" should not be able to share folder "simple-folder" with group "grp1" using the sharing API

0 comments on commit c346db7

Please sign in to comment.