Navigation Menu

Skip to content

Commit

Permalink
Rename SimplePasswordHasher to DefaultPasswordHasher.
Browse files Browse the repository at this point in the history
This avoids confusion with SimplePasswordHasher class of 2.x which doesn't use
the same hashing scheme.
  • Loading branch information
ADmad committed Jun 25, 2014
1 parent a4e6385 commit e527254
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/Auth/BaseAuthenticate.php
Expand Up @@ -38,7 +38,7 @@ abstract class BaseAuthenticate {
* - `contain` Extra models to contain and store in session.
* - `passwordHasher` Password hasher class. Can be a string specifying class name
* or an array containing `className` key, any other keys will be passed as
* config to the class. Defaults to 'Simple'.
* config to the class. Defaults to 'Default'.
*
* @var array
*/
Expand All @@ -50,7 +50,7 @@ abstract class BaseAuthenticate {
'userModel' => 'Users',
'scope' => [],
'contain' => null,
'passwordHasher' => 'Simple'
'passwordHasher' => 'Default'
];

/**
Expand Down
Expand Up @@ -17,10 +17,10 @@
use Cake\Auth\AbstractPasswordHasher;

/**
* Simple password hashing class.
* Default password hashing class.
*
*/
class SimplePasswordHasher extends AbstractPasswordHasher {
class DefaultPasswordHasher extends AbstractPasswordHasher {

/**
* Default config for this object.
Expand Down
Expand Up @@ -14,23 +14,23 @@
*/
namespace Cake\Test\TestCase\Auth;

use Cake\Auth\SimplePasswordHasher;
use Cake\Auth\DefaultPasswordHasher;
use Cake\TestSuite\TestCase;

/**
* Test case for SimplePasswordHasher
* Test case for DefaultPasswordHasher
*
*/
class SimplePasswordHasherTest extends TestCase {
class DefaultPasswordHasherTest extends TestCase {

/**
* Tests that a password not produced by SimplePasswordHasher needs
* Tests that a password not produced by DefaultPasswordHasher needs
* to be rehashed
*
* @return void
*/
public function testNeedsRehash() {
$hasher = new SimplePasswordHasher();
$hasher = new DefaultPasswordHasher();
$this->assertTrue($hasher->needsRehash(md5('foo')));
$password = $hasher->hash('foo');
$this->assertFalse($hasher->needsRehash($password));
Expand Down
16 changes: 8 additions & 8 deletions tests/TestCase/Auth/FallbackPasswordHasherTest.php
Expand Up @@ -14,8 +14,8 @@
*/
namespace Cake\Test\TestCase\Auth;

use Cake\Auth\DefaultPasswordHasher;
use Cake\Auth\FallbackPasswordHasher;
use Cake\Auth\SimplePasswordHasher;
use Cake\Auth\WeakPasswordHasher;
use Cake\TestSuite\TestCase;

Expand All @@ -31,12 +31,12 @@ class FallbackPasswordHasherTest extends TestCase {
* @return void
*/
public function testHash() {
$hasher = new FallbackPasswordHasher(['hashers' => ['Weak', 'Simple']]);
$hasher = new FallbackPasswordHasher(['hashers' => ['Weak', 'Default']]);
$weak = new WeakPasswordHasher();
$this->assertSame($weak->hash('foo'), $hasher->hash('foo'));

$simple = new SimplePasswordHasher();
$hasher = new FallbackPasswordHasher(['hashers' => ['Weak', 'Simple']]);
$simple = new DefaultPasswordHasher();
$hasher = new FallbackPasswordHasher(['hashers' => ['Weak', 'Default']]);
$this->assertSame($weak->hash('foo'), $hasher->hash('foo'));
}

Expand All @@ -47,9 +47,9 @@ public function testHash() {
* @return void
*/
public function testCheck() {
$hasher = new FallbackPasswordHasher(['hashers' => ['Weak', 'Simple']]);
$hasher = new FallbackPasswordHasher(['hashers' => ['Weak', 'Default']]);
$weak = new WeakPasswordHasher();
$simple = new SimplePasswordHasher();
$simple = new DefaultPasswordHasher();

$hash = $simple->hash('foo');
$otherHash = $weak->hash('foo');
Expand All @@ -63,12 +63,12 @@ public function testCheck() {
* @return void
*/
public function testNeedsRehash() {
$hasher = new FallbackPasswordHasher(['hashers' => ['Simple', 'Weak']]);
$hasher = new FallbackPasswordHasher(['hashers' => ['Default', 'Weak']]);
$weak = new WeakPasswordHasher();
$otherHash = $weak->hash('foo');
$this->assertTrue($hasher->needsRehash($otherHash));

$simple = new SimplePasswordHasher();
$simple = new DefaultPasswordHasher();
$hash = $simple->hash('foo');
$this->assertFalse($hasher->needsRehash($hash));
}
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Auth/FormAuthenticateTest.php
Expand Up @@ -263,7 +263,7 @@ public function testPluginModel() {
*/
public function testPasswordHasherSettings() {
$this->auth->config('passwordHasher', [
'className' => 'Simple',
'className' => 'Default',
'hashType' => PASSWORD_BCRYPT
]);

Expand Down Expand Up @@ -298,7 +298,7 @@ public function testPasswordHasherSettings() {
'userModel' => 'Users'
]);
$this->auth->config('passwordHasher', [
'className' => 'Simple'
'className' => 'Default'
]);
$this->assertEquals($expected, $this->auth->authenticate($request, $this->response));

Expand Down Expand Up @@ -326,7 +326,7 @@ public function testAuthenticateNoRehash() {
}

/**
* Tests that not using the Simple password hasher means that the password
* Tests that not using the Default password hasher means that the password
* needs to be rehashed
*
* @return void
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Controller/Component/AuthComponentTest.php
Expand Up @@ -364,7 +364,7 @@ public function testAllConfigWithAuthenticate() {
*/
public function testSameAuthenticateWithDifferentHashers() {
$this->Controller->Auth->config('authenticate', [
'FormSimple' => ['className' => 'Form', 'passwordHasher' => 'Simple'],
'FormSimple' => ['className' => 'Form', 'passwordHasher' => 'Default'],
'FormBlowfish' => ['className' => 'Form', 'passwordHasher' => 'Fallback'],
]);

Expand All @@ -374,7 +374,7 @@ public function testSameAuthenticateWithDifferentHashers() {
$this->assertInstanceOf('Cake\Auth\FormAuthenticate', $objects[0]);
$this->assertInstanceOf('Cake\Auth\FormAuthenticate', $objects[1]);

$this->assertInstanceOf('Cake\Auth\SimplePasswordHasher', $objects[0]->passwordHasher());
$this->assertInstanceOf('Cake\Auth\DefaultPasswordHasher', $objects[0]->passwordHasher());
$this->assertInstanceOf('Cake\Auth\FallbackPasswordHasher', $objects[1]->passwordHasher());
}

Expand Down

0 comments on commit e527254

Please sign in to comment.