Fakultas Ilmu Komputer UI

Commit d4a08bb0 authored by Dhita Putri Pratama's avatar Dhita Putri Pratama
Browse files

Merge branch 'warmfix-oauth-refresh-token' into 'staging'

Warmfix oauth refresh token

See merge request !120
parents ad7bee5c fae1571d
Pipeline #49906 passed with stages
in 3 minutes and 7 seconds
......@@ -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:
......@@ -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):
data = {
'access': str(AccessToken.for_user(user))
'access': str(AccessToken.for_user(user)),
'refresh': str(RefreshToken.for_user(user)),
return Response(data)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment