test: BannerService/S3Service 단위 테스트 추가 + 이미지 업로드 크래시 버그 2건 수정 - #224
Conversation
BannerService 2개, S3Service.uploadImage 7개, 총 9개 신규 테스트. 테스트 작성 중 발견해서 수정한 버그 (S3Service.getFileExtension): 1. 파일명이 null이면 length() 호출에서 NPE → 500. null/빈 문자열 체크 추가. 2. 파일명에 "."가 없으면 lastIndexOf가 -1을 반환하고 그 값 그대로 substring(-1)을 호출해 StringIndexOutOfBoundsException → 500. "."가 없는 경우를 먼저 걸러내도록 수정. 둘 다 원래는 "잘못된 이미지 파일입니다"(400/404)로 처리됐어야 할 케이스가 서버 에러로 새어나가고 있었음. ## 별도로 확인만 하고 고치지 않은 것 S3Service.deleteFile()의 `imageUrl.substring(49)`는 폴더명/버킷명 길이에 따라 늘 달라지는 값이라 하드코딩된 49는 구조적으로 항상 맞을 수 없음. 다만 이 메서드를 실제로 호출하는 곳이 코드베이스 전체에 없어(dead code) 지금 당장 영향은 없음. 실제 URL 포맷을 확인 없이 숫자만 바꾸는 건 오히려 위험해서, 이번엔 고치지 않고 플래그만 해둠 — deleteFile을 실제로 쓰기 전에 반드시 점검 필요.
|
Warning Review limit reached
Next review available in: 39 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
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 |
작업 배경
BannerService,S3Service에 단위 테스트 추가.S3Service는AmazonS3가 생성자 주입돼있어 (Auth 계열과 달리) 순수 단위 테스트가 가능했음.변경 사항
S3Service.getFileExtensionBannerServiceTest,S3ServiceTest발견해서 수정한 버그
S3Service.uploadImage가 업로드 파일명 검증 단계에서 두 가지 케이스에 500을 냈음:null이면fileName.length()에서 NPElastIndexOf가 -1을 반환하고 그대로substring(-1)을 호출해StringIndexOutOfBoundsException둘 다 원래 "잘못된 이미지 파일입니다"(400/404)로 처리됐어야 할 케이스가 서버 에러로 새어나가고 있었음.
S3Service.deleteFile()의imageUrl.substring(49)는 폴더명/버킷명 길이에 따라 항상 값이 달라지는데 49로 하드코딩돼있어 구조적으로 항상 맞을 수 없음. 다만 코드베이스 전체에서 이 메서드를 실제로 호출하는 곳이 없어(dead code) 지금 당장 영향은 없음. 실제 S3 URL 포맷 확인 없이 숫자만 바꾸는 건 오히려 위험해서 이번엔 손대지 않음 — 나중에 deleteFile을 실제로 연결해서 쓰기 전에 반드시 점검 필요.영향 범위
검증 매트릭스
활성_배너를_정렬된_순서_그대로_0부터_인덱싱해서_반환한다•
활성_배너가_없으면_빈_목록을_반환한다정상_업로드•
대문자_확장자•
지원하지_않는_확장자•
스트림_읽기_실패파일명이_null•
파일명이_빈문자열•
확장자가_없는_파일명Test Plan
./gradlew build전체(ServerApplicationTests 포함) 통과 확인🤖 Generated with Claude Code