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

[BE] Auth E2E 테스트 작성 #389

Merged
merged 14 commits into from
Feb 13, 2024

Conversation

HyoJongPark
Copy link
Collaborator

이슈 번호

#382

완료한 기능 명세

image
  • Auth 모듈 E2E 테스트 작성

@HyoJongPark HyoJongPark added the BE 💻 BackEnd label Feb 6, 2024
@HyoJongPark HyoJongPark added this to the 개선 milestone Feb 6, 2024
@HyoJongPark HyoJongPark requested a review from shunny822 February 6, 2024 08:25
@HyoJongPark HyoJongPark self-assigned this Feb 6, 2024
Copy link
Collaborator Author

@HyoJongPark HyoJongPark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오옷쓰 테스트 끝입니다.!! 😆
천천히 봐주세요!!

@@ -20,6 +21,7 @@ export class AuthController {
}

@Get('refresh_token')
@UseGuards(JwtAuthGuard)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존에 refresh 토큰 발급 기능에서 토큰 없이 요청이 오는 경우 500 에러가 발생해 controller 진입 전 jwt토큰 유효성 검증을 하도록 변경했습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 하면 이 API를 사용하는 일반적인 경우인,
jwt 토큰이 있지만 유효기한이 지난 경우에 가드에서 계속 막히지 않나요..?

서비스 로직에서 jwt가 없는 경우에 로그인 하도록 UnauthorizedException을 보내도록 추가해도 좋을 것 같아요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

가드는 삭제하고, 서비스 로직에서 체크하도록 변경했습니다

backend/src/auth/auth.service.ts Show resolved Hide resolved
backend/test/auth/auth.e2e-spec.ts Show resolved Hide resolved
const response = await agent.post(url);

//then
expect(response.status).toEqual(201);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logout의 response status가 201로 오던데, 의도하신건가요??

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

호오.. 아니욥ㅋㅋㅋ
공식문서 찾아보니까 POST 요청인 경우에 응답코드가 기본으로 201이 되나 봅니다!
image

status code를 바꾸려면 @HttpCode를 사용하면 되는 것 같은데 어떻게 할까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋네요!! 이걸로 200 코드를 반환하도록 변경했습니다.

backend/test/auth/auth.e2e-spec.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@shunny822 shunny822 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

벌써 마지막 e2e라니... 수고 많으셨습니다! 👍🔥🔥

@@ -20,6 +21,7 @@ export class AuthController {
}

@Get('refresh_token')
@UseGuards(JwtAuthGuard)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 하면 이 API를 사용하는 일반적인 경우인,
jwt 토큰이 있지만 유효기한이 지난 경우에 가드에서 계속 막히지 않나요..?

서비스 로직에서 jwt가 없는 경우에 로그인 하도록 UnauthorizedException을 보내도록 추가해도 좋을 것 같아요!

backend/test/auth/auth.e2e-spec.ts Outdated Show resolved Hide resolved
backend/test/auth/auth.e2e-spec.ts Show resolved Hide resolved
backend/test/auth/auth.e2e-spec.ts Outdated Show resolved Hide resolved
backend/test/auth/auth.e2e-spec.ts Outdated Show resolved Hide resolved
const response = await agent.post(url);

//then
expect(response.status).toEqual(201);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

호오.. 아니욥ㅋㅋㅋ
공식문서 찾아보니까 POST 요청인 경우에 응답코드가 기본으로 201이 되나 봅니다!
image

status code를 바꾸려면 @HttpCode를 사용하면 되는 것 같은데 어떻게 할까요?

Copy link
Collaborator

@shunny822 shunny822 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

너무 고생 많으셨습니다!!
성불 축하드립니다 😂🔥🔥

@HyoJongPark HyoJongPark merged commit 154dbe8 into boostcampwm2023:develop Feb 13, 2024
1 check passed
@HyoJongPark HyoJongPark deleted the be/test/auth-e2e branch February 13, 2024 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE 💻 BackEnd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants