api/symfony/Component/Validator/Tests/Constraints/NotCompromisedPasswordValidatorTest.yaml

144 lines
6.2 KiB
YAML
Raw Normal View History

2024-09-26 09:03:21 +00:00
name: NotCompromisedPasswordValidatorTest
class_comment: "# * @author K\xE9vin Dunglas <dunglas@gmail.com>"
dependencies:
- name: Luhn
type: class
source: Symfony\Component\Validator\Constraints\Luhn
- name: NotCompromisedPassword
type: class
source: Symfony\Component\Validator\Constraints\NotCompromisedPassword
- name: NotCompromisedPasswordValidator
type: class
source: Symfony\Component\Validator\Constraints\NotCompromisedPasswordValidator
- name: ConstraintValidatorInterface
type: class
source: Symfony\Component\Validator\ConstraintValidatorInterface
- name: UnexpectedTypeException
type: class
source: Symfony\Component\Validator\Exception\UnexpectedTypeException
- name: ConstraintValidatorTestCase
type: class
source: Symfony\Component\Validator\Test\ConstraintValidatorTestCase
- name: ExceptionInterface
type: class
source: Symfony\Contracts\HttpClient\Exception\ExceptionInterface
- name: ServerExceptionInterface
type: class
source: Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface
- name: HttpClientInterface
type: class
source: Symfony\Contracts\HttpClient\HttpClientInterface
- name: ResponseInterface
type: class
source: Symfony\Contracts\HttpClient\ResponseInterface
properties: []
methods:
- name: testThresholdNotReached
visibility: public
parameters:
- name: constraint
comment: "# * @author K\xE9vin Dunglas <dunglas@gmail.com>\n# */\n# class NotCompromisedPasswordValidatorTest\
\ extends ConstraintValidatorTestCase\n# {\n# private const PASSWORD_TRIGGERING_AN_ERROR\
\ = 'apiError';\n# private const PASSWORD_TRIGGERING_AN_ERROR_RANGE_URL = 'https://api.pwnedpasswords.com/range/3EF27';\
\ // https://api.pwnedpasswords.com/range/3EF27 is the range for the value \"\
apiError\"\n# private const PASSWORD_LEAKED = 'maman';\n# private const PASSWORD_NOT_LEAKED\
\ = ']<0585\"%sb^5aa$w6!b38\",,72?dp3r4\\45b28Hy';\n# private const PASSWORD_NON_UTF8_LEAKED\
\ = '\u043C\u0430\u043C\u0430';\n# private const PASSWORD_NON_UTF8_NOT_LEAKED\
\ = '\u043C<\u04320dp3r4\\45b28Hy';\n# \n# private const RETURN = [\n# '35E033023A46402F94CFB4F654C5BFE44A1:1',\n\
# '35F079CECCC31812288257CD770AA7968D7:53',\n# '36039744C253F9B2A4E90CBEDB02EBFB82D:5',\
\ // UTF-8 leaked password: maman\n# '273CA8A2A78C9B2D724144F4FAF4D221C86:6',\
\ // ISO-8859-5 leaked password: \u043C\u0430\u043C\u0430\n# '3686792BBC66A72D40D928ED15621124CFE:7',\n\
# '36EEC709091B810AA240179A44317ED415C:2',\n# 'EE6EB9C0DFA0F07098CEDB11ECC7AFF9D4E:0',\
\ // UTF-8 not leaked password: ]<0585\"%sb^5aa$w6!b38\",,72?dp3r4\\45b28Hy\n\
# 'FC9F37E51AACD6B692A62769267590D46B8:0', // ISO-8859-5 non leaked password:\
\ \u043C<\u04320dp3r4\\45b28Hy\n# ];\n# \n# protected function createValidator():\
\ ConstraintValidatorInterface\n# {\n# // Pass HttpClient::create() instead of\
\ the mock to run the tests against the real API\n# return new NotCompromisedPasswordValidator($this->createHttpClientStub());\n\
# }\n# \n# public function testNullIsValid()\n# {\n# $this->validator->validate(null,\
\ new NotCompromisedPassword());\n# \n# $this->assertNoViolation();\n# }\n# \n\
# public function testEmptyStringIsValid()\n# {\n# $this->validator->validate('',\
\ new NotCompromisedPassword());\n# \n# $this->assertNoViolation();\n# }\n# \n\
# public function testInvalidPasswordButDisabled()\n# {\n# $r = new \\ReflectionProperty($this->validator,\
\ 'enabled');\n# $r->setValue($this->validator, false);\n# \n# $this->validator->validate(self::PASSWORD_LEAKED,\
\ new NotCompromisedPassword());\n# \n# $this->assertNoViolation();\n# }\n# \n\
# public function testInvalidPassword()\n# {\n# $constraint = new NotCompromisedPassword();\n\
# $this->validator->validate(self::PASSWORD_LEAKED, $constraint);\n# \n# $this->buildViolation($constraint->message)\n\
# ->setCode(NotCompromisedPassword::COMPROMISED_PASSWORD_ERROR)\n# ->assertRaised();\n\
# }\n# \n# public function testThresholdReached()\n# {\n# $constraint = new NotCompromisedPassword(['threshold'\
\ => 3]);\n# $this->validator->validate(self::PASSWORD_LEAKED, $constraint);\n\
# \n# $this->buildViolation($constraint->message)\n# ->setCode(NotCompromisedPassword::COMPROMISED_PASSWORD_ERROR)\n\
# ->assertRaised();\n# }\n# \n# /**\n# * @dataProvider provideConstraintsWithThreshold"
- name: provideConstraintsWithThreshold
visibility: public
parameters: []
comment: null
- name: testValidPassword
visibility: public
parameters: []
comment: null
- name: testNonUtf8CharsetValid
visibility: public
parameters: []
comment: null
- name: testNonUtf8CharsetInvalid
visibility: public
parameters: []
comment: null
- name: testInvalidPasswordCustomEndpoint
visibility: public
parameters: []
comment: null
- name: testEndpointWithInvalidValueInReturn
visibility: public
parameters: []
comment: null
- name: testInvalidConstraint
visibility: public
parameters: []
comment: null
- name: testInvalidValue
visibility: public
parameters: []
comment: null
- name: testApiError
visibility: public
parameters: []
comment: null
- name: testApiErrorSkipped
visibility: public
parameters:
- name: constraint
comment: '# * @dataProvider provideErrorSkippingConstraints'
- name: provideErrorSkippingConstraints
visibility: public
parameters: []
comment: null
- name: createHttpClientStub
visibility: private
parameters:
- name: returnValue
default: 'null'
comment: null
- name: getResponse
visibility: public
parameters: []
comment: null
- name: createHttpClientStubCustomEndpoint
visibility: private
parameters:
- name: expectedEndpoint
comment: null
traits:
- Symfony\Component\Validator\Constraints\Luhn
- Symfony\Component\Validator\Constraints\NotCompromisedPassword
- Symfony\Component\Validator\Constraints\NotCompromisedPasswordValidator
- Symfony\Component\Validator\ConstraintValidatorInterface
- Symfony\Component\Validator\Exception\UnexpectedTypeException
- Symfony\Component\Validator\Test\ConstraintValidatorTestCase
- Symfony\Contracts\HttpClient\Exception\ExceptionInterface
- Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface
- Symfony\Contracts\HttpClient\HttpClientInterface
- Symfony\Contracts\HttpClient\ResponseInterface
interfaces:
- ServerExceptionInterface