feat: complete TASK-WP1-06 audit immutability

This commit is contained in:
suyx
2026-07-28 19:29:24 +08:00
parent 2358f97e5c
commit 59e566885b
9 changed files with 487 additions and 125 deletions
@@ -152,12 +152,14 @@ describe("TDD-WP1-DEL-002-anonymous-retention", () => {
const harness = await createRegisteredHarness("retention@example.invalid");
const userId = harness.completed.user.userId;
const csrfToken = harness.service.issueUserCsrfToken(harness.completed.sessionToken);
const accessExpiresAt = fixedNow + 30_000;
const accessActorRef = randomUUID();
const accessTargetRef = randomUUID();
const accessExpiresAt = fixedNow + 180 * 86_400_000;
harness.service.database.prepare(`
INSERT INTO private_content_access_logs (
log_id, actor_ref, subject_ref, target_ref, content_type, occurred_at, expires_at
) VALUES (?, ?, ?, ?, 'image', ?, ?)
`).run(randomUUID(), "admin-fixture", userId, "private-target-fixture", fixedNow - 1_000, accessExpiresAt);
`).run(randomUUID(), accessActorRef, userId, accessTargetRef, fixedNow, accessExpiresAt);
const sent = await harness.service.sendAccountDeletionCode({ csrfToken, sessionToken: harness.completed.sessionToken });
harness.service.completeAccountDeletion({
@@ -182,12 +184,12 @@ describe("TDD-WP1-DEL-002-anonymous-retention", () => {
});
expect(JSON.stringify(anonymous)).not.toContain(harness.email);
expect(JSON.stringify(anonymous)).not.toContain(userId);
expect(JSON.stringify(anonymous)).not.toContain("private-target-fixture");
expect(JSON.stringify(anonymous)).not.toContain(accessTargetRef);
const access = harness.service.database.prepare("SELECT * FROM private_content_access_logs").get();
expect(access).toMatchObject({ actor_ref: "admin-fixture", expires_at: accessExpiresAt });
expect(access).toMatchObject({ actor_ref: accessActorRef, expires_at: accessExpiresAt });
expect(access.subject_ref).not.toBe(userId);
expect(access.target_ref).not.toBe("private-target-fixture");
expect(access.target_ref).not.toBe(accessTargetRef);
expect(access.subject_ref).not.toBe(anonymous[0].anonymous_subject_id);
writeEvidence("DADA_EVIDENCE_DIR_RETENTION", "db-diff.json", {