سامانه صدور فاکتور و حسابداری
test: cover cross-actor idempotency replay
davoodmehraban89 committed
Oct 2, 2026 at 01:14 UTC
528763ce72e7c8adfd50598e9e32b01cb5b694ad
1 file changed
+16
supabase/tests/request_wave1_legacy_transition_security.sql
renamed
+16
@@ -29,7 +29,7 @@ select * from public.request_transition_instance(
29
(select v from wave1_ids where k='legacy_instance'),
30
'approve',1,'wave1-transition-legacy-0001','first authorized transition'
31
);
32
+-- Authorized same-actor/same-action replay remains stable even though expected revision is stale.
33
select * from public.request_transition_instance(
34
(select v from wave1_ids where k='legacy_instance'),
35
'approve',1,'wave1-transition-legacy-0001','authorized retry'
@@ -51,6 +51,21 @@ begin
51
end;
52
end $$;
53
54
+-- Possessing approval capability is still insufficient to replay another actor's
55
+-- idempotency evidence. The replay identity itself is part of the authorization contract.
56
+select set_config('request.jwt.claim.capabilities','read,approve',false);
57
+do $$
58
+begin
59
+ begin
60
+ perform * from public.request_transition_instance(
61
+ (select v from wave1_ids where k='legacy_instance'),
62
+ 'approve',1,'wave1-transition-legacy-0001','cross-actor replay'
63
+ );
64
+ raise exception 'F-409: cross-actor idempotent replay unexpectedly succeeded';
65
+ exception when insufficient_privilege then null;
66
+ end;
67
+end $$;
68
+
69
-- F-410: even a fully-authorized approver cannot bypass D3 step/quorum state
70
-- through the legacy transition endpoint.
71
select set_config('request.jwt.claim.sub','11111111-1111-1111-1111-111111111111',false);