Add support for Argon2 password hashing
[lhc/web/wiklou.git] / tests / phpunit / includes / password / EncryptedPasswordTest.php
index 7ed9711..7384310 100644 (file)
@@ -9,7 +9,7 @@ class EncryptedPasswordTest extends PasswordTestCase {
        protected function getTypeConfigs() {
                return [
                        'both' => [
-                               'class' => 'EncryptedPassword',
+                               'class' => EncryptedPassword::class,
                                'underlying' => 'pbkdf2',
                                'secrets' => [
                                        md5( 'secret1' ),
@@ -18,7 +18,7 @@ class EncryptedPasswordTest extends PasswordTestCase {
                                'cipher' => 'aes-256-cbc',
                        ],
                        'secret1' => [
-                               'class' => 'EncryptedPassword',
+                               'class' => EncryptedPassword::class,
                                'underlying' => 'pbkdf2',
                                'secrets' => [
                                        md5( 'secret1' ),
@@ -26,7 +26,7 @@ class EncryptedPasswordTest extends PasswordTestCase {
                                'cipher' => 'aes-256-cbc',
                        ],
                        'secret2' => [
-                               'class' => 'EncryptedPassword',
+                               'class' => EncryptedPassword::class,
                                'underlying' => 'pbkdf2',
                                'secrets' => [
                                        md5( 'secret2' ),
@@ -34,7 +34,7 @@ class EncryptedPasswordTest extends PasswordTestCase {
                                'cipher' => 'aes-256-cbc',
                        ],
                        'pbkdf2' => [
-                               'class' => 'Pbkdf2Password',
+                               'class' => Pbkdf2Password::class,
                                'algo' => 'sha256',
                                'cost' => '10',
                                'length' => '64',
@@ -72,13 +72,13 @@ class EncryptedPasswordTest extends PasswordTestCase {
                // phpcs:ignore Generic.Files.LineLength
                $hash = ':both:aes-256-cbc:0:izBpxujqC1YbzpCB3qAzgg==:ZqHnitT1pL4YJqKqFES2KEevZYSy2LtlibW5+IMi4XKOGKGy6sE638BXyBbLQQsBtTSrt+JyzwOayKtwIfRbaQsBridx/O1JwBSai1TkGkOsYMBXnlu2Bu/EquCBj5QpjYh7p3Uq4rpiop1KQlin1BJMwnAa1PovhxjpxnYhlhkM4X5ALoGi3XM0bapN48vt';
                $fromHash = $this->passwordFactory->newFromCiphertext( $hash );
-               $fromPlaintext = $this->passwordFactory->newFromPlaintext( 'password', $fromHash );
                $this->assertTrue( $fromHash->update() );
 
                $serialized = $fromHash->toString();
                $this->assertRegExp( '/^:both:aes-256-cbc:1:/', $serialized );
                $fromNewHash = $this->passwordFactory->newFromCiphertext( $serialized );
                $fromPlaintext = $this->passwordFactory->newFromPlaintext( 'password', $fromNewHash );
-               $this->assertTrue( $fromHash->equals( $fromPlaintext ) );
+               $this->assertTrue( $fromPlaintext->verify( 'password' ) );
+               $this->assertTrue( $fromHash->verify( 'password' ) );
        }
 }