2007-07-09 20:07:38 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id$ */
|
|
|
|
/**
|
2007-07-09 20:45:29 +00:00
|
|
|
* Short description for file.
|
2007-07-09 20:07:38 +00:00
|
|
|
*
|
|
|
|
* Long description for file
|
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
|
|
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
2008-01-01 22:18:17 +00:00
|
|
|
* Copyright 2005-2008, Cake Software Foundation, Inc.
|
2007-07-09 20:07:38 +00:00
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
|
|
|
*
|
|
|
|
* Licensed under The Open Group Test Suite License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
|
|
|
* @filesource
|
2008-01-01 22:18:17 +00:00
|
|
|
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
|
2007-07-09 20:07:38 +00:00
|
|
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.controller.components
|
|
|
|
* @since CakePHP(tm) v 1.2.0.5435
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
|
|
|
*/
|
Fixes #2902, DB_ACL::allow allowing all when $actions is not an array.
Fixes #2988, AclComponent check() does not inherit permissions.
Fixes #3022, Inconsistent table alias quoting crashes Acl node lookup with PostgreSQL.
Fixes #3129, Console ACL Shell ACO View Broken
Fixes #3176, Problems with ACL support on Microsoft SQL Server.
Closes #3311 as invalid, DboSourceTest::testArrayConditionsParsing tests added
Fixes #3312, DB_ACL::check() fail returning right permission
Fixes #3344, Model->field adds incorrect condition under certain circumstances.
Fixes #3400, Cookie Component: When reading a non-existing key it throws a notice.
Fixes #3407, Since [5768] CookieComponent throws warning when used in beforeFilter().
Closes #3401, Added form test to ensure $Form->fields array is what the security component requires.
Updated AclComponentTest
Merged changes in app/ to cake/console/libs/templates/skel
Fixed generated link to Run More Test after running Group > All tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5776 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-10-17 12:51:17 +00:00
|
|
|
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
|
|
|
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
|
|
|
}
|
2008-05-13 19:29:03 +00:00
|
|
|
App::import(array('controller'.DS.'components'.DS.'acl', 'model'.DS.'db_acl'));
|
2007-08-21 14:29:39 +00:00
|
|
|
|
Fixes #2902, DB_ACL::allow allowing all when $actions is not an array.
Fixes #2988, AclComponent check() does not inherit permissions.
Fixes #3022, Inconsistent table alias quoting crashes Acl node lookup with PostgreSQL.
Fixes #3129, Console ACL Shell ACO View Broken
Fixes #3176, Problems with ACL support on Microsoft SQL Server.
Closes #3311 as invalid, DboSourceTest::testArrayConditionsParsing tests added
Fixes #3312, DB_ACL::check() fail returning right permission
Fixes #3344, Model->field adds incorrect condition under certain circumstances.
Fixes #3400, Cookie Component: When reading a non-existing key it throws a notice.
Fixes #3407, Since [5768] CookieComponent throws warning when used in beforeFilter().
Closes #3401, Added form test to ensure $Form->fields array is what the security component requires.
Updated AclComponentTest
Merged changes in app/ to cake/console/libs/templates/skel
Fixed generated link to Run More Test after running Group > All tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5776 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-10-17 12:51:17 +00:00
|
|
|
|
2008-05-13 19:29:03 +00:00
|
|
|
class AclNodeTwoTestBase extends AclNode {
|
2007-11-09 05:13:12 +00:00
|
|
|
var $useDbConfig = 'test_suite';
|
|
|
|
var $cacheSources = false;
|
Fixes #2902, DB_ACL::allow allowing all when $actions is not an array.
Fixes #2988, AclComponent check() does not inherit permissions.
Fixes #3022, Inconsistent table alias quoting crashes Acl node lookup with PostgreSQL.
Fixes #3129, Console ACL Shell ACO View Broken
Fixes #3176, Problems with ACL support on Microsoft SQL Server.
Closes #3311 as invalid, DboSourceTest::testArrayConditionsParsing tests added
Fixes #3312, DB_ACL::check() fail returning right permission
Fixes #3344, Model->field adds incorrect condition under certain circumstances.
Fixes #3400, Cookie Component: When reading a non-existing key it throws a notice.
Fixes #3407, Since [5768] CookieComponent throws warning when used in beforeFilter().
Closes #3401, Added form test to ensure $Form->fields array is what the security component requires.
Updated AclComponentTest
Merged changes in app/ to cake/console/libs/templates/skel
Fixed generated link to Run More Test after running Group > All tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5776 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-10-17 12:51:17 +00:00
|
|
|
}
|
2008-05-13 19:29:03 +00:00
|
|
|
class AroTwoTest extends AclNodeTwoTestBase {
|
|
|
|
var $name = 'AroTwoTest';
|
|
|
|
var $useTable = 'aro_twos';
|
|
|
|
var $hasAndBelongsToMany = array('AcoTwoTest' => array('with' => 'PermissionTwoTest'));
|
Fixes #2902, DB_ACL::allow allowing all when $actions is not an array.
Fixes #2988, AclComponent check() does not inherit permissions.
Fixes #3022, Inconsistent table alias quoting crashes Acl node lookup with PostgreSQL.
Fixes #3129, Console ACL Shell ACO View Broken
Fixes #3176, Problems with ACL support on Microsoft SQL Server.
Closes #3311 as invalid, DboSourceTest::testArrayConditionsParsing tests added
Fixes #3312, DB_ACL::check() fail returning right permission
Fixes #3344, Model->field adds incorrect condition under certain circumstances.
Fixes #3400, Cookie Component: When reading a non-existing key it throws a notice.
Fixes #3407, Since [5768] CookieComponent throws warning when used in beforeFilter().
Closes #3401, Added form test to ensure $Form->fields array is what the security component requires.
Updated AclComponentTest
Merged changes in app/ to cake/console/libs/templates/skel
Fixed generated link to Run More Test after running Group > All tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5776 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-10-17 12:51:17 +00:00
|
|
|
}
|
2008-05-13 19:29:03 +00:00
|
|
|
class AcoTwoTest extends AclNodeTwoTestBase {
|
|
|
|
var $name = 'AcoTwoTest';
|
|
|
|
var $useTable = 'aco_twos';
|
|
|
|
var $hasAndBelongsToMany = array('AroTwoTest' => array('with' => 'PermissionTwoTest'));
|
Fixes #2902, DB_ACL::allow allowing all when $actions is not an array.
Fixes #2988, AclComponent check() does not inherit permissions.
Fixes #3022, Inconsistent table alias quoting crashes Acl node lookup with PostgreSQL.
Fixes #3129, Console ACL Shell ACO View Broken
Fixes #3176, Problems with ACL support on Microsoft SQL Server.
Closes #3311 as invalid, DboSourceTest::testArrayConditionsParsing tests added
Fixes #3312, DB_ACL::check() fail returning right permission
Fixes #3344, Model->field adds incorrect condition under certain circumstances.
Fixes #3400, Cookie Component: When reading a non-existing key it throws a notice.
Fixes #3407, Since [5768] CookieComponent throws warning when used in beforeFilter().
Closes #3401, Added form test to ensure $Form->fields array is what the security component requires.
Updated AclComponentTest
Merged changes in app/ to cake/console/libs/templates/skel
Fixed generated link to Run More Test after running Group > All tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5776 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-10-17 12:51:17 +00:00
|
|
|
}
|
2008-05-13 19:29:03 +00:00
|
|
|
class PermissionTwoTest extends CakeTestModel {
|
|
|
|
var $name = 'PermissionTwoTest';
|
|
|
|
var $useTable = 'aros_aco_twos';
|
2007-11-09 05:13:12 +00:00
|
|
|
var $cacheQueries = false;
|
2008-05-13 19:29:03 +00:00
|
|
|
var $belongsTo = array('AroTwoTest' => array('foreignKey' => 'aro_id'), 'AcoTwoTest' => array('foreignKey' => 'aco_id'));
|
2007-11-09 05:13:12 +00:00
|
|
|
var $actsAs = null;
|
Fixes #2902, DB_ACL::allow allowing all when $actions is not an array.
Fixes #2988, AclComponent check() does not inherit permissions.
Fixes #3022, Inconsistent table alias quoting crashes Acl node lookup with PostgreSQL.
Fixes #3129, Console ACL Shell ACO View Broken
Fixes #3176, Problems with ACL support on Microsoft SQL Server.
Closes #3311 as invalid, DboSourceTest::testArrayConditionsParsing tests added
Fixes #3312, DB_ACL::check() fail returning right permission
Fixes #3344, Model->field adds incorrect condition under certain circumstances.
Fixes #3400, Cookie Component: When reading a non-existing key it throws a notice.
Fixes #3407, Since [5768] CookieComponent throws warning when used in beforeFilter().
Closes #3401, Added form test to ensure $Form->fields array is what the security component requires.
Updated AclComponentTest
Merged changes in app/ to cake/console/libs/templates/skel
Fixed generated link to Run More Test after running Group > All tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5776 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-10-17 12:51:17 +00:00
|
|
|
}
|
2008-05-13 19:29:03 +00:00
|
|
|
|
|
|
|
class DB_ACL_TWO_TEST extends DB_ACL {
|
Fixes #2902, DB_ACL::allow allowing all when $actions is not an array.
Fixes #2988, AclComponent check() does not inherit permissions.
Fixes #3022, Inconsistent table alias quoting crashes Acl node lookup with PostgreSQL.
Fixes #3129, Console ACL Shell ACO View Broken
Fixes #3176, Problems with ACL support on Microsoft SQL Server.
Closes #3311 as invalid, DboSourceTest::testArrayConditionsParsing tests added
Fixes #3312, DB_ACL::check() fail returning right permission
Fixes #3344, Model->field adds incorrect condition under certain circumstances.
Fixes #3400, Cookie Component: When reading a non-existing key it throws a notice.
Fixes #3407, Since [5768] CookieComponent throws warning when used in beforeFilter().
Closes #3401, Added form test to ensure $Form->fields array is what the security component requires.
Updated AclComponentTest
Merged changes in app/ to cake/console/libs/templates/skel
Fixed generated link to Run More Test after running Group > All tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5776 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-10-17 12:51:17 +00:00
|
|
|
|
2007-11-09 05:13:12 +00:00
|
|
|
function __construct() {
|
2008-05-13 19:29:03 +00:00
|
|
|
$this->Aro =& new AroTwoTest();
|
|
|
|
$this->Aro->Permission =& new PermissionTwoTest();
|
|
|
|
$this->Aco =& new AcoTwoTest();
|
|
|
|
$this->Aro->Permission =& new PermissionTwoTest();
|
Fixes #2902, DB_ACL::allow allowing all when $actions is not an array.
Fixes #2988, AclComponent check() does not inherit permissions.
Fixes #3022, Inconsistent table alias quoting crashes Acl node lookup with PostgreSQL.
Fixes #3129, Console ACL Shell ACO View Broken
Fixes #3176, Problems with ACL support on Microsoft SQL Server.
Closes #3311 as invalid, DboSourceTest::testArrayConditionsParsing tests added
Fixes #3312, DB_ACL::check() fail returning right permission
Fixes #3344, Model->field adds incorrect condition under certain circumstances.
Fixes #3400, Cookie Component: When reading a non-existing key it throws a notice.
Fixes #3407, Since [5768] CookieComponent throws warning when used in beforeFilter().
Closes #3401, Added form test to ensure $Form->fields array is what the security component requires.
Updated AclComponentTest
Merged changes in app/ to cake/console/libs/templates/skel
Fixed generated link to Run More Test after running Group > All tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5776 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-10-17 12:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-11 19:49:13 +00:00
|
|
|
class INI_ACL_TEST extends INI_ACL {
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
}
|
|
|
|
|
2007-07-09 20:07:38 +00:00
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.controller.components
|
|
|
|
*/
|
|
|
|
class AclComponentTest extends CakeTestCase {
|
2007-08-21 14:29:39 +00:00
|
|
|
|
2008-05-13 19:29:03 +00:00
|
|
|
var $fixtures = array('core.aro_two', 'core.aco_two', 'core.aros_aco_two');
|
2007-10-29 00:17:37 +00:00
|
|
|
|
2007-10-14 01:09:21 +00:00
|
|
|
function startTest() {
|
2007-08-21 14:29:39 +00:00
|
|
|
$this->Acl =& new AclComponent();
|
|
|
|
}
|
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
function before($method) {
|
2008-05-13 19:29:03 +00:00
|
|
|
Configure::write('Acl.classname', 'DB_ACL_TWO_TEST');
|
2008-05-11 19:49:13 +00:00
|
|
|
Configure::write('Acl.database', 'test_suite');
|
2008-05-13 19:29:03 +00:00
|
|
|
parent::before($method);
|
2007-10-29 00:17:37 +00:00
|
|
|
}
|
|
|
|
|
Fixes #2902, DB_ACL::allow allowing all when $actions is not an array.
Fixes #2988, AclComponent check() does not inherit permissions.
Fixes #3022, Inconsistent table alias quoting crashes Acl node lookup with PostgreSQL.
Fixes #3129, Console ACL Shell ACO View Broken
Fixes #3176, Problems with ACL support on Microsoft SQL Server.
Closes #3311 as invalid, DboSourceTest::testArrayConditionsParsing tests added
Fixes #3312, DB_ACL::check() fail returning right permission
Fixes #3344, Model->field adds incorrect condition under certain circumstances.
Fixes #3400, Cookie Component: When reading a non-existing key it throws a notice.
Fixes #3407, Since [5768] CookieComponent throws warning when used in beforeFilter().
Closes #3401, Added form test to ensure $Form->fields array is what the security component requires.
Updated AclComponentTest
Merged changes in app/ to cake/console/libs/templates/skel
Fixed generated link to Run More Test after running Group > All tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5776 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-10-17 12:51:17 +00:00
|
|
|
function testAclCreate() {
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->Acl->Aro->create(array('alias' => 'Chotchkey'));
|
2008-04-10 13:19:10 +00:00
|
|
|
$this->assertTrue($this->Acl->Aro->save());
|
Fixes #2902, DB_ACL::allow allowing all when $actions is not an array.
Fixes #2988, AclComponent check() does not inherit permissions.
Fixes #3022, Inconsistent table alias quoting crashes Acl node lookup with PostgreSQL.
Fixes #3129, Console ACL Shell ACO View Broken
Fixes #3176, Problems with ACL support on Microsoft SQL Server.
Closes #3311 as invalid, DboSourceTest::testArrayConditionsParsing tests added
Fixes #3312, DB_ACL::check() fail returning right permission
Fixes #3344, Model->field adds incorrect condition under certain circumstances.
Fixes #3400, Cookie Component: When reading a non-existing key it throws a notice.
Fixes #3407, Since [5768] CookieComponent throws warning when used in beforeFilter().
Closes #3401, Added form test to ensure $Form->fields array is what the security component requires.
Updated AclComponentTest
Merged changes in app/ to cake/console/libs/templates/skel
Fixed generated link to Run More Test after running Group > All tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5776 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-10-17 12:51:17 +00:00
|
|
|
|
|
|
|
$parent = $this->Acl->Aro->id;
|
2007-08-21 14:29:39 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->Acl->Aro->create(array('parent_id' => $parent, 'alias' => 'Joanna'));
|
2008-04-10 13:19:10 +00:00
|
|
|
$this->assertTrue($this->Acl->Aro->save());
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->Acl->Aro->create(array('parent_id' => $parent, 'alias' => 'Stapler'));
|
2008-04-10 13:19:10 +00:00
|
|
|
$this->assertTrue($this->Acl->Aro->save());
|
2007-08-21 14:29:39 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$root = $this->Acl->Aco->node('ROOT');
|
2008-05-13 19:29:03 +00:00
|
|
|
$parent = $root[0]['AcoTwoTest']['id'];
|
Fixes #2902, DB_ACL::allow allowing all when $actions is not an array.
Fixes #2988, AclComponent check() does not inherit permissions.
Fixes #3022, Inconsistent table alias quoting crashes Acl node lookup with PostgreSQL.
Fixes #3129, Console ACL Shell ACO View Broken
Fixes #3176, Problems with ACL support on Microsoft SQL Server.
Closes #3311 as invalid, DboSourceTest::testArrayConditionsParsing tests added
Fixes #3312, DB_ACL::check() fail returning right permission
Fixes #3344, Model->field adds incorrect condition under certain circumstances.
Fixes #3400, Cookie Component: When reading a non-existing key it throws a notice.
Fixes #3407, Since [5768] CookieComponent throws warning when used in beforeFilter().
Closes #3401, Added form test to ensure $Form->fields array is what the security component requires.
Updated AclComponentTest
Merged changes in app/ to cake/console/libs/templates/skel
Fixed generated link to Run More Test after running Group > All tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5776 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-10-17 12:51:17 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->Acl->Aco->create(array('parent_id' => $parent, 'alias' => 'Drinks'));
|
2008-04-10 13:19:10 +00:00
|
|
|
$this->assertTrue($this->Acl->Aco->save());
|
Fixes #2902, DB_ACL::allow allowing all when $actions is not an array.
Fixes #2988, AclComponent check() does not inherit permissions.
Fixes #3022, Inconsistent table alias quoting crashes Acl node lookup with PostgreSQL.
Fixes #3129, Console ACL Shell ACO View Broken
Fixes #3176, Problems with ACL support on Microsoft SQL Server.
Closes #3311 as invalid, DboSourceTest::testArrayConditionsParsing tests added
Fixes #3312, DB_ACL::check() fail returning right permission
Fixes #3344, Model->field adds incorrect condition under certain circumstances.
Fixes #3400, Cookie Component: When reading a non-existing key it throws a notice.
Fixes #3407, Since [5768] CookieComponent throws warning when used in beforeFilter().
Closes #3401, Added form test to ensure $Form->fields array is what the security component requires.
Updated AclComponentTest
Merged changes in app/ to cake/console/libs/templates/skel
Fixed generated link to Run More Test after running Group > All tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5776 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-10-17 12:51:17 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->Acl->Aco->create(array('parent_id' => $parent, 'alias' => 'PiecesOfFlair'));
|
2008-04-10 13:19:10 +00:00
|
|
|
$this->assertTrue($this->Acl->Aco->save());
|
Fixes #2902, DB_ACL::allow allowing all when $actions is not an array.
Fixes #2988, AclComponent check() does not inherit permissions.
Fixes #3022, Inconsistent table alias quoting crashes Acl node lookup with PostgreSQL.
Fixes #3129, Console ACL Shell ACO View Broken
Fixes #3176, Problems with ACL support on Microsoft SQL Server.
Closes #3311 as invalid, DboSourceTest::testArrayConditionsParsing tests added
Fixes #3312, DB_ACL::check() fail returning right permission
Fixes #3344, Model->field adds incorrect condition under certain circumstances.
Fixes #3400, Cookie Component: When reading a non-existing key it throws a notice.
Fixes #3407, Since [5768] CookieComponent throws warning when used in beforeFilter().
Closes #3401, Added form test to ensure $Form->fields array is what the security component requires.
Updated AclComponentTest
Merged changes in app/ to cake/console/libs/templates/skel
Fixed generated link to Run More Test after running Group > All tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5776 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-10-17 12:51:17 +00:00
|
|
|
|
2007-08-21 14:29:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testDbAclAllow() {
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->assertFalse($this->Acl->check('Micheal', 'tpsReports', 'read'));
|
|
|
|
$this->assertTrue($this->Acl->allow('Micheal', 'tpsReports', array('read', 'delete', 'update')));
|
|
|
|
$this->assertTrue($this->Acl->check('Micheal', 'tpsReports', 'update'));
|
|
|
|
$this->assertTrue($this->Acl->check('Micheal', 'tpsReports', 'read'));
|
|
|
|
$this->assertTrue($this->Acl->check('Micheal', 'tpsReports', 'delete'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->assertFalse($this->Acl->check('root/users/Samir', 'ROOT/tpsReports/view'));
|
|
|
|
$this->assertTrue($this->Acl->allow('root/users/Samir', 'ROOT/tpsReports/view', '*'));
|
|
|
|
$this->assertTrue($this->Acl->check('Samir', 'view', 'read'));
|
|
|
|
$this->assertTrue($this->Acl->check('root/users/Samir', 'ROOT/tpsReports/view', 'update'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-04-11 04:59:52 +00:00
|
|
|
$this->expectError('DB_ACL::allow() - Invalid node');
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->assertFalse($this->Acl->allow('Lumbergh', 'ROOT/tpsReports/DoesNotExist', 'create'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->expectError('DB_ACL::allow() - Invalid node');
|
|
|
|
$this->assertFalse($this->Acl->allow('Homer', 'tpsReports', 'create'));
|
2007-08-21 14:29:39 +00:00
|
|
|
}
|
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
function testDbAclCheck() {
|
|
|
|
$this->assertTrue($this->Acl->check('Samir', 'print', 'read'));
|
|
|
|
$this->assertTrue($this->Acl->check('Lumbergh', 'current', 'read'));
|
|
|
|
$this->assertFalse($this->Acl->check('Milton', 'smash', 'read'));
|
|
|
|
$this->assertFalse($this->Acl->check('Milton', 'current', 'update'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->expectError("DB_ACL::check() - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: WRONG\nAco: tpsReports");
|
|
|
|
$this->assertFalse($this->Acl->check('WRONG', 'tpsReports', 'read'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->expectError("ACO permissions key foobar does not exist in DB_ACL::check()");
|
|
|
|
$this->assertFalse($this->Acl->check('Lumbergh', 'smash', 'foobar'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
//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->assertFalse($this->Acl->check('users', 'NonExistant', 'read'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->assertFalse($this->Acl->check(null, 'printers', 'create'));
|
|
|
|
$this->assertFalse($this->Acl->check('managers', null, 'read'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->assertTrue($this->Acl->check('Bobs', 'ROOT/tpsReports/view/current', 'read'));
|
|
|
|
$this->assertFalse($this->Acl->check('Samir', 'ROOT/tpsReports/update', 'read'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->assertFalse($this->Acl->check('root/users/Milton', 'smash', 'delete'));
|
2007-08-21 14:29:39 +00:00
|
|
|
}
|
2008-05-13 19:29:03 +00:00
|
|
|
|
Fixes #2902, DB_ACL::allow allowing all when $actions is not an array.
Fixes #2988, AclComponent check() does not inherit permissions.
Fixes #3022, Inconsistent table alias quoting crashes Acl node lookup with PostgreSQL.
Fixes #3129, Console ACL Shell ACO View Broken
Fixes #3176, Problems with ACL support on Microsoft SQL Server.
Closes #3311 as invalid, DboSourceTest::testArrayConditionsParsing tests added
Fixes #3312, DB_ACL::check() fail returning right permission
Fixes #3344, Model->field adds incorrect condition under certain circumstances.
Fixes #3400, Cookie Component: When reading a non-existing key it throws a notice.
Fixes #3407, Since [5768] CookieComponent throws warning when used in beforeFilter().
Closes #3401, Added form test to ensure $Form->fields array is what the security component requires.
Updated AclComponentTest
Merged changes in app/ to cake/console/libs/templates/skel
Fixed generated link to Run More Test after running Group > All tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5776 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-10-17 12:51:17 +00:00
|
|
|
function testDbAclDeny() {
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->assertTrue($this->Acl->check('Micheal', 'smash', 'delete'));
|
|
|
|
$this->Acl->deny('Micheal', 'smash', 'delete');
|
|
|
|
$this->assertFalse($this->Acl->check('Micheal', 'smash', 'delete'));
|
|
|
|
$this->assertTrue($this->Acl->check('Micheal', 'smash', 'read'));
|
|
|
|
$this->assertTrue($this->Acl->check('Micheal', 'smash', 'create'));
|
|
|
|
$this->assertTrue($this->Acl->check('Micheal', 'smash', 'update'));
|
|
|
|
$this->assertFalse($this->Acl->check('Micheal', 'smash', '*'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->assertTrue($this->Acl->check('Samir', 'refill', '*'));
|
|
|
|
$this->Acl->deny('Samir', 'refill', '*');
|
|
|
|
$this->assertFalse($this->Acl->check('Samir', 'refill', 'create'));
|
|
|
|
$this->assertFalse($this->Acl->check('Samir', 'refill', 'update'));
|
|
|
|
$this->assertFalse($this->Acl->check('Samir', 'refill', 'read'));
|
|
|
|
$this->assertFalse($this->Acl->check('Samir', 'refill', 'delete'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
|
|
|
$result = $this->Acl->Aro->Permission->find('all', array('conditions' => array('AroTwoTest.alias' => 'Samir')));
|
2008-05-11 19:49:13 +00:00
|
|
|
$expected = '-1';
|
2008-05-13 19:29:03 +00:00
|
|
|
$this->assertEqual($result[0]['PermissionTwoTest']['_delete'], $expected);
|
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->expectError('DB_ACL::allow() - Invalid node');
|
2008-05-13 19:29:03 +00:00
|
|
|
$this->assertFalse($this->Acl->deny('Lumbergh', 'ROOT/tpsReports/DoesNotExist', 'create'));
|
2008-05-11 19:49:13 +00:00
|
|
|
}
|
2008-01-09 00:39:00 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
function testAclNodeLookup() {
|
|
|
|
$result = $this->Acl->Aro->node('root/users/Samir');
|
|
|
|
$expected = array(
|
2008-05-13 19:29:03 +00:00
|
|
|
array('AroTwoTest' => array('id' => '7', 'parent_id' => '4', 'model' => 'User', 'foreign_key' => 3, 'alias' => 'Samir')),
|
|
|
|
array('AroTwoTest' => array('id' => '4', 'parent_id' => '1', 'model' => 'Group', 'foreign_key' => 3, 'alias' => 'users')),
|
|
|
|
array('AroTwoTest' => array('id' => '1', 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'root'))
|
2008-05-11 19:49:13 +00:00
|
|
|
);
|
|
|
|
$this->assertEqual($result, $expected);
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$result = $this->Acl->Aco->node('ROOT/tpsReports/view/current');
|
|
|
|
$expected = array(
|
2008-05-13 19:29:03 +00:00
|
|
|
array('AcoTwoTest' => array('id' => '4', 'parent_id' => '3', 'model' => null, 'foreign_key' => null, 'alias' => 'current')),
|
|
|
|
array('AcoTwoTest' => array('id' => '3', 'parent_id' => '2', 'model' => null, 'foreign_key' => null, 'alias' => 'view')),
|
|
|
|
array('AcoTwoTest' => array('id' => '2', 'parent_id' => '1', 'model' => null, 'foreign_key' => null, 'alias' => 'tpsReports')),
|
|
|
|
array('AcoTwoTest' => array('id' => '1', 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'ROOT')),
|
2008-05-11 19:49:13 +00:00
|
|
|
);
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
}
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
function testDbInherit() {
|
|
|
|
//parent doesn't have access inherit should still deny
|
|
|
|
$this->assertFalse($this->Acl->check('Milton', 'smash', 'delete'));
|
|
|
|
$this->Acl->inherit('Milton', 'smash', 'delete');
|
|
|
|
$this->assertFalse($this->Acl->check('Milton', 'smash', 'delete'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
//inherit parent
|
|
|
|
$this->assertFalse($this->Acl->check('Milton', 'smash', 'read'));
|
|
|
|
$this->Acl->inherit('Milton', 'smash', 'read');
|
|
|
|
$this->assertTrue($this->Acl->check('Milton', 'smash', 'read'));
|
2008-01-09 00:39:00 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
}
|
2008-01-09 00:39:00 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
function testDbGrant() {
|
|
|
|
$this->assertFalse($this->Acl->check('Samir', 'tpsReports', 'create'));
|
|
|
|
$this->Acl->grant('Samir', 'tpsReports', 'create');
|
|
|
|
$this->assertTrue($this->Acl->check('Samir', 'tpsReports', 'create'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->assertFalse($this->Acl->check('Micheal', 'view', 'read'));
|
|
|
|
$this->Acl->grant('Micheal', 'view', array('read', 'create', 'update'));
|
|
|
|
$this->assertTrue($this->Acl->check('Micheal', 'view', 'read'));
|
|
|
|
$this->assertTrue($this->Acl->check('Micheal', 'view', 'create'));
|
|
|
|
$this->assertTrue($this->Acl->check('Micheal', 'view', 'update'));
|
|
|
|
$this->assertFalse($this->Acl->check('Micheal', 'view', 'delete'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->expectError('DB_ACL::allow() - Invalid node');
|
|
|
|
$this->assertFalse($this->Acl->grant('Peter', 'ROOT/tpsReports/DoesNotExist', 'create'));
|
|
|
|
}
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
function testDbRevoke() {
|
|
|
|
$this->assertTrue($this->Acl->check('Bobs', 'tpsReports', 'read'));
|
|
|
|
$this->Acl->revoke('Bobs', 'tpsReports', 'read');
|
|
|
|
$this->assertFalse($this->Acl->check('Bobs', 'tpsReports', 'read'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->assertTrue($this->Acl->check('users', 'printers', 'read'));
|
|
|
|
$this->Acl->revoke('users', 'printers', 'read');
|
|
|
|
$this->assertFalse($this->Acl->check('users', 'printers', 'read'));
|
|
|
|
$this->assertFalse($this->Acl->check('Samir', 'printers', 'read'));
|
|
|
|
$this->assertFalse($this->Acl->check('Peter', 'printers', 'read'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->expectError('DB_ACL::allow() - Invalid node');
|
|
|
|
$this->assertFalse($this->Acl->deny('Bobs', 'ROOT/printers/DoesNotExist', 'create'));
|
|
|
|
}
|
2008-01-09 00:39:00 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
function testStartup() {
|
|
|
|
$controller = new Controller();
|
|
|
|
$this->assertTrue($this->Acl->startup($controller));
|
Fixes #2902, DB_ACL::allow allowing all when $actions is not an array.
Fixes #2988, AclComponent check() does not inherit permissions.
Fixes #3022, Inconsistent table alias quoting crashes Acl node lookup with PostgreSQL.
Fixes #3129, Console ACL Shell ACO View Broken
Fixes #3176, Problems with ACL support on Microsoft SQL Server.
Closes #3311 as invalid, DboSourceTest::testArrayConditionsParsing tests added
Fixes #3312, DB_ACL::check() fail returning right permission
Fixes #3344, Model->field adds incorrect condition under certain circumstances.
Fixes #3400, Cookie Component: When reading a non-existing key it throws a notice.
Fixes #3407, Since [5768] CookieComponent throws warning when used in beforeFilter().
Closes #3401, Added form test to ensure $Form->fields array is what the security component requires.
Updated AclComponentTest
Merged changes in app/ to cake/console/libs/templates/skel
Fixed generated link to Run More Test after running Group > All tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5776 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-10-17 12:51:17 +00:00
|
|
|
}
|
2007-08-21 14:29:39 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
/* The following tests and AclComponent methods are not fully implemented yet
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
function testDbSetAro() {
|
|
|
|
//This method is not implemented in either INI_ACL or DB_ACL
|
|
|
|
//$result = $this->Acl->setAro('Samir');
|
|
|
|
//$this->assertEqual($result, $expected);
|
|
|
|
}
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
function testDbSetAco() {
|
|
|
|
//This method is not implemented in either INI_ACL or DB_ACL
|
|
|
|
//$result = $this->Acl->getAco('printers');
|
|
|
|
//$this->assertEqual($result, $expected);
|
|
|
|
}
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
function testDbGetAro() {
|
|
|
|
//This method is not implemented in either INI_ACL or DB_ACL
|
|
|
|
//$result = $this->Acl->getAro('Samir');
|
|
|
|
//$this->assertEqual($result, $expected);
|
|
|
|
}
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
function testDbGetAco() {
|
|
|
|
//This method is not implemented in either INI_ACL or DB_ACL
|
|
|
|
//$result = $this->Acl->getAco('tpsReports');
|
|
|
|
//$this->assertEqual($result, $expected);
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
function testIniReadConfigFile() {
|
|
|
|
Configure::write('Acl.classname', 'INI_ACL_TEST');
|
|
|
|
unset($this->Acl);
|
|
|
|
$this->Acl = new AclComponent();
|
|
|
|
$iniFile = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'configs'. DS . 'acl.ini.php';
|
|
|
|
$result = $this->Acl->_Instance->readConfigFile($iniFile);
|
2008-02-11 02:27:16 +00:00
|
|
|
$expected = array(
|
2008-05-11 19:49:13 +00:00
|
|
|
'admin' => array(
|
|
|
|
'groups' => 'administrators',
|
|
|
|
'allow' => '',
|
|
|
|
'deny' => 'ads',
|
|
|
|
),
|
|
|
|
'paul' => array(
|
|
|
|
'groups' => 'users',
|
2008-05-13 19:29:03 +00:00
|
|
|
'allow' =>'',
|
2008-05-11 19:49:13 +00:00
|
|
|
'deny' => '',
|
|
|
|
),
|
|
|
|
'jenny' => array(
|
|
|
|
'groups' => 'users',
|
|
|
|
'allow' => 'ads',
|
|
|
|
'deny' => 'images, files',
|
|
|
|
),
|
|
|
|
'nobody' => array(
|
|
|
|
'groups' => 'anonymous',
|
|
|
|
'allow' => '',
|
|
|
|
'deny' => '',
|
|
|
|
),
|
|
|
|
'administrators' => array(
|
|
|
|
'deny' => '',
|
|
|
|
'allow' => 'posts, comments, images, files, stats, ads',
|
|
|
|
),
|
|
|
|
'users' => array(
|
|
|
|
'allow' => 'posts, comments, images, files',
|
|
|
|
'deny' => 'stats, ads',
|
|
|
|
),
|
|
|
|
'anonymous' => array(
|
|
|
|
'allow' => '',
|
|
|
|
'deny' => 'posts, comments, images, files, stats, ads',
|
|
|
|
),
|
2008-02-11 02:27:16 +00:00
|
|
|
);
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
}
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
function testIniCheck() {
|
|
|
|
Configure::write('Acl.classname', 'INI_ACL_TEST');
|
|
|
|
unset($this->Acl);
|
|
|
|
$iniFile = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'configs'. DS . 'acl.ini.php';
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->Acl = new AclComponent();
|
|
|
|
$this->Acl->_Instance->config= $this->Acl->_Instance->readConfigFile($iniFile);
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->assertFalse($this->Acl->check('admin', 'ads'));
|
|
|
|
$this->assertTrue($this->Acl->check('admin', 'posts'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->assertTrue($this->Acl->check('jenny', 'posts'));
|
|
|
|
$this->assertTrue($this->Acl->check('jenny', 'ads'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->assertTrue($this->Acl->check('paul', 'posts'));
|
|
|
|
$this->assertFalse($this->Acl->check('paul', 'ads'));
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
$this->assertFalse($this->Acl->check('nobody', 'comments'));
|
2007-07-09 20:07:38 +00:00
|
|
|
}
|
2008-05-13 19:29:03 +00:00
|
|
|
|
2008-05-11 19:49:13 +00:00
|
|
|
function tearDown() {
|
|
|
|
unset($this->Acl);
|
2008-05-13 19:29:03 +00:00
|
|
|
}
|
2007-07-09 20:07:38 +00:00
|
|
|
}
|
2007-10-29 00:17:37 +00:00
|
|
|
|
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths.
Closes #2234, filepaths to behavior classes should be cached in class.paths.php also
Closes #2345, ability to group components into subfolders
Closes #2645, Improvement to basic.php for class loading.
Fixes #3526, Cache::write, when using just the config name, it fails.
Fixes #3559, loading plugin model as assoc don't work.
Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique)
Fixes #3579, email.php component: Parse error with php 4.
Adding new class and file importer.
Updated most of the core to use the importer.
Added ClassRegsitry::init() that will create and instance of an object and store it in the registry.
Deprecated most of the load functions in basics.php
Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model.
var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models
var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set:
var $uses = array('SomeModel'); will look for some_model.php in the app/models
var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models
var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php
All of the above will work between plugins and main app
These changes also allow placing model and controllers is sub directories
Removed old class.paths.php file generation
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
2007-11-16 09:35:19 +00:00
|
|
|
?>
|