fix: audit target is the record acted on, never a typed username; guard retention

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-11-30 17:16:29 +08:00
1 parent 81ef54f996
commit 7aa5c4b921
10 files changed
+61 -7

No files matched your search

@@ -93,6 +93,10 @@ class AppAccessAspectAuditTest {
@Audited(skip = true)
public void match() {
}
@Audited(target = false)
public void unlock() {
}
}
@BeforeEach
@@ -180,6 +184,27 @@ class AppAccessAspectAuditTest {
assertThat(e.getChanges()).isNull();
}
@Test
void target_isTheLastPathVariable() throws Throwable {
Map<String, String> vars = new LinkedHashMap<>();
vars.put("eventUuid", "E1");
vars.put("eventLeadUuid", "L9");
req.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, vars);
handler(AdminUserController.class, "update");
admin(1L);
call();
assertThat(published().getTargetId()).isEqualTo("L9");
}
@Test
void target_isNotRecordedWhenTheHandlerOptsOut() throws Throwable {
req.setMethod("POST");
handler(AdminUserController.class, "unlock");
admin(1L);
call();
assertThat(published().getTargetId()).isNull();
}
@Test
void module_fallsBackToClassLevel() throws Throwable {
handler(AdminUserController.class, "classModule");