#35477: Django 5.1a1 - unexpected error message
---------------------------------+------------------------------------
Reporter: אורי | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: 5.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Sarah Boyce):
* component: Uncategorized => contrib.auth
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
* type: Uncategorized => Bug
Comment:
Hi אורי, I spent quite a while with this. Next time please share links to
your tests or code in the ticket.
git bisect confirmed this is a regression in
e626716c28b6286f8cf0f8174077f3d2244f3eb3 (ref #34429)
Here is a test case:
{{{#!diff
diff --git a/tests/auth_tests/test_forms.py
b/tests/auth_tests/test_forms.py
index b44f1edb24..f5e2612bf5 100644
--- a/tests/auth_tests/test_forms.py
+++ b/tests/auth_tests/test_forms.py
@@ -3,6 +3,7 @@ import re
import urllib.parse
from unittest import mock
+from django.contrib.auth import password_validation
from django.contrib.auth.forms import (
AdminPasswordChangeForm,
AuthenticationForm,
@@ -865,6 +866,37 @@ class SetPasswordFormTest(TestDataMixin, TestCase):
form.fields[field_name].widget.attrs["autocomplete"],
autocomplete
)
+ @override_settings(
+ AUTH_PASSWORD_VALIDATORS=[
+ {
+ "NAME": (
+
"django.contrib.auth.password_validation.MinimumLengthValidator"
+ ),
+ "OPTIONS": {"min_length": 12},
+ },
+ ]
+ )
+ def test_extra_validation(self):
+ class ModifiedSetPasswordForm(SetPasswordForm):
+ def clean_new_password1(self):
+ new_password = self.cleaned_data["new_password1"]
+
password_validation.validate_password(password=new_password)
+ return new_password
+
+ user = User.objects.get(username="testclient")
+ form = ModifiedSetPasswordForm(
+ user, {"new_password1": "abc", "new_password2": "abc"}
+ )
+ self.assertIs(form.is_valid(), False)
+ self.assertEqual(
+ form["new_password1"].errors,
+ ["This password is too short. It must contain at least 12
characters."],
+ )
+ self.assertEqual(
+ form["new_password2"].errors,
+ ["This password is too short. It must contain at least 12
characters."],
+ )
+
class PasswordChangeFormTest(TestDataMixin, TestCase):
def test_incorrect_password(self):
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35477#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018fa9f308a8-e8987f00-e715-492f-8f07-e6dff188a705-000000%40eu-central-1.amazonses.com.