Files
FOSSBilling/tests-legacy/library/Box/Box_PasswordTest.php
T
Belle Aerni ccc97a3ec9 Initial implementation of CI against a live FOSSBilling Install (#2067)
* Rename tests to tests-legacy

* Groundwork for live tests

* Somewhat working tests on a live instance

* Hmmmmmm

* Fix

* Fixed the other bug

* Added a handful of various tests

* Typos, all these are admin endpoints

* Bypass this check for testing envs

* Disable it for now

* Mini cleanup

* Cleanup from debugging, ran PHP-CS-Fixer
2024-01-14 22:51:32 -08:00

58 lines
1.6 KiB
PHP

<?php
class Box_PasswordTest extends PHPUnit\Framework\TestCase
{
public function testsetAlgo()
{
$boxPassword = new Box_Password();
$algo = PASSWORD_BCRYPT;
$boxPassword->setAlgo($algo);
$result = $boxPassword->getAlgo();
$this->assertEquals($algo, $result);
}
public function testSetOptions()
{
$boxPassword = new Box_Password();
$options = [
'cost' => 12,
];
$boxPassword->setOptions($options);
$result = $boxPassword->getOptions();
$this->assertEquals($options, $result);
}
public function testHashing()
{
$boxPassword = new Box_Password();
$password = '123456';
$hash = $boxPassword->hashIt($password);
$this->assertIsString($hash);
$this->assertNotEmpty($hash);
$veryfied = $boxPassword->verify($password, $hash);
$this->assertIsBool($veryfied);
$this->assertTrue($veryfied);
$needRehashing = $boxPassword->needsRehash($hash);
$this->assertIsBool($needRehashing);
$this->assertFalse($needRehashing);
}
public function testNeedsRehashing()
{
$boxPassword = new Box_Password();
$password = '123456';
$hash = $boxPassword->hashIt($password);
$this->assertIsString($hash);
$this->assertNotEmpty($hash);
$newOptions = ['cost' => 15];
$boxPassword->setOptions($newOptions);
$needRehashing = $boxPassword->needsRehash($hash);
$this->assertIsBool($needRehashing);
$this->assertTrue($needRehashing);
}
}