Skip to content

Commit

Permalink
Adding test cases for AclShell
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 5, 2009
1 parent 9e36d1b commit cd9dd97
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions cake/tests/cases/console/libs/acl.test.php
Expand Up @@ -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.