[FEAT] 사용자 도서 접근 권한 정책 추가#277
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough도서 접근 권한 검증을 전담하는 Changes도서 접근 권한 검증 통합
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/test/java/app/nook/book/service/BookAccessServiceTest.java (1)
16-117: ⚡ Quick winnull 사용자에 대한 엣지 케이스 테스트를 고려하세요.
assertCanView는 익명 사용자(null)에 대한 테스트를 포함하고 있지만,assertCanAddToLibrary와assertCanUpdate는 해당 엣지 케이스를 테스트하지 않습니다. 일관성 있는 테스트 커버리지를 위해 두 메서드에도 null 사용자 시나리오를 추가하는 것을 고려해보세요.📝 추가 가능한 테스트 케이스 예시
`@Test` `@DisplayName`("로그인 사용자가 없으면 서재 등록 권한을 차단한다") void assertCanAddToLibrary_anonymousUser_fail() { Book book = createBook(SourceType.USER, 1L); assertThatThrownBy(() -> bookAccessService.assertCanAddToLibrary(null, book)) .isInstanceOf(CustomException.class) .extracting(exception -> ((CustomException) exception).getErrorCode()) .isEqualTo(BookErrorCode.BOOK_ACCESS_DENIED); } `@Test` `@DisplayName`("로그인 사용자가 없으면 수정 권한을 차단한다") void assertCanUpdate_anonymousUser_fail() { Book book = createBook(SourceType.USER, 1L); assertThatThrownBy(() -> bookAccessService.assertCanUpdate(null, book)) .isInstanceOf(CustomException.class) .extracting(exception -> ((CustomException) exception).getErrorCode()) .isEqualTo(BookErrorCode.BOOK_NOT_OWNED); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/test/java/app/nook/book/service/BookAccessServiceTest.java` around lines 16 - 117, Add null-user edge-case tests for assertCanAddToLibrary and assertCanUpdate to match assertCanView coverage: create a Book via createBook(SourceType.USER, 1L) and call bookAccessService.assertCanAddToLibrary(null, book) expecting a CustomException with error code BookErrorCode.BOOK_ACCESS_DENIED, and call bookAccessService.assertCanUpdate(null, book) expecting a CustomException with error code BookErrorCode.BOOK_NOT_OWNED; name the tests e.g. assertCanAddToLibrary_anonymousUser_fail and assertCanUpdate_anonymousUser_fail to mirror existing test naming.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/test/java/app/nook/book/service/BookAccessServiceTest.java`:
- Around line 63-83: Add a test in BookAccessServiceTest to verify ALADIN books
can be added to a user's library: create a User with createUser(...), create an
ALADIN Book via createBook(SourceType.ALADIN, <anyOwnerId>), then call
bookAccessService.assertCanAddToLibrary(user, book) and assert it does not throw
(use assertThatCode(...).doesNotThrowAnyException()). Ensure the new test
mirrors naming/style of existing tests (e.g., display name "ALADIN 도서는 서재 등록 권한을
허용한다") and lives alongside the other assertCanAddToLibrary tests.
---
Nitpick comments:
In `@src/test/java/app/nook/book/service/BookAccessServiceTest.java`:
- Around line 16-117: Add null-user edge-case tests for assertCanAddToLibrary
and assertCanUpdate to match assertCanView coverage: create a Book via
createBook(SourceType.USER, 1L) and call
bookAccessService.assertCanAddToLibrary(null, book) expecting a CustomException
with error code BookErrorCode.BOOK_ACCESS_DENIED, and call
bookAccessService.assertCanUpdate(null, book) expecting a CustomException with
error code BookErrorCode.BOOK_NOT_OWNED; name the tests e.g.
assertCanAddToLibrary_anonymousUser_fail and assertCanUpdate_anonymousUser_fail
to mirror existing test naming.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1706fa68-904d-4bac-beaa-98dbef54441a
📒 Files selected for processing (7)
src/main/java/app/nook/book/exception/BookErrorCode.javasrc/main/java/app/nook/book/service/BookAccessService.javasrc/main/java/app/nook/book/service/BookService.javasrc/main/java/app/nook/library/service/LibraryCommandService.javasrc/test/java/app/nook/book/service/BookAccessServiceTest.javasrc/test/java/app/nook/book/service/BookServiceTest.javasrc/test/java/app/nook/library/service/LibraryServiceTest.java
|
📄 작업 내용 요약
BOOK_ACCESS_DENIED반환📎 Issue 번호
✅ 작업 목록
📝 기타 참고사항
Summary by CodeRabbit
릴리스 노트
새로운 기능
테스트