mirror of
https://github.com/nextcloud/server.git
synced 2026-02-19 02:38:40 -05:00
test: Test hash validation
Signed-off-by: Christopher Ng <chrng8@gmail.com>
This commit is contained in:
parent
415edcac9b
commit
48b69c53dc
1 changed files with 25 additions and 0 deletions
|
|
@ -264,4 +264,29 @@ class HasherTest extends \Test\TestCase {
|
|||
$info = password_get_info($relativePath['hash']);
|
||||
$this->assertEquals(PASSWORD_BCRYPT, $info['algo']);
|
||||
}
|
||||
|
||||
public function testValidHash() {
|
||||
$hash = '3|$argon2id$v=19$m=65536,t=4,p=1$czFCSjk3LklVdXppZ2VCWA$li0NgdXe2/jwSRxgteGQPWlzJU0E0xdtfHbCbrpych0';
|
||||
|
||||
$isValid = $this->hasher->validate($hash);
|
||||
|
||||
$this->assertTrue($isValid);
|
||||
}
|
||||
|
||||
public function testValidGeneratedHash() {
|
||||
$message = 'secret';
|
||||
$hash = $this->hasher->hash($message);
|
||||
|
||||
$isValid = $this->hasher->validate($hash);
|
||||
|
||||
$this->assertTrue($isValid);
|
||||
}
|
||||
|
||||
public function testInvalidHash() {
|
||||
$invalidHash = 'someInvalidHash';
|
||||
|
||||
$isValid = $this->hasher->validate($invalidHash);
|
||||
|
||||
$this->assertFalse($isValid);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue