Skip to content

Commit

Permalink
test: Test hash validation
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <[email protected]>
  • Loading branch information
Pytal committed Jul 5, 2024
1 parent 415edca commit 48b69c5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/lib/Security/HasherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,29 @@ public function testHashUsePasswordDefault() {
$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);
}
}

0 comments on commit 48b69c5

Please sign in to comment.