This repository was archived by the owner on May 26, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,25 @@ def test_jwt_login_form(self):
78
78
self .assertEqual (response .status_code , status .HTTP_200_OK )
79
79
self .assertEqual (decoded_payload ['username' ], self .username )
80
80
81
+ def test_jwt_login_with_expired_token (self ):
82
+ """
83
+ Ensure JWT login view works even if expired token is provided
84
+ """
85
+ payload = utils .jwt_payload_handler (self .user )
86
+ payload ['exp' ] = 1
87
+ token = utils .jwt_encode_handler (payload )
88
+
89
+ auth = 'JWT {0}' .format (token )
90
+ client = APIClient (enforce_csrf_checks = True )
91
+ response = client .post (
92
+ '/auth-token/' , self .data ,
93
+ HTTP_AUTHORIZATION = auth , format = 'json' )
94
+
95
+ decoded_payload = utils .jwt_decode_handler (response .data ['token' ])
96
+
97
+ self .assertEqual (response .status_code , status .HTTP_200_OK )
98
+ self .assertEqual (decoded_payload ['username' ], self .username )
99
+
81
100
82
101
class CustomUserObtainJSONWebTokenTests (TestCase ):
83
102
"""JSON Web Token Authentication"""
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ class ObtainJSONWebToken(APIView):
15
15
"""
16
16
throttle_classes = ()
17
17
permission_classes = ()
18
+ authentication_classes = ()
18
19
parser_classes = (parsers .FormParser , parsers .JSONParser ,)
19
20
renderer_classes = (renderers .JSONRenderer ,)
20
21
serializer_class = JSONWebTokenSerializer
You can’t perform that action at this time.
0 commit comments