[Security] validate empty passwords again
This commit is contained in:
parent
62fdf9c72b
commit
878198cefa
@ -90,6 +90,29 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
->assertRaised();
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider emptyPasswordData
|
||||||
|
*/
|
||||||
|
public function testEmptyPasswordsAreNotValid($password)
|
||||||
|
{
|
||||||
|
$constraint = new UserPassword(array(
|
||||||
|
'message' => 'myMessage',
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->validator->validate($password, $constraint);
|
||||||
|
|
||||||
|
$this->buildViolation('myMessage')
|
||||||
|
->assertRaised();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function emptyPasswordData()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array(null),
|
||||||
|
array(''),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||||
*/
|
*/
|
||||||
|
@ -40,6 +40,8 @@ class UserPasswordValidator extends ConstraintValidator
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null === $password || '' === $password) {
|
if (null === $password || '' === $password) {
|
||||||
|
$this->context->addViolation($constraint->message);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user