Conversation
- jwt 토큰 제거 - unit 테스트 공통 mock 상속 처리 - 모든 restdocs test unit test 전환 - 불필요한 테스트 제거
|
Labeler has applied any labels matching special text in your title and description. |
Walkthrough테스트 인프라에 새 기본 지원 클래스 Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 4❌ Failed checks (2 warnings, 2 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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. Comment |
Test Results 36 files 36 suites 12s ⏱️ Results for commit c40f016. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
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 | 🟡 Minor3개 테스트 메서드에서 Authorization 헤더 토큰이 갱신되지 않았습니다.
sendFriendRequest와acceptFriendRequest는"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: 테스트 클래스명FcmAlarmControllerTest를AlarmControllerTest또는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.JsonType→JsonFieldType으로 통일을 권장합니다.
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: 테스트 클래스 패키지 위치 확인 필요
BookmarkControllerTest는ku_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"으로 일관되게 적용되었습니다. 다만 변경되지 않은 일부 테스트 메서드(searchPlaceLine 329,savePlaceSearchKeywordLine 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)으로 선언되어 있으며, 현재AuthControllerTest와CollegeQueryControllerTest두 곳에서 동일하게 중복되어 있습니다. 두 테스트 클래스 모두RestDocsUnitTestSupport를 상속하므로, 이 공통 MockBean을 기본 클래스에 추가하거나 import 문을 사용하여 코드 중복을 줄일 수 있습니다.
src/test/java/ku_rum/backend/domain/auth/presentation/AuthControllerTest.java
Outdated
Show resolved
Hide resolved
| mockMvc.perform(patch("/api/v1/auth/logout") | ||
| .header("Authorization", "Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyUEsiOjEsInJvbGVzIjoiUk9MRV9VU0VSIiwiaWF0IjoxNzQwMjQyNjQxLCJleHAiOjE3NDAyNDQ0NDF9.kLSMBLWdvIvrBpGJdOigSKjxMIab0cV06xFjSpwrq70") | ||
| .header("Authorization", "Bearer your.jwt.token") |
There was a problem hiding this comment.
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.
| 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.
There was a problem hiding this comment.
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 | 🟡 MinoraccessToken 유효 시간 주석이 실제 값과 불일치
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.
|



#️⃣ 연관된 이슈
closes #321
📝작업 내용
작업 상세 내용
💬리뷰 요구사항
Summary by CodeRabbit
릴리스 노트
Tests
Chores