mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 10:36:16 +00:00
adding test case to verify permission inheritance functions correctly. Fixes #4464
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6913 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
64e68c9b7c
commit
72e54d4780
1 changed files with 27 additions and 8 deletions
|
@ -152,6 +152,23 @@ class AclComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->assertFalse($this->Acl->check('root/users/Milton', 'smash', 'delete'));
|
$this->assertFalse($this->Acl->check('root/users/Milton', 'smash', 'delete'));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* testDbAclCascadingDeny function
|
||||||
|
*
|
||||||
|
* Setup the acl permissions such that Bobs inherits from admin.
|
||||||
|
* deny Admin delete access to a specific resource, check the permisssions are inherited.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testDbAclCascadingDeny() {
|
||||||
|
$this->Acl->inherit('Bobs', 'ROOT', '*');
|
||||||
|
$this->assertTrue($this->Acl->check('admin', 'tpsReports', 'delete'));
|
||||||
|
$this->assertTrue($this->Acl->check('Bobs', 'tpsReports', 'delete'));
|
||||||
|
$this->Acl->deny('admin', 'tpsReports', 'delete');
|
||||||
|
$this->assertFalse($this->Acl->check('admin', 'tpsReports', 'delete'));
|
||||||
|
$this->assertFalse($this->Acl->check('Bobs', 'tpsReports', 'delete'));
|
||||||
|
}
|
||||||
|
|
||||||
function testDbAclDeny() {
|
function testDbAclDeny() {
|
||||||
$this->assertTrue($this->Acl->check('Micheal', 'smash', 'delete'));
|
$this->assertTrue($this->Acl->check('Micheal', 'smash', 'delete'));
|
||||||
|
@ -343,14 +360,15 @@ class AclComponentTest extends CakeTestCase {
|
||||||
* Generates a list of the current aro and aco structures and a grid dump of the permissions that are defined
|
* Generates a list of the current aro and aco structures and a grid dump of the permissions that are defined
|
||||||
* Only designed to work with the db based ACL
|
* Only designed to work with the db based ACL
|
||||||
*
|
*
|
||||||
|
* @param bool $treesToo
|
||||||
* @access private
|
* @access private
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __debug () {
|
function __debug ($printTreesToo = false) {
|
||||||
$this->Acl->Aro->displayField = 'alias';
|
$this->Acl->Aro->displayField = 'alias';
|
||||||
$this->Acl->Aco->displayField = 'alias';
|
$this->Acl->Aco->displayField = 'alias';
|
||||||
$aros = $this->Acl->Aro->find('list');
|
$aros = $this->Acl->Aro->find('list', array('order' => 'lft'));
|
||||||
$acos = $this->Acl->Aco->find('list');
|
$acos = $this->Acl->Aco->find('list', array('order' => 'lft'));
|
||||||
$rights = array('*', 'create', 'read', 'update', 'delete');
|
$rights = array('*', 'create', 'read', 'update', 'delete');
|
||||||
$permissions['Aros v Acos >'] = $acos;
|
$permissions['Aros v Acos >'] = $acos;
|
||||||
foreach ($aros as $aro) {
|
foreach ($aros as $aro) {
|
||||||
|
@ -379,7 +397,9 @@ class AclComponentTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
$permisssions = array_map(array(&$this, '__pad'), $permissions);
|
$permisssions = array_map(array(&$this, '__pad'), $permissions);
|
||||||
array_unshift($permissions, 'Current Permissions :');
|
array_unshift($permissions, 'Current Permissions :');
|
||||||
|
if ($printTreesToo) {
|
||||||
debug (array('aros' => $this->Acl->Aro->generateTreeList(), 'acos' => $this->Acl->Aco->generateTreeList()));
|
debug (array('aros' => $this->Acl->Aro->generateTreeList(), 'acos' => $this->Acl->Aco->generateTreeList()));
|
||||||
|
}
|
||||||
debug (implode("\r\n", $permissions));
|
debug (implode("\r\n", $permissions));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -395,5 +415,4 @@ class AclComponentTest extends CakeTestCase {
|
||||||
return str_pad($string, $len);
|
return str_pad($string, $len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Reference in a new issue