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] feat(#39): 유저 정보 조회 #84

Merged
merged 9 commits into from
Feb 1, 2024
Merged

Conversation

j-ra1n
Copy link
Contributor

@j-ra1n j-ra1n commented Jan 31, 2024

#️⃣ 연관된 이슈

#39

Pull Request Type

어떤 변경 사항이 있나요?

  • 새로운 기능 추가
  • 코드 리팩토링
  • 버그 수정
  • CSS 등 사용자 UI 디자인 변경
  • 테스트 추가, 테스트 리팩토링
  • 코드에 영향을 주지 않는 변경사항
    • 오타 수정, 문서 수정, 변수명 변경, 주석 추가 및 수정

Pull Request Checklist

PR이 다음 요구 사항을 충족하는지 확인하세요.

  • 변경 사항에 대한 테스트를 모두 통과했나요?
  • 코드 정렬은 적용했나요?
  • 새로운 branch에 작업 후 dev로 PR을 요청했나요?

📝 작업 내용

  • @AuthenticationPrincipal 어노테이션 사용 -> (인증된 사용자의 정보)
  • user info DTO 추가
  • 예외 메시지 추가
  • 테스트 추가

💬 리뷰 요구사항

유저정보 조회 성공 테스트가 안되고있는데 일단 res_code가 200이 나오고 res_obj에서 몇개만 불러와지는 상황입니다.

* @AuthenticationPrincipal 어노테이션 사용 -> (인증된 사용자의 정보)
* user info DTO 추가
* 예외 메시지 추가
* userInfoTest 구현
* name, profileImageUrl -> platformId, platformType 변경
@j-ra1n
Copy link
Contributor Author

j-ra1n commented Jan 31, 2024

image

image

* 사용자 정보 조회 userservice 구현
* 세션 사용자 정보 -> db 사용자 정보 조회 변경
* 예외메시지 추가
* Test 수정 (Json path 변경)
Copy link

github-actions bot commented Jan 31, 2024

📝 테스트 커버리지 리포트

Overall Project 44.83% -0.96%
Files changed 77.26% 🍏

File Coverage
ExceptionMessage.java 100% 🍏
UserInfoResponse.java 76.96% -23.04% 🍏
AuthService.java 76.09% -4.35% 🍏
AuthController.java 50.81% 🍏
UserException.java 0%

@rndudals
Copy link
Contributor

  1. 컨트롤러를 최대한 간단하게 하고 나머지 로직들을 UserService로 넘기는게 나을 것 같아요!
  2. AuthController에서 로직을 처리하는거여서 UserService 클래스를 따로 생성하는 것보다 AuthService안에 getUserByPlatform() 함수를 구현하는게 좋을 것 같습니다!

* UserService 제거 -> AuthService에 반영
* 컨트롤러 리팩토링 -> AuthService
@j-ra1n
Copy link
Contributor Author

j-ra1n commented Jan 31, 2024

  • authService를 @MockBean로 주입하면
    @DisplayName("유저정보 조회 성공 테스트")에서 오류나면서 실패함
    -> 디버깅 해보니 AuthController의 @GetMapping("/info") 부분에서 getUserByInfo 함수 호출이 안됩니다.

authService를 @Autowired로 주입하면
함수 호출이 잘되고 [유저정보 조회 성공 테스트 ]성공합니다.
하지만 [로그아웃 성공 테스트] 은 실패합니다.

이유를 모르겠습니다.

@jusung-c
Copy link
Contributor

jusung-c commented Feb 1, 2024

@MockBean 테스트는 가짜 객체를 넣어주는 테스트여서 실제 작동을 하지 않는 걸로 알고 있어욥.
AuthControllerTest는 컨트롤러 단을 테스트하는 것이므로 when() 메서드를 통해 authService의 동작을 지정해준 후 테스트를 진행하면 될 것 같아요~

authService 동작에 대한 테스트는 AuthServiceTest에서 진행하시면 될 것 같아요!

* when( ) 메서드로 동작 지정
* getUserByInfo 테스트
* UserException 추가
* 조회 정보 없으면 null -> 예외
@j-ra1n
Copy link
Contributor Author

j-ra1n commented Feb 1, 2024

예외확인
image

@j-ra1n j-ra1n merged commit 6894fb2 into dev Feb 1, 2024
1 check failed
@j-ra1n j-ra1n deleted the feat(#39)-user-Info-inquiry branch February 4, 2024 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants