Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding test cases for AclShell

  • Loading branch information...
commit cd9dd97eff90e6abe862c729d9ea2d642e46c3d6 1 parent 9e36d1b
@markstory markstory authored
Showing with 38 additions and 0 deletions.
  1. +38 −0 cake/tests/cases/console/libs/acl.test.php
View
38 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();
+ }
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.