2012-04-16 02:54:13 +00:00
|
|
|
<?php
|
2011-10-10 21:18:48 +00:00
|
|
|
/**
|
|
|
|
* IniAclTest file.
|
|
|
|
*
|
2017-06-10 21:33:55 +00:00
|
|
|
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
2017-06-10 22:10:52 +00:00
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2011-10-10 21:18:48 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
2013-02-08 12:22:51 +00:00
|
|
|
* For full copyright and license information, please see the LICENSE.txt
|
2011-10-10 21:18:48 +00:00
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2017-06-10 22:10:52 +00:00
|
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2017-06-10 21:33:55 +00:00
|
|
|
* @link https://cakephp.org CakePHP(tm) Project
|
2012-02-23 18:45:32 +00:00
|
|
|
* @package Cake.Test.Case.Controller.Component.Acl
|
2011-10-10 21:18:48 +00:00
|
|
|
* @since CakePHP(tm) v 2.0
|
2017-06-10 22:23:14 +00:00
|
|
|
* @license https://opensource.org/licenses/mit-license.php MIT License
|
2011-10-10 21:18:48 +00:00
|
|
|
*/
|
2013-05-30 22:11:14 +00:00
|
|
|
|
2012-01-29 18:54:26 +00:00
|
|
|
App::uses('IniAcl', 'Controller/Component/Acl');
|
2011-09-14 01:25:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test case for the IniAcl implementation
|
|
|
|
*
|
2012-02-23 18:45:32 +00:00
|
|
|
* @package Cake.Test.Case.Controller.Component.Acl
|
2011-09-14 01:25:50 +00:00
|
|
|
*/
|
|
|
|
class IniAclTest extends CakeTestCase {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* testIniCheck method
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testCheck() {
|
2012-03-12 02:20:25 +00:00
|
|
|
$iniFile = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'acl.ini.php';
|
2011-09-14 01:25:50 +00:00
|
|
|
|
|
|
|
$Ini = new IniAcl();
|
|
|
|
$Ini->config = $Ini->readConfigFile($iniFile);
|
|
|
|
|
|
|
|
$this->assertFalse($Ini->check('admin', 'ads'));
|
|
|
|
$this->assertTrue($Ini->check('admin', 'posts'));
|
|
|
|
|
|
|
|
$this->assertTrue($Ini->check('jenny', 'posts'));
|
|
|
|
$this->assertTrue($Ini->check('jenny', 'ads'));
|
|
|
|
|
|
|
|
$this->assertTrue($Ini->check('paul', 'posts'));
|
|
|
|
$this->assertFalse($Ini->check('paul', 'ads'));
|
|
|
|
|
|
|
|
$this->assertFalse($Ini->check('nobody', 'comments'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* check should accept a user array.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testCheckArray() {
|
2012-03-12 02:20:25 +00:00
|
|
|
$iniFile = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'acl.ini.php';
|
2011-09-14 01:25:50 +00:00
|
|
|
|
|
|
|
$Ini = new IniAcl();
|
|
|
|
$Ini->config = $Ini->readConfigFile($iniFile);
|
|
|
|
$Ini->userPath = 'User.username';
|
|
|
|
|
|
|
|
$user = array(
|
|
|
|
'User' => array('username' => 'admin')
|
|
|
|
);
|
|
|
|
$this->assertTrue($Ini->check($user, 'posts'));
|
|
|
|
}
|
|
|
|
}
|