Skip to content

Commit

Permalink
[Security] validate empty passwords again
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Jul 14, 2017
1 parent 62fdf9c commit 878198c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Expand Up @@ -90,6 +90,29 @@ public function testPasswordIsNotValid()
->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
*/
Expand Down
Expand Up @@ -40,6 +40,8 @@ public function validate($password, Constraint $constraint)
}

if (null === $password || '' === $password) {
$this->context->addViolation($constraint->message);

return;
}

Expand Down

0 comments on commit 878198c

Please sign in to comment.