mirror of
				https://github.com/brmlab/brmsklad.git
				synced 2025-10-31 08:13:58 +01:00 
			
		
		
		
	Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
		
							parent
							
								
									5a580df460
								
							
						
					
					
						commit
						235a541597
					
				
					 793 changed files with 60746 additions and 23753 deletions
				
			
		|  | @ -1,20 +1,17 @@ | |||
| <?php | ||||
| /** | ||||
|  * FormAuthenticateTest file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * | ||||
|  * Licensed under The MIT License | ||||
|  * For full copyright and license information, please see the LICENSE.txt | ||||
|  * Redistributions of files must retain the above copyright notice. | ||||
|  * | ||||
|  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP(tm) Project | ||||
|  * @package       Cake.Test.Case.Controller.Component.Auth | ||||
|  * @since         CakePHP(tm) v 2.0 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('AuthComponent', 'Controller/Component'); | ||||
|  | @ -32,6 +29,11 @@ require_once CAKE . 'Test' . DS . 'Case' . DS . 'Model' . DS . 'models.php'; | |||
|  */ | ||||
| class FormAuthenticateTest extends CakeTestCase { | ||||
| 
 | ||||
| /** | ||||
|  * Fixtrues | ||||
|  * | ||||
|  * @var array | ||||
|  */ | ||||
| 	public $fixtures = array('core.user', 'core.auth_user'); | ||||
| 
 | ||||
| /** | ||||
|  | @ -99,6 +101,84 @@ class FormAuthenticateTest extends CakeTestCase { | |||
| 		$this->assertFalse($this->auth->authenticate($request, $this->response)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test authenticate password is false method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAuthenticatePasswordIsFalse() { | ||||
| 		$request = new CakeRequest('posts/index', false); | ||||
| 		$request->data = array( | ||||
| 			'User' => array( | ||||
| 				'user' => 'mariano', | ||||
| 				'password' => null | ||||
| 		)); | ||||
| 		$this->assertFalse($this->auth->authenticate($request, $this->response)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test for password as empty string with _checkFields() call skipped | ||||
|  * Refs https://github.com/cakephp/cakephp/pull/2441 | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAuthenticatePasswordIsEmptyString() { | ||||
| 		$request = new CakeRequest('posts/index', false); | ||||
| 		$request->data = array( | ||||
| 			'User' => array( | ||||
| 				'user' => 'mariano', | ||||
| 				'password' => '' | ||||
| 		)); | ||||
| 
 | ||||
| 		$this->auth = $this->getMock( | ||||
| 			'FormAuthenticate', | ||||
| 			array('_checkFields'), | ||||
| 			array( | ||||
| 				$this->Collection, | ||||
| 				array( | ||||
| 					'fields' => array('username' => 'user', 'password' => 'password'), | ||||
| 					'userModel' => 'User' | ||||
| 				) | ||||
| 			) | ||||
| 		); | ||||
| 
 | ||||
| 		// Simulate that check for ensuring password is not empty is missing.
 | ||||
| 		$this->auth->expects($this->once()) | ||||
| 			->method('_checkFields') | ||||
| 			->will($this->returnValue(true)); | ||||
| 
 | ||||
| 		$this->assertFalse($this->auth->authenticate($request, $this->response)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test authenticate field is not string | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAuthenticateFieldsAreNotString() { | ||||
| 		$request = new CakeRequest('posts/index', false); | ||||
| 		$request->data = array( | ||||
| 			'User' => array( | ||||
| 				'user' => array('mariano', 'phpnut'), | ||||
| 				'password' => 'my password' | ||||
| 		)); | ||||
| 		$this->assertFalse($this->auth->authenticate($request, $this->response)); | ||||
| 
 | ||||
| 		$request->data = array( | ||||
| 			'User' => array( | ||||
| 				'user' => array(), | ||||
| 				'password' => 'my password' | ||||
| 		)); | ||||
| 		$this->assertFalse($this->auth->authenticate($request, $this->response)); | ||||
| 
 | ||||
| 		$request->data = array( | ||||
| 			'User' => array( | ||||
| 				'user' => 'mariano', | ||||
| 				'password' => array('password1', 'password2') | ||||
| 		)); | ||||
| 		$this->assertFalse($this->auth->authenticate($request, $this->response)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test the authenticate method | ||||
|  * | ||||
|  | @ -151,6 +231,30 @@ class FormAuthenticateTest extends CakeTestCase { | |||
| 		$this->assertFalse($this->auth->authenticate($request, $this->response)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that username of 0 works. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAuthenticateUsernameZero() { | ||||
| 		$User = ClassRegistry::init('User'); | ||||
| 		$User->updateAll(array('user' => $User->getDataSource()->value('0')), array('user' => 'mariano')); | ||||
| 
 | ||||
| 		$request = new CakeRequest('posts/index', false); | ||||
| 		$request->data = array('User' => array( | ||||
| 			'user' => '0', | ||||
| 			'password' => 'password' | ||||
| 		)); | ||||
| 
 | ||||
| 		$expected = array( | ||||
| 			'id' => 1, | ||||
| 			'user' => '0', | ||||
| 			'created' => '2007-03-17 01:16:23', | ||||
| 			'updated' => '2007-03-17 01:18:31' | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $this->auth->authenticate($request, $this->response)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test a model in a plugin. | ||||
|  * | ||||
|  | @ -184,10 +288,58 @@ class FormAuthenticateTest extends CakeTestCase { | |||
| 			'username' => 'gwoo', | ||||
| 			'created' => '2007-03-17 01:16:23' | ||||
| 		); | ||||
| 		$this->assertEquals(self::date(), $result['updated']); | ||||
| 		$this->assertEquals(static::date(), $result['updated']); | ||||
| 		unset($result['updated']); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 		CakePlugin::unload(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test password hasher settings | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testPasswordHasherSettings() { | ||||
| 		$this->auth->settings['passwordHasher'] = array( | ||||
| 			'className' => 'Simple', | ||||
| 			'hashType' => 'md5' | ||||
| 		); | ||||
| 
 | ||||
| 		$passwordHasher = $this->auth->passwordHasher(); | ||||
| 		$result = $passwordHasher->config(); | ||||
| 		$this->assertEquals('md5', $result['hashType']); | ||||
| 
 | ||||
| 		$hash = Security::hash('mypass', 'md5', true); | ||||
| 		$User = ClassRegistry::init('User'); | ||||
| 		$User->updateAll( | ||||
| 			array('password' => $User->getDataSource()->value($hash)), | ||||
| 			array('User.user' => 'mariano') | ||||
| 		); | ||||
| 
 | ||||
| 		$request = new CakeRequest('posts/index', false); | ||||
| 		$request->data = array('User' => array( | ||||
| 			'user' => 'mariano', | ||||
| 			'password' => 'mypass' | ||||
| 		)); | ||||
| 
 | ||||
| 		$result = $this->auth->authenticate($request, $this->response); | ||||
| 		$expected = array( | ||||
| 			'id' => 1, | ||||
| 			'user' => 'mariano', | ||||
| 			'created' => '2007-03-17 01:16:23', | ||||
| 			'updated' => '2007-03-17 01:18:31' | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$this->auth = new FormAuthenticate($this->Collection, array( | ||||
| 			'fields' => array('username' => 'user', 'password' => 'password'), | ||||
| 			'userModel' => 'User' | ||||
| 		)); | ||||
| 		$this->auth->settings['passwordHasher'] = array( | ||||
| 			'className' => 'Simple', | ||||
| 			'hashType' => 'sha1' | ||||
| 		); | ||||
| 		$this->assertFalse($this->auth->authenticate($request, $this->response)); | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko