Skip to content

test: 로그인 인증 테스트#161

Open
hyeok3767 wants to merge 1 commit intodevelopfrom
test/160-login-auth-test
Open

test: 로그인 인증 테스트#161
hyeok3767 wants to merge 1 commit intodevelopfrom
test/160-login-auth-test

Conversation

@hyeok3767
Copy link

작업 내용

  • 유효한 로그인 토큰에 대하여 2가지 테스트 실행
  • 유효하지 않은 로그인 토큰에 대하여 4가지 테스트 실행

특이 사항 (리뷰 시 참고할 내용)

관련 이슈

close #160

Comment on lines +43 to +47
//test.java.com.keunsori.keunsoriserver.auth.api.AuthApiTest.java에서 사용하기 위해 추가하였습니다.
public String generateTokenForTest(String studentId, String name, MemberStatus status, long validity) {
return createToken(studentId, name, status, validity);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

이 부분 사용되지 않고 있는 것 같은데 혹시 맞을까요..?

Copy link
Member

@kckc0608 kckc0608 left a comment

Choose a reason for hiding this comment

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

첫 PR 수고 많으셨습니다!! 코멘트 확인 부탁드려요~

Comment on lines +43 to +47
//test.java.com.keunsori.keunsoriserver.auth.api.AuthApiTest.java에서 사용하기 위해 추가하였습니다.
public String generateTokenForTest(String studentId, String name, MemberStatus status, long validity) {
return createToken(studentId, name, status, validity);
}

Copy link
Member

@kckc0608 kckc0608 Jan 9, 2026

Choose a reason for hiding this comment

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

테스트 용도의 코드는 메인 패키지 안에서 작성하지 않습니다!
테스트 용도로 필요한 로직은 테스트 패키지 내부에서 별도로 작성해주세용

Comment on lines +25 to +26
@Value("${jwt.secret}")
private String secretKey;
Copy link
Member

Choose a reason for hiding this comment

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

보통 테스트 할 때 시크릿키는 테스트용 시크릿키를 커스텀으로 만들어서 테스트해요!

Comment on lines +38 to 39
@DisplayName("Header에 유효한 토큰 존재")
void 로그인_되어있는_경우_테스트() throws JsonProcessingException {
Copy link
Member

Choose a reason for hiding this comment

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

보통 DisplayName 을 쓸 때는 메서드 명을 한글로 적지 않습니당. (DisplayName 을 두고 메서드 명을 영어로 적기 vs 메서드 명을 지을 때 구체적으로 무엇을 테스트하는지 상세하게 한글로 적기 중 택 1 하는 것이 일반적)

저희는 DisplayName 을 쓰지 않고 한글로 메서드 명을 적은거에용

.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);

.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(jwtExceptionFilter, JwtAuthenticationFilter.class);
Copy link
Member

Choose a reason for hiding this comment

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

  1. 요 로직들이 새로 추가된 이유를 PR 설명에 같이 적어주시면 더 좋을 것 같아요
  2. 에러 메세지는 하드코딩하지 않고 상수로 빼서 적어주세요!

Map<String, Object> body = new HashMap<>();
body.put("status", HttpServletResponse.SC_UNAUTHORIZED);
body.put("error", "Unauthorized");
body.put("message", e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

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

SecurityConfig 에서 응답하는 body 형식과 다른 것 같은데, 통일하면 더 좋을 것 같아요~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test : 로그인 인증 테스트 코드 작성

3 participants