| 13532 |
anikendra |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* IniAclTest file.
|
|
|
4 |
*
|
|
|
5 |
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
|
|
6 |
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
|
7 |
*
|
|
|
8 |
* Licensed under The MIT License
|
|
|
9 |
* For full copyright and license information, please see the LICENSE.txt
|
|
|
10 |
* Redistributions of files must retain the above copyright notice.
|
|
|
11 |
*
|
|
|
12 |
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
|
13 |
* @link http://cakephp.org CakePHP(tm) Project
|
|
|
14 |
* @package Cake.Test.Case.Controller.Component.Acl
|
|
|
15 |
* @since CakePHP(tm) v 2.0
|
|
|
16 |
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
|
|
17 |
*/
|
|
|
18 |
|
|
|
19 |
App::uses('IniAcl', 'Controller/Component/Acl');
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
* Test case for the IniAcl implementation
|
|
|
23 |
*
|
|
|
24 |
* @package Cake.Test.Case.Controller.Component.Acl
|
|
|
25 |
*/
|
|
|
26 |
class IniAclTest extends CakeTestCase {
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
* testIniCheck method
|
|
|
30 |
*
|
|
|
31 |
* @return void
|
|
|
32 |
*/
|
|
|
33 |
public function testCheck() {
|
|
|
34 |
$iniFile = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'acl.ini.php';
|
|
|
35 |
|
|
|
36 |
$Ini = new IniAcl();
|
|
|
37 |
$Ini->config = $Ini->readConfigFile($iniFile);
|
|
|
38 |
|
|
|
39 |
$this->assertFalse($Ini->check('admin', 'ads'));
|
|
|
40 |
$this->assertTrue($Ini->check('admin', 'posts'));
|
|
|
41 |
|
|
|
42 |
$this->assertTrue($Ini->check('jenny', 'posts'));
|
|
|
43 |
$this->assertTrue($Ini->check('jenny', 'ads'));
|
|
|
44 |
|
|
|
45 |
$this->assertTrue($Ini->check('paul', 'posts'));
|
|
|
46 |
$this->assertFalse($Ini->check('paul', 'ads'));
|
|
|
47 |
|
|
|
48 |
$this->assertFalse($Ini->check('nobody', 'comments'));
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* check should accept a user array.
|
|
|
53 |
*
|
|
|
54 |
* @return void
|
|
|
55 |
*/
|
|
|
56 |
public function testCheckArray() {
|
|
|
57 |
$iniFile = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'acl.ini.php';
|
|
|
58 |
|
|
|
59 |
$Ini = new IniAcl();
|
|
|
60 |
$Ini->config = $Ini->readConfigFile($iniFile);
|
|
|
61 |
$Ini->userPath = 'User.username';
|
|
|
62 |
|
|
|
63 |
$user = array(
|
|
|
64 |
'User' => array('username' => 'admin')
|
|
|
65 |
);
|
|
|
66 |
$this->assertTrue($Ini->check($user, 'posts'));
|
|
|
67 |
}
|
|
|
68 |
}
|