#24987: django.test.client.Client.login() rejects user with is_active=False
-------------------------------------+-------------------------------------
Reporter: jdufresne | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Someday/Maybe
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by hobarrera):
> However, the AuthenticationForm used by the login() view (which is the
default) does perform this check, as do the permission-checking methods
such as has_perm() and the authentication in the Django admin. All of
those functions/methods will return False for inactive users.
I think it makes sense for inactive users to get rejected; it's the result
you'd get while using the whole default stack (eg: backend + view + form).
My first thought is that your tests should use `force_login`, or maybe
override `login()` to use your own login view+form combination.
Another, more flexible, but more appropriate fix is for `login()` to log
in users by posting to `LOGIN_URL`, which makes sure that tests use the
exact same thing as what your application uses. This might be more effort,
but makes tests far more consistent for everyone.
--
Ticket URL: <https://code.djangoproject.com/ticket/24987#comment:13>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.45c795a69c1ca5a539906279e7105cd0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.