diff --git a/jwtauth/test/test_authentication.py b/jwtauth/test/test_authentication.py index d112fca..3898c44 100644 --- a/jwtauth/test/test_authentication.py +++ b/jwtauth/test/test_authentication.py @@ -18,7 +18,9 @@ def api_client(): """ API 클라이언트를 생성하여 반환합니다. """ - return APIClient() + client = APIClient() + client.default_format = "json" + return client @pytest.fixture @@ -140,8 +142,8 @@ def test_JWT_인증_실패_만료된_토큰(api_client, user): url = reverse("refresh") # When: 리프레시 API에 만료된 토큰과 함께 POST 요청을 보냄 response = api_client.post(url) - # Then: 응답 상태 코드가 400 (Bad Request)임 - assert response.status_code == status.HTTP_400_BAD_REQUEST + # Then: 응답 상태 코드가 401 (Unauthorized)임 + assert response.status_code == status.HTTP_401_UNAUTHORIZED @pytest.mark.django_db @@ -152,8 +154,8 @@ def test_JWT_인증_실패_유효하지_않은_토큰(api_client): url = reverse("refresh") # When: 리프레시 API에 유효하지 않은 토큰과 함께 POST 요청을 보냄 response = api_client.post(url) - # Then: 응답 상태 코드가 400 (Bad Request)임 - assert response.status_code == status.HTTP_400_BAD_REQUEST + # Then: 응답 상태 코드가 401 (Unauthorized)임 + assert response.status_code == status.HTTP_401_UNAUTHORIZED @pytest.mark.django_db diff --git a/weaverse/settings.py b/weaverse/settings.py index f4647f4..adf14f7 100644 --- a/weaverse/settings.py +++ b/weaverse/settings.py @@ -58,12 +58,16 @@ ] REST_FRAMEWORK = { - "DEFAULT_RENDERER_CLASSES": ( + "DEFAULT_RENDERER_CLASSES": [ "rest_framework.renderers.JSONRenderer", - "rest_framework.renderers.BrowsableAPIRenderer", # 이 옵션이 있어야 브라우저에서 API를 시각적으로 볼 수 있음 - ), - "DEFAULT_AUTHENTICATION_CLASSES": ("jwtauth.authentication.JWTAuthentication",), - "DEFAULT_PARSER_CLASSES": ("rest_framework.parsers.JSONParser",), + "rest_framework.renderers.BrowsableAPIRenderer", + ], + "DEFAULT_AUTHENTICATION_CLASSES": [ + "jwtauth.authentication.JWTAuthentication", + ], + "DEFAULT_PARSER_CLASSES": [ + "rest_framework.parsers.JSONParser", + ], "DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema", "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination", "PAGE_SIZE": 10,