mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
Add a test (only handle bcrypt and legacy sha256 as we have to maintain PHP 7.1 compatibility)
This commit is contained in:
committed by
Stephen Abello
parent
dc804a90d4
commit
5762ac38a7
57
test/core/ormPasswordTest.php
Normal file
57
test/core/ormPasswordTest.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/*!
|
||||
* @copyright Copyright (C) 2010-2020 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Core;
|
||||
|
||||
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
use Utils;
|
||||
use ormPassword;
|
||||
|
||||
/**
|
||||
* Tests of the ormPassword class
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class ormPasswordTest extends ItopDataTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $sToHashValues
|
||||
* @param $sToHashSalt
|
||||
* @param $sHashAlgo
|
||||
* @param $sExpectedHash
|
||||
*
|
||||
* @throws \ConfigException
|
||||
* @throws \CoreException
|
||||
* @dataProvider HashProvider
|
||||
*/
|
||||
public function testCheckHash($sToHashValues, $sToHashSalt, $sHashAlgo, $sExpectedHash)
|
||||
{
|
||||
utils::GetConfig()->SetPasswordHashAlgo($sHashAlgo);
|
||||
$oPassword1 = new ormPassword($sExpectedHash, $sToHashSalt);
|
||||
static::assertTrue($oPassword1->CheckPassword($sToHashValues));
|
||||
}
|
||||
|
||||
public function HashProvider()
|
||||
{
|
||||
return array(
|
||||
'Bcrypt' => array(
|
||||
'admin',
|
||||
'',
|
||||
PASSWORD_BCRYPT,
|
||||
'$2y$10$P6yqXv/0pT4e9kfN6d95jOKX4KR5Il.N0vRLc2DoZoycwnU9mcnia'
|
||||
),
|
||||
'sha256 (legacy)' => array(
|
||||
'admin',
|
||||
'salt',
|
||||
'sha256',
|
||||
'2bb7998496899acdd8137fad3a44faf96a84a03d7f230ce42e97cd17c7ae429e'
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user