mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Add tests for #3624
The username of '0' should be accepted by FormAuthenticate. Refs #3624
This commit is contained in:
parent
88b3629f4f
commit
d1e4dfac47
2 changed files with 32 additions and 5 deletions
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
|
@ -51,7 +49,7 @@ class FormAuthenticate extends BaseAuthenticate {
|
|||
}
|
||||
foreach (array($fields['username'], $fields['password']) as $field) {
|
||||
$value = $request->data($model . '.' . $field);
|
||||
if (empty($value) && $value !== "0" || !is_string($value)) {
|
||||
if (empty($value) && $value !== '0' || !is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
/**
|
||||
* FormAuthenticateTest file
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
|
@ -166,6 +164,13 @@ class FormAuthenticateTest extends CakeTestCase {
|
|||
));
|
||||
$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',
|
||||
|
@ -226,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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue