@davoodmehraban89 / VELYQOR / commits / 4c9ed04
Fork 0

Intelligence, Advanced Charting & Trading Platform

test(db): atomic send permit only once and denied after consent revocation

davoodmehraban89 committed Oct 23, 2026 at 02:36 UTC 4c9ed046cc2ac821ff18e6d5f640fb1d8b58355c
1 file changed +13 -1
db/tests/alert_runtime_invariants.sql
+13 -1
@@ -148,6 +148,14 @@ BEGIN
148 result.outbox_id, result.claim_token, t+interval '5 minutes 1 second') THEN
149 RAISE EXCEPTION 'valid leased and consenting recipient denied at egress';
150 END IF;
151 + IF NOT public.alert_notification_begin_egress(
152 + result.outbox_id, result.claim_token, t+interval '5 minutes 1 second') THEN
153 + RAISE EXCEPTION 'first valid send permit not issued';
154 + END IF;
155 + IF public.alert_notification_begin_egress(
156 + result.outbox_id, result.claim_token, t+interval '5 minutes 2 seconds') THEN
157 + RAISE EXCEPTION 'repeated send permit enabled duplicate outbound message';
158 + END IF;
159 IF public.alert_notification_egress_allowed(
160 result.outbox_id, gen_random_uuid(), t+interval '5 minutes 1 second') THEN
161 RAISE EXCEPTION 'wrong lease token authorized message egress';
@@ -202,6 +210,10 @@ BEGIN
210 result.outbox_id, result.claim_token, t+interval '7 minutes 2 seconds') THEN
211 RAISE EXCEPTION 'revoked consent still authorized outbound message';
212 END IF;
213 + IF public.alert_notification_begin_egress(
214 + result.outbox_id, result.claim_token, t+interval '7 minutes 2 seconds') THEN
215 + RAISE EXCEPTION 'revoked consent issued an outbound send permit';
216 + END IF;
217 IF public.alert_notification_egress_allowed(
218 result.outbox_id, gen_random_uuid(), t+interval '7 minutes 2 seconds') THEN
219 RAISE EXCEPTION 'foreign claim permitted outbound message';
@@ -256,7 +268,7 @@ BEGIN
268 ) AS acl
269 WHERE ns.nspname='public' AND p.proname IN
270 ('alert_rule_commit','alert_notification_claim_consented',
259 - 'alert_notification_egress_allowed')
271 + 'alert_notification_egress_allowed','alert_notification_begin_egress')
272 AND acl.grantee=0 AND acl.privilege_type='EXECUTE'
273 ) THEN
274 RAISE EXCEPTION 'unsafe PUBLIC execute grant';