Fixing ACL interface class names

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6999 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-05-22 02:00:36 +00:00
parent 1523020ea1
commit 6c5f98ddec
9 changed files with 40 additions and 41 deletions

View file

@ -170,7 +170,7 @@
* The classname and database used in CakePHP's
* access control lists.
*/
Configure::write('Acl.classname', 'DB_ACL');
Configure::write('Acl.classname', 'DbAcl');
Configure::write('Acl.database', 'default');
/**
* Cache Engine Configuration

View file

@ -75,12 +75,12 @@ class AclShell extends Shell {
$this->dataSource = $this->params['datasource'];
}
if (Configure::read('Acl.classname') != 'DB_ACL') {
if (!in_array(Configure::read('Acl.classname'), array('DbAcl', 'DB_ACL'))) {
$out = "--------------------------------------------------\n";
$out .= __("Error: Your current Cake configuration is set to", true) . "\n";
$out .= __("an ACL implementation other than DB. Please change", true) . "\n";
$out .= __("your core config to reflect your decision to use", true) . "\n";
$out .= __("DB_ACL before attempting to use this script", true) . ".\n";
$out .= __("DbAcl before attempting to use this script", true) . ".\n";
$out .= "--------------------------------------------------\n";
$out .= sprintf(__("Current ACL Classname: %s", true), Configure::read('Acl.classname')) . "\n";
$out .= "--------------------------------------------------\n";

View file

@ -170,7 +170,7 @@
* The classname and database used in CakePHP's
* access control lists.
*/
Configure::write('Acl.classname', 'DB_ACL');
Configure::write('Acl.classname', 'DbAcl');
Configure::write('Acl.database', 'default');
/**
* Cache Engine Configuration

View file

@ -47,7 +47,7 @@ class AclComponent extends Object {
*
*/
function __construct() {
$name = Configure::read('Acl.classname');
$name = Inflector::camelize(strtolower(Configure::read('Acl.classname')));
if (!class_exists($name)) {
if (App::import('Component', $name)) {
if (strpos($name, '.') !== false) {
@ -237,7 +237,7 @@ class AclBase extends Object {
* @package cake
* @subpackage cake.cake.libs.model
*/
class DB_ACL extends AclBase {
class DbAcl extends AclBase {
/**
* Constructor
*
@ -277,11 +277,11 @@ class DB_ACL extends AclBase {
$acoPath = new Set($this->Aco->node($aco));
if (empty($aroPath) || empty($acoPath)) {
trigger_error("DB_ACL::check() - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: " . print_r($aro, true) . "\nAco: " . print_r($aco, true), E_USER_WARNING);
trigger_error("DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: " . print_r($aro, true) . "\nAco: " . print_r($aco, true), E_USER_WARNING);
return false;
}
if ($acoPath->get() == null || $acoPath->get() == array()) {
trigger_error("DB_ACL::check() - Failed ACO node lookup in permissions check. Node references:\nAro: " . print_r($aro, true) . "\nAco: " . print_r($aco, true), E_USER_WARNING);
trigger_error("DbAcl::check() - Failed ACO node lookup in permissions check. Node references:\nAro: " . print_r($aro, true) . "\nAco: " . print_r($aco, true), E_USER_WARNING);
return false;
}
@ -290,7 +290,7 @@ class DB_ACL extends AclBase {
$acoNode = $acoNode[0];
if ($action != '*' && !in_array('_' . $action, $permKeys)) {
trigger_error(sprintf(__("ACO permissions key %s does not exist in DB_ACL::check()", true), $action), E_USER_NOTICE);
trigger_error(sprintf(__("ACO permissions key %s does not exist in DbAcl::check()", true), $action), E_USER_NOTICE);
return false;
}
@ -362,7 +362,7 @@ class DB_ACL extends AclBase {
$save = array();
if ($perms == false) {
trigger_error(__('DB_ACL::allow() - Invalid node', true), E_USER_WARNING);
trigger_error(__('DbAcl::allow() - Invalid node', true), E_USER_WARNING);
return false;
}
if (isset($perms[0])) {
@ -496,7 +496,7 @@ class DB_ACL extends AclBase {
* @package cake
* @subpackage cake.cake.libs.model.iniacl
*/
class INI_ACL extends AclBase {
class IniAcl extends AclBase {
/**
* Array with configuration, parsed from ini file
*

View file

@ -78,7 +78,6 @@ class AclNode extends AppModel {
function node($ref = null) {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
$type = $this->alias;
$prefix = $this->tablePrefix;
$result = null;
if (!empty($this->useTable)) {
@ -100,7 +99,7 @@ class AclNode extends AppModel {
$db->name("{$type}.rght") . ' >= ' . $db->name("{$type}0.rght")),
'fields' => array('id', 'parent_id', 'model', 'foreign_key', 'alias'),
'joins' => array(array(
'table' => $db->name($prefix . $table),
'table' => $db->fullTableName($this),
'alias' => "{$type}0",
'type' => 'LEFT',
'conditions' => array("{$type}0.alias" => $start)
@ -112,7 +111,7 @@ class AclNode extends AppModel {
$j = $i - 1;
$queryData['joins'][] = array(
'table' => $db->name($prefix . $table),
'table' => $db->fullTableName($this),
'alias' => "{$type}{$i}",
'type' => 'LEFT',
'conditions' => array(
@ -177,7 +176,7 @@ class AclNode extends AppModel {
'conditions' => $ref,
'fields' => array('id', 'parent_id', 'model', 'foreign_key', 'alias'),
'joins' => array(array(
'table' => $db->name($prefix . $table),
'table' => $db->fullTableName($table),
'alias' => "{$type}0",
'type' => 'LEFT',
'conditions' => array(

View file

@ -54,7 +54,7 @@ class PermissionTwoTest extends CakeTestModel {
var $actsAs = null;
}
class DB_ACL_TWO_TEST extends DB_ACL {
class DbAclTwoTest extends DbAcl {
function __construct() {
$this->Aro =& new AroTwoTest();
@ -63,7 +63,7 @@ class DB_ACL_TWO_TEST extends DB_ACL {
$this->Aro->Permission =& new PermissionTwoTest();
}
}
class INI_ACL_TEST extends INI_ACL {
class IniAclTest extends IniAcl {
}
@ -82,7 +82,7 @@ class AclComponentTest extends CakeTestCase {
}
function before($method) {
Configure::write('Acl.classname', 'DB_ACL_TWO_TEST');
Configure::write('Acl.classname', 'DbAclTwoTest');
Configure::write('Acl.database', 'test_suite');
parent::before($method);
}
@ -121,10 +121,10 @@ class AclComponentTest extends CakeTestCase {
$this->assertTrue($this->Acl->check('Samir', 'view', 'read'));
$this->assertTrue($this->Acl->check('root/users/Samir', 'ROOT/tpsReports/view', 'update'));
$this->expectError('DB_ACL::allow() - Invalid node');
$this->expectError('DbAcl::allow() - Invalid node');
$this->assertFalse($this->Acl->allow('Lumbergh', 'ROOT/tpsReports/DoesNotExist', 'create'));
$this->expectError('DB_ACL::allow() - Invalid node');
$this->expectError('DbAcl::allow() - Invalid node');
$this->assertFalse($this->Acl->allow('Homer', 'tpsReports', 'create'));
}
@ -134,14 +134,14 @@ class AclComponentTest extends CakeTestCase {
$this->assertFalse($this->Acl->check('Milton', 'smash', 'read'));
$this->assertFalse($this->Acl->check('Milton', 'current', 'update'));
$this->expectError("DB_ACL::check() - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: WRONG\nAco: tpsReports");
$this->expectError("DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: WRONG\nAco: tpsReports");
$this->assertFalse($this->Acl->check('WRONG', 'tpsReports', 'read'));
$this->expectError("ACO permissions key foobar does not exist in DB_ACL::check()");
$this->expectError("ACO permissions key foobar does not exist in DbAcl::check()");
$this->assertFalse($this->Acl->check('Lumbergh', 'smash', 'foobar'));
//The next assertion should generate an error but only returns false.
//$this->expectError("DB_ACL::check() - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: users\nAco: NonExistant");
//$this->expectError("DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: users\nAco: NonExistant");
$this->assertFalse($this->Acl->check('users', 'NonExistant', 'read'));
$this->assertFalse($this->Acl->check(null, 'printers', 'create'));
@ -190,7 +190,7 @@ class AclComponentTest extends CakeTestCase {
$expected = '-1';
$this->assertEqual($result[0]['PermissionTwoTest']['_delete'], $expected);
$this->expectError('DB_ACL::allow() - Invalid node');
$this->expectError('DbAcl::allow() - Invalid node');
$this->assertFalse($this->Acl->deny('Lumbergh', 'ROOT/tpsReports/DoesNotExist', 'create'));
}
@ -237,7 +237,7 @@ class AclComponentTest extends CakeTestCase {
$this->assertTrue($this->Acl->check('Micheal', 'view', 'update'));
$this->assertFalse($this->Acl->check('Micheal', 'view', 'delete'));
$this->expectError('DB_ACL::allow() - Invalid node');
$this->expectError('DbAcl::allow() - Invalid node');
$this->assertFalse($this->Acl->grant('Peter', 'ROOT/tpsReports/DoesNotExist', 'create'));
}
@ -252,7 +252,7 @@ class AclComponentTest extends CakeTestCase {
$this->assertFalse($this->Acl->check('Samir', 'printers', 'read'));
$this->assertFalse($this->Acl->check('Peter', 'printers', 'read'));
$this->expectError('DB_ACL::allow() - Invalid node');
$this->expectError('DbAcl::allow() - Invalid node');
$this->assertFalse($this->Acl->deny('Bobs', 'ROOT/printers/DoesNotExist', 'create'));
}
@ -264,31 +264,31 @@ class AclComponentTest extends CakeTestCase {
/* The following tests and AclComponent methods are not fully implemented yet
function testDbSetAro() {
//This method is not implemented in either INI_ACL or DB_ACL
//This method is not implemented in either IniAcl or DbAcl
//$result = $this->Acl->setAro('Samir');
//$this->assertEqual($result, $expected);
}
function testDbSetAco() {
//This method is not implemented in either INI_ACL or DB_ACL
//This method is not implemented in either IniAcl or DbAcl
//$result = $this->Acl->getAco('printers');
//$this->assertEqual($result, $expected);
}
function testDbGetAro() {
//This method is not implemented in either INI_ACL or DB_ACL
//This method is not implemented in either IniAcl or DbAcl
//$result = $this->Acl->getAro('Samir');
//$this->assertEqual($result, $expected);
}
function testDbGetAco() {
//This method is not implemented in either INI_ACL or DB_ACL
//This method is not implemented in either IniAcl or DbAcl
//$result = $this->Acl->getAco('tpsReports');
//$this->assertEqual($result, $expected);
}
*/
function testIniReadConfigFile() {
Configure::write('Acl.classname', 'INI_ACL_TEST');
Configure::write('Acl.classname', 'IniAclTest');
unset($this->Acl);
$this->Acl = new AclComponent();
$iniFile = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config'. DS . 'acl.ini.php';
@ -331,7 +331,7 @@ class AclComponentTest extends CakeTestCase {
}
function testIniCheck() {
Configure::write('Acl.classname', 'INI_ACL_TEST');
Configure::write('Acl.classname', 'IniAclTest');
unset($this->Acl);
$iniFile = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config'. DS . 'acl.ini.php';

View file

@ -293,7 +293,7 @@ class AuthTest extends CakeTestCase {
$this->Controller->params['controller'] = 'auth_test';
$this->Controller->params['action'] = 'add';
$this->Controller->Acl->name = 'DB_ACL_TEST';
$this->Controller->Acl->name = 'DbAclTest';
$this->Controller->Acl->Aro->id = null;
$this->Controller->Acl->Aro->create(array('alias'=>'Roles'));

View file

@ -30,7 +30,8 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
}
App::import(array('controller'.DS.'components'.DS.'acl', 'model'.DS.'db_acl'));
App::import('Component', 'Acl');
App::import('Core', 'db_acl');
/**
* DB ACL wrapper test class
@ -115,7 +116,7 @@ class DbAroUserTest extends CakeTestModel {
* @package cake.tests
* @subpackage cake.tests.cases.libs.controller.components
*/
class DBACL_TEST extends DB_ACL {
class DbAclTest extends DbAcl {
function __construct() {
$this->Aro =& new DbAroTest();
@ -135,7 +136,7 @@ class AclNodeTest extends CakeTestCase {
var $fixtures = array('core.aro', 'core.aco', 'core.aros_aco', 'core.aco_action', 'core.auth_user');
function setUp() {
Configure::write('Acl.classname', 'DB_ACL_TEST');
Configure::write('Acl.classname', 'DbAclTest');
Configure::write('Acl.database', 'test_suite');
}

View file

@ -46,11 +46,10 @@ class AroFixture extends CakeTestFixture {
);
var $records = array(
array('id' => '1', 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'ROOT', 'lft' => 1, 'rght' => 8),
array('id' => '2', 'parent_id' => '1', 'model' => 'Group', 'foreign_key' => '1', 'alias' => 'admins', 'lft' => 2, 'rght' => 7),
array('id' => '3', 'parent_id' => '2', 'model' => 'AuthUser', 'foreign_key' => '1', 'alias' => 'Gandalf', 'lft' => 3, 'rght' => 4),
array('id' => '4', 'parent_id' => '2', 'model' => 'AuthUser', 'foreign_key' => '2', 'alias' => 'Elrond', 'lft' => 5, 'rght' => 6),
array('parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'ROOT', 'lft' => 1, 'rght' => 8),
array('parent_id' => '1', 'model' => 'Group', 'foreign_key' => '1', 'alias' => 'admins', 'lft' => 2, 'rght' => 7),
array('parent_id' => '2', 'model' => 'AuthUser', 'foreign_key' => '1', 'alias' => 'Gandalf', 'lft' => 3, 'rght' => 4),
array('parent_id' => '2', 'model' => 'AuthUser', 'foreign_key' => '2', 'alias' => 'Elrond', 'lft' => 5, 'rght' => 6)
);
}