Skip to content
Permalink
Browse files

Adding test cases for AclShell

  • Loading branch information...
markstory committed Aug 5, 2009
1 parent 9e36d1b commit cd9dd97eff90e6abe862c729d9ea2d642e46c3d6
Showing with 38 additions and 0 deletions.
  1. +38 −0 cake/tests/cases/console/libs/acl.test.php
@@ -232,5 +232,43 @@ function testGrant() {
$this->assertFalse(empty($node['Aco'][0]));
$this->assertEqual($node['Aco'][0]['Permission']['_create'], 1);
}
/**
* test dent
*
* @return void
**/
function testDeny() {
$this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create');
$this->Task->expectAt(0, 'out', array(new PatternExpectation('/Permission denied/'), true));
$this->Task->deny();
$node = $this->Task->Acl->Aro->read(null, 4);
$this->assertFalse(empty($node['Aco'][0]));
$this->assertEqual($node['Aco'][0]['Permission']['_create'], -1);
}
/**
* test checking allowed and denied perms
*
* @return void
**/
function testCheck() {
$this->Task->args = array('AuthUser.2', 'ROOT/Controller1', '*');
$this->Task->expectAt(0, 'out', array(new PatternExpectation('/not allowed/'), true));
$this->Task->check();
$this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create');
$this->Task->expectAt(1, 'out', array(new PatternExpectation('/Permission granted/'), true));
$this->Task->grant();
$this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create');
$this->Task->expectAt(2, 'out', array(new PatternExpectation('/is allowed/'), true));
$this->Task->check();
$this->Task->args = array('AuthUser.2', 'ROOT/Controller1', '*');
$this->Task->expectAt(3, 'out', array(new PatternExpectation('/not allowed/'), true));
$this->Task->check();
}
}
?>

0 comments on commit cd9dd97

Please sign in to comment.
You can’t perform that action at this time.