Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

134 인증 테스트 오류settings 파일 수정 #135

Merged
merged 2 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions jwtauth/test/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def api_client():
"""
API 클라이언트를 생성하여 반환합니다.
"""
return APIClient()
client = APIClient()
client.default_format = "json"
return client


@pytest.fixture
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 9 additions & 5 deletions weaverse/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading