Skip to content

Commit fe3ce1e

Browse files
committed
test: add test for rest_framework_simplejwt.token_blacklist support
1 parent ca5eff2 commit fe3ce1e

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

tests/contrib/test_rest_auth.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from django.urls import include, path
77
from rest_framework import viewsets
88

9-
from tests import assert_schema, generate_schema
9+
from tests import assert_schema, generate_schema, get_request_schema
1010
from tests.models import SimpleModel, SimpleSerializer
1111

1212
try:
@@ -79,3 +79,35 @@ class XViewset(viewsets.ModelViewSet):
7979
'jwtCookieAuth': {'type': 'apiKey', 'in': 'cookie', 'name': 'jwt-session'},
8080
'jwtHeaderAuth': {'type': 'http', 'scheme': 'bearer', 'bearerFormat': 'JWT'}
8181
}
82+
83+
84+
@pytest.mark.contrib('dj_rest_auth', 'rest_framework_simplejwt')
85+
def test_rest_auth_token_blacklist(no_warnings, settings):
86+
# flush module import cache to re-evaluate conditional import
87+
import dj_rest_auth.urls
88+
reload(dj_rest_auth.urls)
89+
90+
settings.INSTALLED_APPS += (
91+
'rest_framework_simplejwt',
92+
'rest_framework_simplejwt.token_blacklist',
93+
)
94+
settings.SIMPLE_JWT = {
95+
'BLACKLIST_AFTER_ROTATION': True
96+
}
97+
98+
urlpatterns = [
99+
path('rest-auth/', include('dj_rest_auth.urls')),
100+
]
101+
schema = generate_schema(None, patterns=urlpatterns)
102+
assert get_request_schema(schema['paths']['/rest-auth/logout/']['post'])['$ref'] == '#/components/schemas/Logout'
103+
assert schema['components']['schemas']['Logout'] == {
104+
'type': 'object',
105+
'properties': {
106+
'refresh': {
107+
'type': 'string',
108+
},
109+
},
110+
'required': [
111+
'refresh',
112+
],
113+
}

0 commit comments

Comments
 (0)