feat(user): make use case classes internal and add test configurations#55
Conversation
|
Warning Review limit reached
More reviews will be available in 39 minutes and 13 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (21)
📝 WalkthroughWalkthroughSeven user use case implementation classes in the ChangesUser Use Case Visibility, Logic Fix, and Integration Tests
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
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. 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: 3
🧹 Nitpick comments (1)
bootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/user/RequestUserPasswordChangeUseCaseTest.kt (1)
93-94: ⚡ Quick winAssert audit attribution, not only audit count.
Line 93 only checks
auditLogs.size. Add an assertion that the emitted log’sperformedByUserIdequalsadminIdto lock in the requestorId regression fix.🤖 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 `@bootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/user/RequestUserPasswordChangeUseCaseTest.kt` around lines 93 - 94, The test in RequestUserPasswordChangeUseCaseTest currently only verifies the count of audit logs (size shouldBe 1) but does not validate the content of the emitted audit log. Add an additional assertion after the size check to verify that the first audit log entry in testLogger.auditLogs has its performedByUserId property equal to adminId. This ensures the requestorId regression fix is properly validated in the test.
🤖 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
`@bootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/config/TestPasswordHasher.kt`:
- Around line 7-14: The issue is that MessageDigest is mutable and not
thread-safe; keeping it as a class field (digest) in this Spring singleton
causes nondeterministic hashes when tests run concurrently. Remove the digest
field and instead create a new MessageDigest instance directly inside the hash
method each time it's called using MessageDigest.getInstance("SHA-256"), so that
each invocation gets its own fresh instance rather than sharing the mutable
state across calls in the hash and verify methods.
In
`@bootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/config/TestUserIntegrationConfig.kt`:
- Around line 39-42: The testLogger() bean method in
TestUserIntegrationConfig.kt declares a return type of Logger (interface), but
tests inject TestLogger (concrete class) directly, which causes Spring
autowiring failures since the framework does not guarantee concrete class
injection when `@Bean` declares an interface return type. Change the return type
of the testLogger() method from Logger to TestLogger to enable reliable
autowiring by concrete class.
In `@bootstrap/src/test/resources/application-test.yml`:
- Line 19: The master-key property in application-test.yml is hardcoded with a
real-looking cryptographic value, creating security and scanner noise concerns.
Replace the hardcoded key value with a clearly non-production placeholder string
(such as "test-key" or "dev-test-key") that is obviously not suitable for
production. Additionally, ensure the application is configured to support
environment variable overrides for the app.security.master-key property so that
the actual test key can be injected via environment configuration rather than
committed to version control.
---
Nitpick comments:
In
`@bootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/user/RequestUserPasswordChangeUseCaseTest.kt`:
- Around line 93-94: The test in RequestUserPasswordChangeUseCaseTest currently
only verifies the count of audit logs (size shouldBe 1) but does not validate
the content of the emitted audit log. Add an additional assertion after the size
check to verify that the first audit log entry in testLogger.auditLogs has its
performedByUserId property equal to adminId. This ensures the requestorId
regression fix is properly validated in the test.
🪄 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: e0a3a2ac-982c-4273-bf04-4c1d2e33976e
📒 Files selected for processing (26)
application/src/main/kotlin/com/alleslocker/backend/application/user/usecase/ActivateUserUseCaseImpl.ktapplication/src/main/kotlin/com/alleslocker/backend/application/user/usecase/AdminResetPasswordUserUseCaseImpl.ktapplication/src/main/kotlin/com/alleslocker/backend/application/user/usecase/ChangeUserRoleUseCaseImpl.ktapplication/src/main/kotlin/com/alleslocker/backend/application/user/usecase/CreateUserUseCaseImpl.ktapplication/src/main/kotlin/com/alleslocker/backend/application/user/usecase/DeactivateUserUseCaseImpl.ktapplication/src/main/kotlin/com/alleslocker/backend/application/user/usecase/GetUsersPagedUseCaseImpl.ktapplication/src/main/kotlin/com/alleslocker/backend/application/user/usecase/RequestUserPasswordChangeUseCaseImpl.ktapplication/src/main/kotlin/com/alleslocker/backend/application/user/usecase/ResetPasswordUserUseCaseImpl.ktbootstrap/build.gradlebootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/config/TestLogger.ktbootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/config/TestPasswordHasher.ktbootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/config/TestPresenter.ktbootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/config/TestUserIntegrationConfig.ktbootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/user/ActivateUserUseCaseTest.ktbootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/user/AdminResetPasswordUserUseCaseTest.ktbootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/user/ChangeUserRoleUseCaseTest.ktbootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/user/CreateUserUseCaseTest.ktbootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/user/DeactivateUserUseCaseTest.ktbootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/user/EditUserUseCaseTest.ktbootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/user/GetUserUseCaseTest.ktbootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/user/GetUsersPagedUseCaseTest.ktbootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/user/LoginUserUseCaseTest.ktbootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/user/RequestUserPasswordChangeUseCaseTest.ktbootstrap/src/test/kotlin/com/alleslocker/backend/bootstrap/integration/user/ResetPasswordUserUseCaseTest.ktbootstrap/src/test/resources/application-test.ymlweb/src/main/kotlin/com/alleslocker/backend/web/user/controller/UserController.kt
💤 Files with no reviewable changes (1)
- web/src/main/kotlin/com/alleslocker/backend/web/user/controller/UserController.kt
Summary by CodeRabbit
Refactor
Tests
Chores