Skip to content

[Test] CustomOAuth2UserService 테스트를 loadUser() 실제 호출 기준으로 재작성해 findOrCreate 검증 - #203

Open
minseo0313 wants to merge 4 commits into
devfrom
test/#155-oauth-jwt
Open

[Test] CustomOAuth2UserService 테스트를 loadUser() 실제 호출 기준으로 재작성해 findOrCreate 검증#203
minseo0313 wants to merge 4 commits into
devfrom
test/#155-oauth-jwt

Conversation

@minseo0313

@minseo0313 minseo0313 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

💡 개요

CustomOAuth2UserServiceTest가 노션 AUTH-004 명세와 달리 loadUser()를 실행하지 않고
private createUserInfo()만 리플렉션으로 호출해, findOrCreate() 호출 검증과
providerId=null 예외 분기가 테스트되지 않던 문제를 수정합니다.

🪐 주요 변경 사항

  • TC-004~008을 customOAuth2UserService.loadUser(userRequest) 실제 호출 기준으로 재작성
  • RestOperations mock을 setRestOperations로 주입해 super.loadUser()의 userinfo HTTP 호출만 격리
  • findOrCreate() 호출 인자 검증 및 OAuth2UserAdapter 반환 검증 추가

✅ 상세 내용

  • TC-004~006 (kakao/google/naver): loadUser() 호출 후
    verify(userService).findOrCreate(argThat(info -> provider/providerId 일치)) +
    반환값 instanceof OAuth2UserAdapter 검증
  • TC-007 (미지원 provider): loadUser() 경유 OAuth2AuthenticationException(Unsupported provider)
    발생 및 findOrCreate() 미호출 검증
  • TC-008 (providerId=null): loadUser() 경유 OAuth2AuthenticationException(Provider ID is missing)
    발생 및 findOrCreate() 미호출 검증 — 기존 테스트가 커버하지 못하던
    CustomOAuth2UserService.loadUser()의 null 체크 분기를 실제로 실행
  • 중복/미사용 import(MemberType, ReflectionTestUtils, wildcard) 및 불필요한 spy() 래핑 제거
  • 파싱 단위 검증은 기존 OAuth2UserInfoTest와 중복되어 제거

🔔 참고 사항

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 575ed783-bdf0-4e3d-9746-a6232e6462b7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@minseo0313 minseo0313 changed the title test: CustomOAuth2UserService 테스트를 loadUser() 실제 호출 기준으로 재작성해 findOrCreate 연동·예외 분기 검증 (#155) [test] CustomOAuth2UserService 테스트를 loadUser() 실제 호출 기준으로 재작성해 findOrCreate 검증 Sep 3, 2026
@minseo0313 minseo0313 changed the title [test] CustomOAuth2UserService 테스트를 loadUser() 실제 호출 기준으로 재작성해 findOrCreate 검증 [Test] CustomOAuth2UserService 테스트를 loadUser() 실제 호출 기준으로 재작성해 findOrCreate 검증 Sep 3, 2026
@minseo0313
minseo0313 requested a review from seoyeon83 September 3, 2026 02:55

@seoyeon83 seoyeon83 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. 확인했습니다.

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.

2 participants