Skip to content

[Test] 테스트 수정#428

Merged
david-parkk merged 15 commits intodevelopfrom
fix/#321
Feb 13, 2026
Merged

[Test] 테스트 수정#428
david-parkk merged 15 commits intodevelopfrom
fix/#321

Conversation

@david-parkk
Copy link
Contributor

@david-parkk david-parkk commented Feb 12, 2026

#️⃣ 연관된 이슈

closes #321

📝작업 내용

  • 테스트 jwt 토큰 제거
  • unit 테스트 공통 mock 상속 처리
  • 모든 restdocs test unit test 전환
  • 불필요한 테스트 제거
  • JWT 토큰 secret key 변경

작업 상세 내용

💬리뷰 요구사항

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요.

Summary by CodeRabbit

릴리스 노트

  • Tests

    • 테스트 인프라를 경량화하고 단위/웹 계층 중심으로 전환하여 테스트 범위 및 성능 개선
    • 공통 테스트 지원 구조 통일 및 불필요한 목(mock) 의존성 제거로 유지보수성 향상
    • 일부 통합형 테스트를 삭제하거나 Web MVC 슬라이스로 재구성
  • Chores

    • 서브모듈 참조 메타데이터 업데이트
    • 테스트용 설정을 변경하여 데이터베이스 스키마 생성 방식 조정

@github-actions
Copy link

Labeler has applied any labels matching special text in your title and description.
Please review the labels and make any necessary changes.

@github-actions github-actions bot added the test label Feb 12, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

Walkthrough

테스트 인프라에 새 기본 지원 클래스 RestDocsUnitTestSupport를 추가하고 다수의 테스트를 해당 클래스로 마이그레이션했습니다. 일부 통합 테스트는 @WebMvcTest로 축소되었고, 불필요한 테스트 파일들이 삭제되었으며 테스트용 설정과 서브모듈 참조가 갱신되었습니다.

Changes

Cohort / File(s) Summary
Submodule Reference Update
src/main/resources/config
서브모듈 커밋 참조 업데이트 (736a316...a2f38ba...).
새 테스트 지원 클래스
src/test/java/ku_rum/backend/config/RestDocsUnitTestSupport.java
RestDocsTestSupport를 확장한 새 테스트 지원 클래스 추가; @MockBean으로 ApiLogRepository, SecurityFilterChain, JwtTokenAuthenticationFilter 필드 보유.
기본 클래스 마이그레이션(다수의 단순 변경)
src/test/java/ku_rum/backend/domain/.../AlarmControllerTest.java, .../FcmAlarmControllerTest.java, .../BookmarkControllerTest.java, .../KeywordControllerTest.java, .../NoticeControllerTest.java, .../RankControllerTest.java, .../FriendQueryControllerTest.java, .../TemporaryUserControllerTest.java, .../UserFcmControllerTest.java
여러 테스트가 RestDocsTestSupportRestDocsUnitTestSupport로 변경되고 공통 보안/로그 관련 MockBean들이 제거됨(임포트 조정 포함).
WebMvcTest 전환(테스트 스코프 축소)
src/test/java/ku_rum/backend/domain/auth/presentation/AuthControllerTest.java, .../college/.../CollegeQueryControllerTest.java, .../common/mail/.../MailControllerTest.java, .../department/.../DepartmentQueryControllerTest.java, .../friend/.../FriendManageControllerTest.java, .../friend/.../FriendReportControllerTest.java, .../place/.../PlaceControllerTest.java, .../user/.../UserControllerTest.java, .../user/.../UserProfileControllerTest.java
여러 테스트에서 @SpringBootTest@WebMvcTest(...)로 전환하고 RestDocsUnitTestSupport로 변경, 보안 필터 MockBean 제거 및 Authorization 헤더 간소화 등 테스트 환경 경량화.
테스트 파일 삭제
src/test/java/ku_rum/backend/domain/common/firebase/application/NotificationServiceTest.java, src/test/java/ku_rum/backend/domain/common/firebase/presentation/NotificationApiControllerTest.java, src/test/java/ku_rum/backend/domain/common/image/presentation/ImageControllerTest.java
단위/통합 테스트 파일 삭제(테스트 코드 제거).
중간형 변경 및 기타 테스트 조정
src/test/java/ku_rum/backend/domain/search/presentation/RecentSearchControllerTest.java, src/test/java/ku_rum/backend/domain/place/presentation/PlaceControllerTest.java
기본 클래스 변경 및 MockBean/의존성 조정, 일부 테스트의 Authorization 헤더 및 REST Docs 설명 정리.
테스트용 설정 변경
src/main/resources/application-test.yml
jpa.hibernate.ddl-auto 값 변경: create-dropcreate.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • PR #296: 동일 application-test.ymlspring.jpa.hibernate.ddl-auto 변경과 관련됨.
  • PR #320: Bookmark 테스트 변경 및 RestDocs 지원 마이그레이션과 코드적 교차 가능성 있음.
  • PR #410: PlaceControllerTest 및 관련 테스트 설정 변경과 중복 가능성 있음.

