diff --git a/backend/main/test_views.py b/backend/main/test_views.py index f4d7ed3c2f2cbeebf69d46a5101e05afd1c85d9c..b5d523c422a533a9441e23de567dfc101d77887d 100644 --- a/backend/main/test_views.py +++ b/backend/main/test_views.py @@ -255,7 +255,15 @@ class OAuthAccessTokenViewTestCase(APITestCase): response = self.client.post('/auth/access/oauth/', data={'tokenId': self.token}) - self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertEqual('access' in response.data, True) + + def test_get_refresh_token(self): + with patch('main.views.OAuthAccessTokenView.get_keys') as fake_keys: + fake_keys.return_value = self.keys + response = self.client.post('/auth/access/oauth/', + data={'tokenId': self.token}) + + self.assertEqual('refresh' in response.data, True) def test_get_access_token_bad(self): with patch('main.views.OAuthAccessTokenView.get_keys') as fake_keys: diff --git a/backend/main/views.py b/backend/main/views.py index 304ac78f584a04056e584ed29a5a99f42c43a063..9745ee1c6742378057f721e616d174e86ebe4143 100644 --- a/backend/main/views.py +++ b/backend/main/views.py @@ -9,7 +9,7 @@ from django.utils.translation import gettext_lazy as _ from rest_framework import exceptions, generics, status, views from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response -from rest_framework_authlib.tokens import AccessToken +from rest_framework_authlib.tokens import AccessToken, RefreshToken from urllib.parse import urljoin, quote from . import ( @@ -163,7 +163,8 @@ class OAuthAccessTokenView(views.APIView): is_verified=True) data = { - 'access': str(AccessToken.for_user(user)) + 'access': str(AccessToken.for_user(user)), + 'refresh': str(RefreshToken.for_user(user)), } return Response(data)