Skip to content

Commit 88302fa

Browse files
committed
Fix LogoutSerializer for JWT/dj_rest_auth #1392
1 parent f7138e3 commit 88302fa

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

drf_spectacular/contrib/rest_auth.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,9 @@ def view_replacement(self):
7878

7979
if (
8080
get_use_jwt()
81-
and getattr(settings, 'SIMPLE_JWT', {}).get('BLACKLIST_AFTER_ROTATION', False)
8281
and 'rest_framework_simplejwt.token_blacklist' in settings.INSTALLED_APPS
82+
and not get_dj_rest_auth_setting('JWT_AUTH_HTTPONLY', 'JWT_AUTH_HTTPONLY')
8383
):
84-
8584
class LogoutSerializer(serializers.Serializer):
8685
refresh = serializers.CharField(required=True, allow_blank=False)
8786

tests/contrib/test_rest_auth.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ class XViewset(viewsets.ModelViewSet):
8282

8383

8484
@pytest.mark.contrib('dj_rest_auth', 'rest_framework_simplejwt')
85-
@mock.patch('dj_rest_auth.app_settings.api_settings.USE_JWT', True, create=True)
85+
@mock.patch('dj_rest_auth.app_settings.api_settings.USE_JWT', True)
86+
@mock.patch('dj_rest_auth.app_settings.api_settings.JWT_AUTH_HTTPONLY', False)
8687
def test_rest_auth_token_blacklist(no_warnings, settings):
8788
# flush module import cache to re-evaluate conditional import
8889
import dj_rest_auth.urls
@@ -92,15 +93,13 @@ def test_rest_auth_token_blacklist(no_warnings, settings):
9293
'rest_framework_simplejwt',
9394
'rest_framework_simplejwt.token_blacklist',
9495
)
95-
settings.SIMPLE_JWT = {
96-
'BLACKLIST_AFTER_ROTATION': True
97-
}
98-
9996
urlpatterns = [
10097
path('rest-auth/', include('dj_rest_auth.urls')),
10198
]
10299
schema = generate_schema(None, patterns=urlpatterns)
103-
assert get_request_schema(schema['paths']['/rest-auth/logout/']['post'])['$ref'] == '#/components/schemas/Logout'
100+
assert get_request_schema(schema['paths']['/rest-auth/logout/']['post'])['$ref'] == (
101+
'#/components/schemas/Logout'
102+
)
104103
assert schema['components']['schemas']['Logout'] == {
105104
'type': 'object',
106105
'properties': {

0 commit comments

Comments
 (0)