Suggested labels

Refactor

Suggested reviewers

  • kmw10693

Poem

🐇 토끼가 폴더를 톡톡 두드리며 말하네,
새 지원 클래스로 테스트 숲을 정리했네.
무거운 통합은 가볍게, 문서는 반짝 반짝,
당근 하나 물고 코드를 춤추게 하네. 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 4
❌ Failed checks (2 warnings, 2 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ⚠️ Unable to check for merge conflicts: Invalid branch name format
Title check ❓ Inconclusive 제목이 매우 일반적이고 추상적입니다. '[Test] 테스트 수정'은 구체적인 변경 사항을 설명하지 않으며 모호합니다. 제목을 더 구체적으로 수정하세요. 예: '[Test] RestDocs 테스트를 Unit 테스트로 전환 및 JWT 토큰 제거' 또는 '[Test] Unit 테스트 마이그레이션 및 공통 mock 상속 처리'
Out of Scope Changes check ❓ Inconclusive 대부분의 변경 사항이 이슈 #321과 직접 관련되어 있으나, src/main/resources/config 서브모듈 업데이트와 application-test.yml의 JPA DDL-auto 변경은 관련성이 명확하지 않습니다. 서브모듈 커밋 업데이트와 application-test.yml의 ddl-auto 변경이 이슈 #321 해결과 어떤 관계가 있는지 명확히 설명해주세요.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed PR 설명이 대부분 완성되었으며 필수 섹션들이 포함되어 있으나, 리뷰 요구사항이 비어있습니다. 작업 내용과 상세 내용은 충분합니다.
Linked Issues check ✅ Passed PR이 연관된 이슈 #321의 모든 주요 목표를 충족합니다: JWT 헤더 설정 문제 해결, unit 테스트로 전환, 공통 mock 상속 적용, 불필요한 테스트 제거, JWT 토큰 제거 및 secret key 변경.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/#321
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch fix/#321
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
src/test/java/ku_rum/backend/domain/auth/presentation/AuthControllerTest.java (1)

288-308: exchangeToken 테스트의 responseFields.type() 지정이 누락되었습니다.

다른 테스트 메서드(login, logout, reissue)에서는 모든 fieldWithPath.type(JsonFieldType.XXX)을 명시하고 있으나, exchangeToken에서는 생략되어 있습니다. 생성되는 API 문서의 일관성을 위해 타입을 추가하는 것을 권장합니다.


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 and usage tips.

@github-actions
Copy link

github-actions bot commented Feb 12, 2026

Test Results

 36 files   36 suites   12s ⏱️
168 tests 168 ✅ 0 💤 0 ❌
169 runs  169 ✅ 0 💤 0 ❌

Results for commit c40f016.

♻️ This comment has been updated with latest results.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/test/java/ku_rum/backend/domain/user/presentation/TemporaryUserControllerTest.java (1)

57-57: ⚠️ Potential issue | 🟡 Minor

오타: "맴버" → "멤버"

API 태그에 "맴버 테스트 API"로 되어 있으나, "멤버 테스트 API"가 올바른 표기입니다.

✏️ 수정 제안
-                                .tag("맴버 테스트 API")
+                                .tag("멤버 테스트 API")
src/test/java/ku_rum/backend/domain/friend/presentation/FriendManageControllerTest.java (1)

107-107: ⚠️ Potential issue | 🟡 Minor

3개 테스트 메서드에서 Authorization 헤더 토큰이 갱신되지 않았습니다.

sendFriendRequestacceptFriendRequest"Bearer access-token"으로 변경되었지만, rejectFriendRequest (Line 107), deleteFriendRequest (Line 139), deleteFriend (Line 170)는 여전히 "Bearer your.jwt.token"을 사용합니다. PR 목적이 JWT 토큰 제거/통일인 만큼, 이 세 메서드도 동일하게 수정해야 합니다.

🐛 수정 제안
-                        .header("Authorization", "Bearer your.jwt.token")
+                        .header("Authorization", "Bearer access-token")

위 변경을 Line 107, 139, 170에 각각 적용하세요.

Also applies to: 139-139, 170-170

🤖 Fix all issues with AI agents
In
`@src/test/java/ku_rum/backend/domain/auth/presentation/AuthControllerTest.java`:
- Line 27: In AuthControllerTest replace the incorrect Selenium import and
usages: remove import org.openqa.selenium.json.JsonType and import
org.springframework.restdocs.payload.JsonFieldType instead, then update every
occurrence of JsonType (e.g. JsonType.STRING, JsonType.BOOLEAN, etc.) to
JsonFieldType (JsonFieldType.STRING, JsonFieldType.BOOLEAN, ...), ensuring calls
like fieldWithPath(...).type(...) now use JsonFieldType; also verify compilation
after removing the Selenium dependency.
- Around line 155-156: In AuthControllerTest update the Authorization header
used in the logout request to match the other tests: replace the header value
"Bearer your.jwt.token" in the
mockMvc.perform(patch("/api/v1/auth/logout").header("Authorization", ...)) call
with "Bearer access-token" so the test suite uses a consistent token string
across tests.
🧹 Nitpick comments (9)
src/test/java/ku_rum/backend/domain/friend/presentation/FriendReportControllerTest.java (1)

47-48: Authorization 헤더 토큰 문자열이 파일마다 불일치합니다.

이 파일에서는 "Bearer access_token" (밑줄)을 사용하지만, FriendManageControllerTest에서는 "Bearer access-token" (하이픈), "Bearer your.jwt.token" 등 다양한 형태가 혼용되고 있습니다. 테스트 간 일관성을 위해 하나의 상수로 통일하는 것을 권장합니다.

♻️ 상수 추출 제안

RestDocsUnitTestSupport 또는 별도 유틸 클래스에 상수를 정의:

public static final String MOCK_AUTH_HEADER = "Bearer test-access-token";

그리고 각 테스트에서 해당 상수를 참조:

 mockMvc.perform(patch("/api/v1/friends/block")
-                        .header("Authorization",
-                                "Bearer access_token")
+                        .header("Authorization", MOCK_AUTH_HEADER)

Also applies to: 82-83

src/test/java/ku_rum/backend/domain/friend/presentation/FriendManageControllerTest.java (1)

73-73: 사용되지 않는 변수 requestId.

Line 73과 Line 101에서 requestId가 선언되었지만 이후 사용되지 않습니다.

♻️ 제거 제안
-        Long requestId = 1L;
         FriendRequest friendRequest = new FriendRequest(1L);

Also applies to: 101-101

src/test/java/ku_rum/backend/domain/alarm/presentation/FcmAlarmControllerTest.java (1)

24-24: 테스트 클래스명 FcmAlarmControllerTestAlarmControllerTest 또는 AlarmControllerFcmTest로 변경하세요.

FcmAlarmController는 존재하지 않으며, 실제 테스트 대상은 AlarmController입니다. 테스트 클래스명을 테스트 대상과 일치시켜 코드 가독성과 유지보수성을 향상시키세요.

src/test/java/ku_rum/backend/domain/user/presentation/UserControllerTest.java (1)

44-44: org.openqa.selenium.json.JsonType 대신 org.springframework.restdocs.payload.JsonFieldType 사용을 권장합니다.

이 파일에서 REST Docs 필드 타입 서술자로 Selenium의 JsonType을 사용하고 있습니다 (예: Line 104, 108 등). 이는 불필요한 Selenium 의존성을 가져오며, 동일 파일 내에서 JsonFieldType(Line 48)과 혼용되고 있습니다. REST Docs 필드 타입에는 JsonFieldType을 일관되게 사용하는 것이 바람직합니다.

♻️ 제안: Selenium JsonType을 Spring REST Docs JsonFieldType으로 교체
-import org.openqa.selenium.json.JsonType;

그리고 파일 내의 JsonType.STRING, JsonType.NUMBER 등을 JsonFieldType.STRING, JsonFieldType.NUMBER로 일괄 변경합니다.

src/test/java/ku_rum/backend/domain/user/presentation/UserProfileControllerTest.java (1)

32-32: org.openqa.selenium.json.JsonTypeJsonFieldType으로 통일을 권장합니다.

UserControllerTest.java와 동일하게, 이 파일에서도 Selenium의 JsonType이 REST Docs 필드 타입 서술자로 사용되고 있습니다. org.springframework.restdocs.payload.JsonFieldType으로 통일하면 불필요한 Selenium 의존성을 제거할 수 있습니다.

src/test/java/ku_rum/backend/domain/bookmark/domain/BookmarkControllerTest.java (1)

1-1: 테스트 클래스 패키지 위치 확인 필요

BookmarkControllerTestku_rum.backend.domain.bookmark.domain 패키지에 위치하고 있지만, presentation 계층의 BookmarkController를 테스트하는 클래스입니다. ku_rum.backend.domain.bookmark.presentation 패키지로 이동하는 것이 다른 테스트 클래스들의 패키지 구조와 일관됩니다.

src/test/java/ku_rum/backend/domain/place/presentation/PlaceControllerTest.java (2)

104-106: Authorization 헤더 토큰 값 통일 확인.

변경된 라인들은 모두 "Bearer access-token"으로 일관되게 적용되었습니다. 다만 변경되지 않은 일부 테스트 메서드(searchPlace Line 329, savePlaceSearchKeyword Line 381)에서는 여전히 "Bearer test-access-token"을 사용하고 있어 불일치가 남아 있습니다. 이번 PR에서 함께 통일하는 것을 고려해 주세요.

🔧 수정 제안 (Line 329, 381)
-                        .header("Authorization", "Bearer test-access-token"))
+                        .header("Authorization", "Bearer access-token"))

