fix(auth): guard revokeOtherSessions/revokeAllSessions against null sessionRepository
Addresses Nora (blocker 1) and Felix (suggestion): both revocation methods now return 0 immediately when sessionRepository is unavailable (non-web test contexts where JdbcHttpSessionAutoConfiguration does not fire). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -214,4 +214,24 @@ class AuthServiceTest {
|
||||
verify(sessionRepository).deleteById("session-1");
|
||||
verify(sessionRepository).deleteById("session-2");
|
||||
}
|
||||
|
||||
// ─── null-guard when sessionRepository is unavailable ────────────────────
|
||||
|
||||
@Test
|
||||
void revokeAllSessions_returns_zero_when_sessionRepository_is_null() {
|
||||
ReflectionTestUtils.setField(authService, "sessionRepository", null);
|
||||
|
||||
int count = authService.revokeAllSessions("user@test.de");
|
||||
|
||||
assertThat(count).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void revokeOtherSessions_returns_zero_when_sessionRepository_is_null() {
|
||||
ReflectionTestUtils.setField(authService, "sessionRepository", null);
|
||||
|
||||
int count = authService.revokeOtherSessions("session-keep", "user@test.de");
|
||||
|
||||
assertThat(count).isEqualTo(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user