diff options
| author | Andrew Pinkham <code@andrewsforge.com> | 2017-04-25 15:26:58 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-06-21 09:22:15 -0400 |
| commit | a96b981d84367fd41b1df40adf3ac9ca71a741dd (patch) | |
| tree | 3349d324683d69d18fce2ac6e5260e73853ba1a1 /tests/auth_tests | |
| parent | b1cbbe926789bcfc2e118c7d7c7a0f30fab5248a (diff) | |
Fixed #28127 -- Allowed UserCreationForm's password validation to check all user fields.
Diffstat (limited to 'tests/auth_tests')
| -rw-r--r-- | tests/auth_tests/test_forms.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py index 05f1f41961..e5cd05d0d8 100644 --- a/tests/auth_tests/test_forms.py +++ b/tests/auth_tests/test_forms.py @@ -239,6 +239,28 @@ class UserCreationFormTest(TestDataMixin, TestCase): '<ul><li>Your password can't be too similar to your other personal information.</li></ul>' ) + @override_settings(AUTH_PASSWORD_VALIDATORS=[ + {'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'}, + ]) + def test_user_create_form_validates_password_with_all_data(self): + """UserCreationForm password validation uses all of the form's data.""" + class CustomUserCreationForm(UserCreationForm): + class Meta(UserCreationForm.Meta): + model = User + fields = ('username', 'email', 'first_name', 'last_name') + form = CustomUserCreationForm({ + 'username': 'testuser', + 'password1': 'testpassword', + 'password2': 'testpassword', + 'first_name': 'testpassword', + 'last_name': 'lastname', + }) + self.assertFalse(form.is_valid()) + self.assertEqual( + form.errors['password2'], + ['The password is too similar to the first name.'], + ) + # To verify that the login form rejects inactive users, use an authentication # backend that allows them. |