82-93: setUp()에서 수동 SecurityContext 설정은 @WithMockUser로 대체 가능합니다.

다른 테스트 파일(CollegeQueryControllerTest, AuthControllerTest)에서는 @WithMockUser를 사용하고 있지만, 이 파일에서는 @BeforeEach에서 직접 SecurityContextHolder를 설정하고 있습니다. CustomUserDetails가 필요한 테스트가 있어 의도적인 것으로 보이지만, CustomUserDetails를 사용하지 않는 테스트에서는 @WithMockUser와 혼재되지 않도록 일관성을 확인해 주세요.

src/test/java/ku_rum/backend/domain/college/presentation/CollegeQueryControllerTest.java (1)

29-33: S3Service MockBean 선언을 RestDocsUnitTestSupport로 통합하는 것을 고려해 주세요.

S3Service가 정규화된 클래스 이름(ku_rum.backend.domain.common.s3.application.S3Service)으로 선언되어 있으며, 현재 AuthControllerTestCollegeQueryControllerTest 두 곳에서 동일하게 중복되어 있습니다. 두 테스트 클래스 모두 RestDocsUnitTestSupport를 상속하므로, 이 공통 MockBean을 기본 클래스에 추가하거나 import 문을 사용하여 코드 중복을 줄일 수 있습니다.

