-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature: 회원가입 및 로그인 구현 #16
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
혹시 api/v1 앞에 붙는건 환경 변수로 컨트롤하는건 어떤가요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수정하겠습니다
doReturn(user.getProviderId()).when(oidcProviderFactory).getProviderId(dto.provider(), dto.idToken()); | ||
doReturn(user).when(userWriter).create(any(User.class)); | ||
doReturn(jwt).when(jwtProvider).generateToken(user); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
random value 만들어주는 테스트는 좋네요 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다만, 저번에 말씀해주셨듯이 통합테스트에서는 정확한 범위 내에서 랜덤을 돌려야겠어요. 이상한 문자도 들어가서 특수한 경우(ex. Base64 decoding)에는 에러 발생 가능성이 있습니다.
@AutoConfigureMockMvc | ||
@ActiveProfiles("test") | ||
@SpringBootTest | ||
@SpringBootTest(properties = "spring.profiles.active: test") | ||
public abstract class ControllerTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Controller Test에서는 MockMvc로 테스트하고 통합테스트는 따로 Test Container로 설정된 DB까지 접근될 수 있게 작성하면 되는걸로 이해하면 되나요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어.. 그런건 아니고, 의식의 흐름이었습니다 ㅋㅋ 수정하고 리뷰 요청 다시 보내겠습니다.
MockMvc를 활용해도 SpringBootTest이기에 Testcontainer를 활용할 수 있습니다. TestRestTemplate으로 변경한 이유는 서블릿 컨테이너를 활용하기 위해서입니다. |
확인했습니다 |
#4
이전 PR에서 구현했던 것들을 활용하여 회원가입과 로그인 API를 구현했습니다. 모두 Provider와 외부 API를 활용하는 로직들이라 특별한 도메인 모델은 없습니다. 통합 테스트 관련하여 Testcontainer를 활용하기로 했는데, 외부 API에 의존하는 로직이다보니 모킹이 필수라 생각이 들었고, 일단 모킹을 활용하여 단위테스트만 작성해두었습니다. Query의 경우, Jpa 메서드를 통한 자동완성만을 활용했기에 크게 이상이 있을 것 같진 않습니다.
추후에 환경변수를 세팅하여 배포할텐데, 아마 git의 submodule을 활용할 예정입니다.
또 Testcontainer 관련하여 간략하게 적자면, 일단 세팅은 모두 되어있고, 로컬에서 SpringBootTest나 Build 시, docker를 실행시켜놓아야 Testcontainer가 올리갑니다. 추가적으로 궁금하신점은 리뷰와 함께 남겨주세요.
ps. 초기 설정 파일이 좀 있다보니 PR이 커져버렸는데, 설정까지만 양해 부탁드립니다 .