feat(core-audit): NoopAuditLog impl

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-11 16:11:52 +02:00
parent 12a8391944
commit 17996e9347
2 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import { describe, it, expect } from "vitest";
import { NoopAuditLog } from "./noop-audit-log";
import type { AuditEntry } from "@repo/core-shared/audit";
describe("NoopAuditLog", () => {
const sample: AuditEntry = {
actorId: "user_1",
actorType: "user",
actorRoles: [],
action: "VIEW",
resource: { type: "articles", id: "1" },
at: new Date(),
scope: { feature: "blog", environment: "test", tenant: "default" },
from: { ipTruncated: "10.0.0.0", userAgent: "test" },
containsPii: false,
outcome: "success",
};
it("record() is a no-op that does not throw", async () => {
const log = new NoopAuditLog();
await expect(log.record(sample)).resolves.toBeUndefined();
});
it("eraseSubject() is a no-op that does not throw", async () => {
const log = new NoopAuditLog();
await expect(log.eraseSubject("user_1", "pseudonymize")).resolves.toBeUndefined();
await expect(log.eraseSubject("user_1", "delete")).resolves.toBeUndefined();
});
});

View File

@@ -0,0 +1,11 @@
import type { AuditEntry } from "@repo/core-shared/audit";
import type { IAuditLog } from "./audit-log.interface";
export class NoopAuditLog implements IAuditLog {
async record(_entry: AuditEntry): Promise<void> {
// intentional no-op
}
async eraseSubject(_actorId: string, _mode: "pseudonymize" | "delete"): Promise<void> {
// intentional no-op
}
}