Comment on lines 155 to +156
mockMvc.perform(patch("/api/v1/auth/logout")
.header("Authorization", "Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyUEsiOjEsInJvbGVzIjoiUk9MRV9VU0VSIiwiaWF0IjoxNzQwMjQyNjQxLCJleHAiOjE3NDAyNDQ0NDF9.kLSMBLWdvIvrBpGJdOigSKjxMIab0cV06xFjSpwrq70")
.header("Authorization", "Bearer your.jwt.token")
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Authorization 헤더 값이 다른 테스트와 불일치합니다.

이 PR의 다른 테스트들은 "Bearer access-token"을 사용하지만, 여기서는 "Bearer your.jwt.token"을 사용하고 있습니다. 일관성을 위해 통일하는 것이 좋겠습니다.

🔧 수정 제안
-                        .header("Authorization", "Bearer your.jwt.token")
+                        .header("Authorization", "Bearer access-token")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mockMvc.perform(patch("/api/v1/auth/logout")
.header("Authorization", "Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyUEsiOjEsInJvbGVzIjoiUk9MRV9VU0VSIiwiaWF0IjoxNzQwMjQyNjQxLCJleHAiOjE3NDAyNDQ0NDF9.kLSMBLWdvIvrBpGJdOigSKjxMIab0cV06xFjSpwrq70")
.header("Authorization", "Bearer your.jwt.token")
mockMvc.perform(patch("/api/v1/auth/logout")
.header("Authorization", "Bearer access-token")
🤖 Prompt for AI Agents
In
`@src/test/java/ku_rum/backend/domain/auth/presentation/AuthControllerTest.java`
around lines 155 - 156, In AuthControllerTest update the Authorization header
used in the logout request to match the other tests: replace the header value
"Bearer your.jwt.token" in the
mockMvc.perform(patch("/api/v1/auth/logout").header("Authorization", ...)) call
with "Bearer access-token" so the test suite uses a consistent token string
across tests.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/resources/application-test.yml (1)

84-87: ⚠️ Potential issue | 🟡 Minor

accessToken 유효 시간 주석이 실제 값과 불일치

1800000ms는 30분이지만 주석에는 1시간으로 표기되어 있습니다. 테스트 환경이라 실질적 영향은 적지만, 혼동을 방지하기 위해 수정을 권장합니다.

📝 주석 수정 제안
-  accessToken-valid-time: 1800000 # 1시간
+  accessToken-valid-time: 1800000 # 30분
🤖 Fix all issues with AI agents
In `@src/main/resources/application-test.yml`:
- Line 24: Change application-test.yml to avoid leaving test schema behind:
revert ddl-auto: create back to ddl-auto: create-drop (or switch the test
profile datasource to an H2 in-memory JDBC URL) so `@SpringBootTest` integration
tests remain isolated and do not fail on subsequent runs; also update the
inaccurate comment referring to 1800000ms (change "1시간" to "30분" or correct the
numeric unit) so the timeout comment matches the actual value.

@sonarqubecloud
Copy link

@david-parkk david-parkk merged commit 1aa4afe into develop Feb 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restdocs -> OpenAPI JWT 헤더 설정

1 participant