1
0
Fork 0
mirror of synced 2024-07-11 01:16:01 +12:00
appwrite/tests/unit/Auth/Validator/PasswordDictionaryTest.php
2024-03-06 18:34:21 +01:00

39 lines
1 KiB
PHP

<?php
namespace Tests\Unit\Auth\Validator;
use Appwrite\Auth\Validator\PasswordDictionary;
use PHPUnit\Framework\TestCase;
class PasswordDictionaryTest extends TestCase
{
protected ?PasswordDictionary $object = null;
public function setUp(): void
{
$this->object = new PasswordDictionary(
['password' => true, '123456' => true],
true
);
}
public function testValues(): void
{
$this->assertEquals($this->object->isValid('1'), false); // to check parent is being called
$this->assertEquals($this->object->isValid('123456'), false);
$this->assertEquals($this->object->isValid('password'), false);
$this->assertEquals($this->object->isValid('myPasswordIsRight'), true);
$pass = ''; // 256 chars
for ($i = 0; $i < 256; $i++) {
$pass .= 'p';
}
$this->assertEquals($this->object->isValid($pass), true);
$pass .= 'p'; // 257 chars
$this->assertEquals($this->object->isValid($pass), false);
}
}