mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
b261d3cadc
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@92879 467b73ca-7a2a-4603-9d3b-597d59a354a9
86 lines
3.1 KiB
PHP
86 lines
3.1 KiB
PHP
<?php
|
|
/**
|
|
* @package cms
|
|
* @subpackage tests
|
|
*/
|
|
class SecurityAdminTest extends FunctionalTest {
|
|
static $fixture_file = 'cms/tests/CMSMainTest.yml';
|
|
|
|
function testGroupExport() {
|
|
$this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
|
|
|
|
/* First, open the applicable group */
|
|
$this->get('admin/security/getitem?ID=' . $this->idFromFixture('Group','admin'));
|
|
$this->assertRegExp('/<input[^>]+id="Form_EditForm_Title"[^>]+value="Administrators"[^>]*>/',$this->content());
|
|
|
|
/* Then load the export page */
|
|
$this->get('admin/security//EditForm/field/Members/export');
|
|
$lines = preg_split('/\n/', $this->content());
|
|
|
|
$this->assertEquals(count($lines), 3, "Export with members has one content row");
|
|
$this->assertRegExp('/"","","admin@example.com"/', $lines[1], "Member values are correctly exported");
|
|
}
|
|
|
|
function testEmptyGroupExport() {
|
|
$this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
|
|
|
|
/* First, open the applicable group */
|
|
$this->get('admin/security/getitem?ID=' . $this->idFromFixture('Group','empty'));
|
|
$this->assertRegExp('/<input[^>]+id="Form_EditForm_Title"[^>]+value="Empty Group"[^>]*>/',$this->content());
|
|
|
|
/* Then load the export page */
|
|
$this->get('admin/security//EditForm/field/Members/export');
|
|
$lines = preg_split('/\n/', $this->content());
|
|
|
|
$this->assertEquals(count($lines), 2, "Empty export only has header fields and an empty row");
|
|
$this->assertEquals($lines[1], '', "Empty export only has no content row");
|
|
}
|
|
|
|
function testAddHiddenPermission() {
|
|
SecurityAdmin::add_hidden_permission('CMS_ACCESS_ReportAdmin');
|
|
$this->assertContains('CMS_ACCESS_ReportAdmin', SecurityAdmin::get_hidden_permissions());
|
|
|
|
// reset to defaults
|
|
SecurityAdmin::clear_hidden_permissions();
|
|
}
|
|
|
|
function testRemoveHiddenPermission() {
|
|
SecurityAdmin::add_hidden_permission('CMS_ACCESS_ReportAdmin');
|
|
$this->assertContains('CMS_ACCESS_ReportAdmin', SecurityAdmin::get_hidden_permissions());
|
|
SecurityAdmin::remove_hidden_permission('CMS_ACCESS_ReportAdmin');
|
|
$this->assertNotContains('CMS_ACCESS_ReportAdmin', SecurityAdmin::get_hidden_permissions());
|
|
|
|
// reset to defaults
|
|
SecurityAdmin::clear_hidden_permissions();
|
|
}
|
|
|
|
function testClearHiddenPermission() {
|
|
SecurityAdmin::add_hidden_permission('CMS_ACCESS_ReportAdmin');
|
|
$this->assertContains('CMS_ACCESS_ReportAdmin', SecurityAdmin::get_hidden_permissions());
|
|
SecurityAdmin::clear_hidden_permissions('CMS_ACCESS_ReportAdmin');
|
|
$this->assertNotContains('CMS_ACCESS_ReportAdmin', SecurityAdmin::get_hidden_permissions());
|
|
}
|
|
|
|
function testPermissionFieldRespectsHiddenPermissions() {
|
|
$this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
|
|
|
|
$group = $this->objFromFixture('Group', 'admin');
|
|
|
|
SecurityAdmin::add_hidden_permission('CMS_ACCESS_ReportAdmin');
|
|
$response = $this->get('admin/security/show/' . $group->ID);
|
|
|
|
$this->assertContains(
|
|
'CMS_ACCESS_CMSMain',
|
|
$response->getBody()
|
|
);
|
|
$this->assertNotContains(
|
|
'CMS_ACCESS_ReportAdmin',
|
|
$response->getBody()
|
|
);
|
|
|
|
// reset to defaults
|
|
SecurityAdmin::clear_hidden_permissions();
|
|
}
|
|
}
|
|
|
|
?>
|