From: Brad Jorsch Date: Fri, 16 Aug 2019 18:44:29 +0000 (-0400) Subject: Handle changed defaults in Argon2PasswordTest::testPartialConfig() X-Git-Tag: 1.34.0-rc.0~694^2 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=8698bc3b42215934651c3e81fdd3fb9e37586836;p=lhc%2Fweb%2Fwiklou.git Handle changed defaults in Argon2PasswordTest::testPartialConfig() PHP 7.2.21 and 7.3.8 changed the default settings for PASSWORD_ARGON2I. Load the default settings at runtime so the test can work. Bug: T230487 Change-Id: I55a0f1af160c822113c9f86f8f8cce558da61736 --- diff --git a/tests/phpunit/includes/password/Argon2PasswordTest.php b/tests/phpunit/includes/password/Argon2PasswordTest.php index b518040e87..6de56173a6 100644 --- a/tests/phpunit/includes/password/Argon2PasswordTest.php +++ b/tests/phpunit/includes/password/Argon2PasswordTest.php @@ -88,6 +88,10 @@ class Argon2PasswordTest extends PasswordTestCase { } public function testPartialConfig() { + // The default options changed in PHP 7.2.21 and 7.3.8. This seems to be the only way to + // fetch them at runtime. + $options = password_get_info( password_hash( '', PASSWORD_ARGON2I ) )['options']; + $factory = new PasswordFactory(); $factory->register( 'argon2', [ 'class' => Argon2Password::class, @@ -96,7 +100,14 @@ class Argon2PasswordTest extends PasswordTestCase { $partialPassword = $factory->newFromType( 'argon2' ); $partialPassword->crypt( 'password' ); - $fullPassword = $this->passwordFactory->newFromCiphertext( $partialPassword->toString() ); + + $factory2 = new PasswordFactory(); + $factory2->register( 'argon2', [ + 'class' => Argon2Password::class, + 'algo' => 'argon2i', + ] + $options ); + + $fullPassword = $factory2->newFromCiphertext( $partialPassword->toString() ); $this->assertFalse( $fullPassword->needsUpdate(), 'Options not set for a password should fall back to defaults'