def test_password_breached(self):
     form = forms.ResetPasswordForm(
         data={
             "new_password": "******",
             "password_confirm": "MyStr0ng!shPassword",
             "username": "******",
             "full_name": "full_name",
             "email": "email",
         },
         user_service=pretend.stub(
             find_userid=pretend.call_recorder(lambda _: None)
         ),
         breach_service=pretend.stub(
             check_password=lambda pw, tags=None: True,
             failure_message=(
                 "This password has appeared in a breach or has otherwise been "
                 "compromised and cannot be used."
             ),
         ),
     )
     assert not form.validate()
     assert form.new_password.errors.pop() == (
         "This password has appeared in a breach or has otherwise been "
         "compromised and cannot be used."
     )
    def test_password_confirm_required_error(self):
        form = forms.ResetPasswordForm(
            data={"password_confirm": ""},
            breach_service=pretend.stub(check_password=lambda pw, tags=None: False),
        )

        assert not form.validate()
        assert form.password_confirm.errors.pop() == "This field is required."
示例#3
0
    def test_passwords_match_success(self):
        form = forms.ResetPasswordForm(data={
            "password":
            "******",
            "password_confirm":
            "MyStr0ng!shPassword",
        }, )

        assert form.validate()
示例#4
0
    def test_passwords_mismatch_error(self):
        form = forms.ResetPasswordForm(data={
            "password": "******",
            "password_confirm": "mismatch",
        }, )

        assert not form.validate()
        assert (form.password_confirm.errors.pop() ==
                "Your passwords do not match. Please try again.")
示例#5
0
    def test_passwords_match_success(self):
        form = forms.ResetPasswordForm(data={
            "new_password": "******",
            "password_confirm": "MyStr0ng!shPassword",
            "username": "******",
            "full_name": "full_name",
            "email": "email",
        }, )

        assert form.validate()
示例#6
0
    def test_password_strength(self, password, expected):
        form = forms.ResetPasswordForm(data={
            "new_password": password,
            "password_confirm": password,
            "username": "******",
            "full_name": "full_name",
            "email": "email",
        }, )

        assert form.validate() == expected
示例#7
0
    def test_passwords_mismatch_error(self):
        form = forms.ResetPasswordForm(data={
            "new_password": "******",
            "password_confirm": "mismatch",
            "username": "******",
            "full_name": "full_name",
            "email": "email",
        }, )

        assert not form.validate()
        assert (form.password_confirm.errors.pop() ==
                "Your passwords don't match. Try again.")
    def test_passwords_match_success(self):
        form = forms.ResetPasswordForm(
            data={
                "new_password": "******",
                "password_confirm": "MyStr0ng!shPassword",
                "username": "******",
                "full_name": "full_name",
                "email": "email",
            },
            breach_service=pretend.stub(check_password=lambda pw, tags=None: False),
        )

        assert form.validate()
    def test_password_strength(self, password, expected):
        form = forms.ResetPasswordForm(
            data={
                "new_password": password,
                "password_confirm": password,
                "username": "******",
                "full_name": "full_name",
                "email": "email",
            },
            breach_service=pretend.stub(check_password=lambda pw, tags=None: False),
        )

        assert form.validate() == expected
示例#10
0
    def test_passwords_mismatch_error(self):
        form = forms.ResetPasswordForm(
            data={
                "new_password": "******",
                "password_confirm": "mismatch",
                "username": "******",
                "full_name": "full_name",
                "email": "email",
            },
            breach_service=pretend.stub(
                check_password=lambda pw, tags=None: False),
        )

        assert not form.validate()
        assert (form.password_confirm.errors.pop() ==
                "Your passwords don't match. Try again.")
示例#11
0
    def test_password_confirm_required_error(self):
        form = forms.ResetPasswordForm(data={"password_confirm": ""})

        assert not form.validate()
        assert form.password_confirm.errors.pop() == "This field is required."
示例#12
0
 def test_password_strength(self, password, expected):
     form = forms.ResetPasswordForm(data={
         "password": password,
         "password_confirm": password
     }, )
     assert form.validate() == expected