|
6 | 6 | from django.urls import include, path |
7 | 7 | from rest_framework import viewsets |
8 | 8 |
|
9 | | -from tests import assert_schema, generate_schema |
| 9 | +from tests import assert_schema, generate_schema, get_request_schema |
10 | 10 | from tests.models import SimpleModel, SimpleSerializer |
11 | 11 |
|
12 | 12 | try: |
@@ -79,3 +79,35 @@ class XViewset(viewsets.ModelViewSet): |
79 | 79 | 'jwtCookieAuth': {'type': 'apiKey', 'in': 'cookie', 'name': 'jwt-session'}, |
80 | 80 | 'jwtHeaderAuth': {'type': 'http', 'scheme': 'bearer', 'bearerFormat': 'JWT'} |
81 | 81 | } |
| 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