Fix #883: Prevent usage of too weak passwords

This commit is contained in:
Eliot Berriot 2019-09-21 16:11:08 +02:00
parent def555bd50
commit f44abfecfb
6 changed files with 91 additions and 13 deletions

View file

@ -4,7 +4,11 @@ from funkwhale_api.users.admin import MyUserCreationForm
def test_clean_username_success(db):
# Instantiate the form with a new username
form = MyUserCreationForm(
{"username": "alamode", "password1": "123456", "password2": "123456"}
{
"username": "alamode",
"password1": "thisismypassword",
"password2": "thisismypassword",
}
)
# Run is_valid() to trigger the validation
valid = form.is_valid()
@ -19,7 +23,11 @@ def test_clean_username_false(factories):
user = factories["users.User"]()
# Instantiate the form with the same username as self.user
form = MyUserCreationForm(
{"username": user.username, "password1": "123456", "password2": "123456"}
{
"username": user.username,
"password1": "thisismypassword",
"password2": "thisismypassword",
}
)
# Run is_valid() to trigger the validation, which is going to fail
# because the username is already taken