Conversation
Responses can be returned by middleware before reaching AuthenticationMiddleware - in these cases there is no request.user attribute. This happnes with the default Django MIDDLEWARE ordering if the current host is disallowed (not in ALLOWED_HOSTS)
|
Looks good, can you think of a way to add a unit test? I skimmed over the tests and did not see anything similar. This may require a new |
|
For reference, these views are used by some of the tests: https://github.com/smartfile/django-session-jwt/blob/master/django_session_jwt/views.py And the tests themselves are here, at the top of the file are some low-level tests (mocks and method calls). Tests for the middleware would fit roughly into this category. The second section uses the views above. https://github.com/smartfile/django-session-jwt/blob/master/django_session_jwt/tests.py |
|
Added a test that fails before this patch |
…attribute on Request)
|
Moved the test to the existing |
Responses can be returned by middleware before reaching
AuthenticationMiddleware- in these cases there is norequest.userattribute.This happens with Django's default
MIDDLEWAREordering if the current host is disallowed (not inALLOWED_HOSTS) for instance.