فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(A03): reject direct add put and putRaw with atomic rollback
davoodmehraban89 committed
Oct 19, 2026 at 18:35 UTC
aa7631cd040f92792fc1e076c135f7aa48ab1764
1 file changed
+16
tests/a03-audit-integration.test.mjs
+16
@@ -245,3 +245,19 @@ test('A03 guard: full backup replay of identical audit is accepted', async () =>
245
await StorageService.importAll(snapshot);
246
assert.ok((await AuditService.list()).length >= 1);
247
});
248
+
249
+test('A03: direct audit mutation APIs reject forged records and roll back writes', async () => {
250
+ await setup();
251
+ for (const method of ['add', 'put', 'putRaw']) {
252
+ const id = StorageService.uid('forged_');
253
+ await assert.rejects(StorageService.transaction(['audit_events', 'products'], async tx => {
254
+ await tx.put('products', { id, companyId: company, name: 'rollback' });
255
+ await tx[method]('audit_events', {
256
+ id, companyId: company, actorId: 'forged', eventType: 'journal_posted',
257
+ sourceId: id, commandKey: id, createdByService: true
258
+ });
259
+ }), /ثبت مستقیم رویداد ممیزی/);
260
+ assert.equal(await StorageService.get('products', id), undefined);
261
+ assert.equal(await StorageService.get('audit_events', id), undefined);
262
+ }
263
+});