Merge pull request #2832 from mateusz/behat-permissions

Behat permissions
This commit is contained in:
Ingo Schommer 2014-02-07 16:16:01 +13:00
commit 0e9868adfe
2 changed files with 115 additions and 0 deletions

View File

@ -124,6 +124,22 @@ class CmsUiContext extends BehatContext {
return $table_element;
}
/**
* Finds the first visible GridField table.
*/
protected function getFirstGridFieldTable() {
$page = $this->getSession()->getPage();
$tableElements = $page->findAll('css', '.ss-gridfield-table');
assertNotNull($tableElements, 'Table elements not found');
// Return first found table.
foreach($tableElements as $table) {
if($table->isVisible()) return $table;
}
assertNotNull(null, 'First visible table element not found');
}
/**
* @Given /^I should see a "([^"]*)" button in CMS Content Toolbar$/
*/
@ -233,6 +249,20 @@ class CmsUiContext extends BehatContext {
$element->click();
}
/**
* Clicks on a row in the first found visible GridField table.
* Example: I click on "New Zealand" in the table
*
* @Given /^I click on "([^"]*)" in the table$/
*/
public function iClickOnInTheFirstTable($text) {
$table_element = $this->getFirstGridFieldTable();
$element = $table_element->find('xpath', sprintf('//*[count(*)=0 and contains(.,"%s")]', $text));
assertNotNull($element, sprintf('Element containing `%s` not found', $text));
$element->click();
}
/**
* @Then /^I can see the preview panel$/
*/

View File

@ -0,0 +1,85 @@
@javascript
Feature: Manage Security Permissions for Groups
As a site administrator
I want to control my user's security permissions in an intuitive way
So that I can easily control access to the CMS
Background:
Given a "group" "test group"
And a "member" "ADMIN" belonging to "ADMIN Group" with "Email"="admin@test.com"
And the "group" "ADMIN group" has permissions "Full administrative rights"
And I am logged in with "ADMIN" permissions
And I go to "/admin/security"
And I click the "Groups" CMS tab
And I click on "test group" in the table
And I click the "Permissions" CMS tab
Scenario: I can see sub-permissions being properly set and restored when using "Access to all CMS sections"
When I check "Access to all CMS sections"
Then the "Access to 'Security' section" checkbox should be checked
And the "Access to 'Security' section" field should be disabled
When I uncheck "Access to all CMS sections"
Then the "Access to 'Security' section" checkbox should not be checked
And the "Access to 'Security' section" field should be enabled
When I check "Access to 'Security' section"
And I check "Access to all CMS sections"
When I uncheck "Access to all CMS sections"
Then the "Access to 'Security' section" checkbox should be checked
# Save so the driver can reset without having to deal with the popup alert.
Then I press the "Save" button
Scenario: I can see sub-permissions being properly set and restored when using "Full administrative rights"
When I check "Access to 'Security' section"
And I check "Full administrative rights"
Then the "Access to all CMS sections" checkbox should be checked
And the "Access to all CMS sections" field should be disabled
And the "Access to 'Security' section" checkbox should be checked
And the "Access to 'Security' section" field should be disabled
And I uncheck "Full administrative rights"
Then the "Access to all CMS sections" checkbox should not be checked
And the "Access to all CMS sections" field should be enabled
And the "Access to 'Security' section" checkbox should be checked
And the "Access to 'Security' section" field should be enabled
# Save so the driver can reset without having to deal with the popup alert.
Then I press the "Save" button
Scenario: I can see sub-permissions being handled properly between reloads when using "Full administrative rights"
When I check "Full administrative rights"
And I press the "Save" button
And I click the "Permissions" CMS tab
Then the "Full administrative rights" checkbox should be checked
And the "Access to 'Security' section" checkbox should be checked
And the "Access to 'Security' section" field should be disabled
When I uncheck "Full administrative rights"
Then the "Access to 'Security' section" checkbox should not be checked
And the "Access to 'Security' section" field should be enabled
When I press the "Save" button
And I click the "Permissions" CMS tab
Then the "Full administrative rights" checkbox should not be checked
And the "Access to 'Security' section" checkbox should not be checked
And the "Access to 'Security' section" field should be enabled
Scenario: I can see sub-permissions being handled properly between reloads when using "Access to all CMS sections"
When I check "Access to all CMS sections"
And I press the "Save" button
And I click the "Permissions" CMS tab
Then the "Access to all CMS sections" checkbox should be checked
And the "Access to 'Security' section" checkbox should be checked
And the "Access to 'Security' section" field should be disabled
When I uncheck "Access to all CMS sections"
Then the "Access to 'Security' section" checkbox should not be checked
And the "Access to 'Security' section" field should be enabled
When I press the "Save" button
And I click the "Permissions" CMS tab
Then the "Access to all CMS sections" checkbox should not be checked
And the "Access to 'Security' section" checkbox should not be checked
And the "Access to 'Security' section" field should be enabled