mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-18 15:39:53 +00:00
Merge pull request #3387 from php-engineer/master-security-test
Correct parameter order
This commit is contained in:
commit
5eff011711
1 changed files with 18 additions and 18 deletions
|
@ -114,10 +114,10 @@ class SecurityTest extends CakeTestCase {
|
||||||
$key = 'someKey';
|
$key = 'someKey';
|
||||||
$hash = 'someHash';
|
$hash = 'someHash';
|
||||||
|
|
||||||
$this->assertSame(strlen(Security::hash($key, null, false)), 40);
|
$this->assertSame(40, strlen(Security::hash($key, null, false)));
|
||||||
$this->assertSame(strlen(Security::hash($key, 'sha1', false)), 40);
|
$this->assertSame(40, strlen(Security::hash($key, 'sha1', false)));
|
||||||
$this->assertSame(strlen(Security::hash($key, null, true)), 40);
|
$this->assertSame(40, strlen(Security::hash($key, null, true)));
|
||||||
$this->assertSame(strlen(Security::hash($key, 'sha1', true)), 40);
|
$this->assertSame(40, strlen(Security::hash($key, 'sha1', true)));
|
||||||
|
|
||||||
$result = Security::hash($key, null, $hash);
|
$result = Security::hash($key, null, $hash);
|
||||||
$this->assertSame($result, 'e38fcb877dccb6a94729a81523851c931a46efb1');
|
$this->assertSame($result, 'e38fcb877dccb6a94729a81523851c931a46efb1');
|
||||||
|
@ -127,25 +127,25 @@ class SecurityTest extends CakeTestCase {
|
||||||
|
|
||||||
$hashType = 'sha1';
|
$hashType = 'sha1';
|
||||||
Security::setHash($hashType);
|
Security::setHash($hashType);
|
||||||
$this->assertSame(Security::$hashType, $hashType);
|
$this->assertSame($hashType, Security::$hashType);
|
||||||
$this->assertSame(strlen(Security::hash($key, null, true)), 40);
|
$this->assertSame(40, strlen(Security::hash($key, null, true)));
|
||||||
$this->assertSame(strlen(Security::hash($key, null, false)), 40);
|
$this->assertSame(40, strlen(Security::hash($key, null, false)));
|
||||||
|
|
||||||
$this->assertSame(strlen(Security::hash($key, 'md5', false)), 32);
|
$this->assertSame(32, strlen(Security::hash($key, 'md5', false)));
|
||||||
$this->assertSame(strlen(Security::hash($key, 'md5', true)), 32);
|
$this->assertSame(32, strlen(Security::hash($key, 'md5', true)));
|
||||||
|
|
||||||
$hashType = 'md5';
|
$hashType = 'md5';
|
||||||
Security::setHash($hashType);
|
Security::setHash($hashType);
|
||||||
$this->assertSame(Security::$hashType, $hashType);
|
$this->assertSame($hashType, Security::$hashType);
|
||||||
$this->assertSame(strlen(Security::hash($key, null, false)), 32);
|
$this->assertSame(32, strlen(Security::hash($key, null, false)));
|
||||||
$this->assertSame(strlen(Security::hash($key, null, true)), 32);
|
$this->assertSame(32, strlen(Security::hash($key, null, true)));
|
||||||
|
|
||||||
if (!function_exists('hash') && !function_exists('mhash')) {
|
if (!function_exists('hash') && !function_exists('mhash')) {
|
||||||
$this->assertSame(strlen(Security::hash($key, 'sha256', false)), 32);
|
$this->assertSame(32, strlen(Security::hash($key, 'sha256', false)));
|
||||||
$this->assertSame(strlen(Security::hash($key, 'sha256', true)), 32);
|
$this->assertSame(32, strlen(Security::hash($key, 'sha256', true)));
|
||||||
} else {
|
} else {
|
||||||
$this->assertSame(strlen(Security::hash($key, 'sha256', false)), 64);
|
$this->assertSame(64, strlen(Security::hash($key, 'sha256', false)));
|
||||||
$this->assertSame(strlen(Security::hash($key, 'sha256', true)), 64);
|
$this->assertSame(64, strlen(Security::hash($key, 'sha256', true)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Security::setHash($_hashType);
|
Security::setHash($_hashType);
|
||||||
|
@ -167,8 +167,8 @@ class SecurityTest extends CakeTestCase {
|
||||||
$hashType = 'blowfish';
|
$hashType = 'blowfish';
|
||||||
Security::setHash($hashType);
|
Security::setHash($hashType);
|
||||||
|
|
||||||
$this->assertSame(Security::$hashType, $hashType);
|
$this->assertSame($hashType, Security::$hashType);
|
||||||
$this->assertSame(strlen(Security::hash($key, null, false)), 60);
|
$this->assertSame(60, strlen(Security::hash($key, null, false)));
|
||||||
|
|
||||||
$password = $submittedPassword = $key;
|
$password = $submittedPassword = $key;
|
||||||
$storedPassword = Security::hash($password);
|
$storedPassword = Security::hash($password);
|
||||||
|
|
Loading…
Add table
Reference in a new issue