aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2024-07-04 16:57:09 -0700
committerChristopher Ng <chrng8@gmail.com>2024-07-04 17:05:50 -0700
commit48b69c53dca7d1c7889deea9e82ca25decadb39e (patch)
treed2fae6976d11c98a92dfc07ff32e2004cfa46e21 /tests
parent415edcac9b48983b2266576080bdf4c2fd23482a (diff)
downloadnextcloud-server-48b69c53dca7d1c7889deea9e82ca25decadb39e.tar.gz
nextcloud-server-48b69c53dca7d1c7889deea9e82ca25decadb39e.zip
test: Test hash validation
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Security/HasherTest.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/lib/Security/HasherTest.php b/tests/lib/Security/HasherTest.php
index 0eb233de485..f51b4ee39db 100644
--- a/tests/lib/Security/HasherTest.php
+++ b/tests/lib/Security/HasherTest.php
@@ -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);
+ }
}