Skip to content
Permalink
Browse files

Adding test case for Auth with authorize = actions.

  • Loading branch information...
markstory committed Sep 14, 2009
1 parent 090eb27 commit c94698500b91dfec455c33aa90547db9011740ac
Showing with 32 additions and 1 deletion.
  1. +32 −1 cake/tests/cases/libs/controller/components/auth.test.php
@@ -24,6 +24,8 @@
App::import('Model', 'DbAcl');
App::import('Core', 'Xml');
Mock::generate('AclComponent', 'AuthTestMockAclComponent');
/**
* TestAuthComponent class
*
@@ -735,7 +737,7 @@ function testAuthorizeCrud() {
$result = $this->Controller->Acl->Aro->save();
$this->assertTrue($result);
$this->Controller->Acl->Aco->create(array('alias'=>'Root'));
$this->Controller->Acl->Aco->create(array('alias' => 'Root'));
$result = $this->Controller->Acl->Aco->save();
$this->assertTrue($result);
@@ -762,6 +764,35 @@ function testAuthorizeCrud() {
$this->assertTrue($this->Controller->Session->check('Message.auth'));
}
/**
* test authorize = 'actions' setting.
*
* @return void
**/
function testAuthorizeActions() {
$this->AuthUser =& new AuthUser();
$user = $this->AuthUser->find();
$this->Controller->Session->write('Auth', $user);
$this->Controller->params['controller'] = 'auth_test';
$this->Controller->params['action'] = 'add';
$this->Controller->Acl =& new AuthTestMockAclComponent();
$this->Controller->Acl->setReturnValue('check', true);
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->userModel = 'AuthUser';
$this->Controller->Auth->authorize = 'actions';
$this->Controller->Auth->actionPath = 'Root/';
$this->Controller->Acl->expectAt(0, 'check', array(
$user, 'Root/AuthTest/add'
));
$this->Controller->Auth->startup($this->Controller);
$this->assertTrue($this->Controller->Auth->isAuthorized());
}
/**
* Tests that deny always takes precedence over allow
*

0 comments on commit c946985

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