NotCompromisedPassword example

        'FC9F37E51AACD6B692A62769267590D46B8:0', // ISO-8859-5 non leaked password: м<в0dp3r4\45b28Hy     ];

    protected function createValidator(): ConstraintValidatorInterface
    {
        // Pass HttpClient::create() instead of the mock to run the tests against the real API         return new NotCompromisedPasswordValidator($this->createHttpClientStub());
    }

    public function testNullIsValid()
    {
        $this->validator->validate(null, new NotCompromisedPassword());

        $this->assertNoViolation();
    }

    public function testEmptyStringIsValid()
    {
        $this->validator->validate('', new NotCompromisedPassword());

        $this->assertNoViolation();
    }

    
use Symfony\Component\Validator\Constraints\NotCompromisedPassword;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Mapping\Loader\AttributeLoader;

/** * @author Kévin Dunglas <dunglas@gmail.com> */
class NotCompromisedPasswordTest extends TestCase
{
    public function testDefaultValues()
    {
        $constraint = new NotCompromisedPassword();
        $this->assertSame(1, $constraint->threshold);
        $this->assertFalse($constraint->skipOnError);
    }

    public function testAttributes()
    {
        $metadata = new ClassMetadata(NotCompromisedPasswordDummy::class);
        $loader = new AttributeLoader();
        self::assertTrue($loader->loadClassMetadata($metadata));

        [$aConstraint] = $metadata->properties['a']->getConstraints();
        
Home | Imprint | This part of the site doesn't use cookies.