From 3429f979aae403247e224eee886b304a4a025345 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 24 Apr 2023 09:06:38 +0200 Subject: [PATCH] [Validator] Update the name of a password strength level --- .../Component/Validator/Constraints/PasswordStrength.php | 4 ++-- .../Validator/Constraints/PasswordStrengthValidator.php | 2 +- .../Tests/Constraints/PasswordStrengthValidatorTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/PasswordStrength.php b/src/Symfony/Component/Validator/Constraints/PasswordStrength.php index eef98ef337a36..b41965879f5eb 100644 --- a/src/Symfony/Component/Validator/Constraints/PasswordStrength.php +++ b/src/Symfony/Component/Validator/Constraints/PasswordStrength.php @@ -26,7 +26,7 @@ final class PasswordStrength extends Constraint { public const STRENGTH_VERY_WEAK = 0; public const STRENGTH_WEAK = 1; - public const STRENGTH_REASONABLE = 2; + public const STRENGTH_MEDIUM = 2; public const STRENGTH_STRONG = 3; public const STRENGTH_VERY_STRONG = 4; @@ -42,7 +42,7 @@ final class PasswordStrength extends Constraint public function __construct(array $options = null, int $minScore = null, array $groups = null, mixed $payload = null) { - $options['minScore'] ??= self::STRENGTH_REASONABLE; + $options['minScore'] ??= self::STRENGTH_MEDIUM; parent::__construct($options, $groups, $payload); diff --git a/src/Symfony/Component/Validator/Constraints/PasswordStrengthValidator.php b/src/Symfony/Component/Validator/Constraints/PasswordStrengthValidator.php index e4799645b8ec2..c3d2b7d76a2bc 100644 --- a/src/Symfony/Component/Validator/Constraints/PasswordStrengthValidator.php +++ b/src/Symfony/Component/Validator/Constraints/PasswordStrengthValidator.php @@ -82,7 +82,7 @@ private static function estimateStrength(#[\SensitiveParameter] string $password return match (true) { $entropy >= 120 => PasswordStrength::STRENGTH_VERY_STRONG, $entropy >= 100 => PasswordStrength::STRENGTH_STRONG, - $entropy >= 80 => PasswordStrength::STRENGTH_REASONABLE, + $entropy >= 80 => PasswordStrength::STRENGTH_MEDIUM, $entropy >= 60 => PasswordStrength::STRENGTH_WEAK, default => PasswordStrength::STRENGTH_VERY_WEAK, }; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/PasswordStrengthValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/PasswordStrengthValidatorTest.php index f4f5816e249a1..474dd889c3686 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/PasswordStrengthValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/PasswordStrengthValidatorTest.php @@ -45,7 +45,7 @@ public function testValidValues(string $value, int $expectedStrength) public static function getValidValues(): iterable { yield ['How-is-this', PasswordStrength::STRENGTH_WEAK]; - yield ['Reasonable-pwd', PasswordStrength::STRENGTH_REASONABLE]; + yield ['Reasonable-pwd', PasswordStrength::STRENGTH_MEDIUM]; yield ['This 1s a very g00d Pa55word! ;-)', PasswordStrength::STRENGTH_VERY_STRONG]; yield ['pudding-smack-👌🏼-fox-😎', PasswordStrength::STRENGTH_VERY_STRONG]; }