Skip to content
This repository was archived by the owner on May 26, 2020. It is now read-only.

Commit c617edb

Browse files
committed
Specify empty authentication_classes #27
1 parent 3554790 commit c617edb

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

rest_framework_jwt/tests/test_views.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,25 @@ def test_jwt_login_form(self):
7878
self.assertEqual(response.status_code, status.HTTP_200_OK)
7979
self.assertEqual(decoded_payload['username'], self.username)
8080

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+
81100

82101
class CustomUserObtainJSONWebTokenTests(TestCase):
83102
"""JSON Web Token Authentication"""

rest_framework_jwt/views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class ObtainJSONWebToken(APIView):
1515
"""
1616
throttle_classes = ()
1717
permission_classes = ()
18+
authentication_classes = ()
1819
parser_classes = (parsers.FormParser, parsers.JSONParser,)
1920
renderer_classes = (renderers.JSONRenderer,)
2021
serializer_class = JSONWebTokenSerializer

0 commit comments

Comments
 (0)