fix(supabase): V1-2.1 close the second verifier and security findings

Save and submit lock the sheet before the version; change_note length and a
blank FR name answer closed codes; pgTAP for a capability refused to a
factorless account and the five remaining historical-sheet RPC refusals.
This commit is contained in:
bchanot committed 2026-10-28 18:44:00 +01:00
1 parent 4a829416c6
commit 961995804a
4 files changed
+47 -10

No files matched your search

+19 -1
View File
@@ -8,7 +8,7 @@
-- ids created here, so the file also runs on a stack that already holds
-- sheets, rounds or a working copy.
begin;
select plan(78);
select plan(85);
-- Accounts: O owner, E admin + editor + publisher, V reviewer, V2 admin +
-- editor + reviewer (an author of a later round), V3 reviewer, R reader.
@@ -502,6 +502,17 @@ select throws_ok($$ select public.delete_sheet_asset(pg_temp.id('s13.asset')) $$
select throws_ok($$ select public.delete_sheet_asset((select id from public.anatomical_sheet_assets
where sheet_id = '503dc301-a8b1-50d4-9e44-0919b2fc2916' limit 1)) $$,
'42501', 'sheet.historical_read_only', 'the historical sheet''s drawing row is never deleted');
select throws_ok($$ select public.delete_anatomical_sheet('503dc301-a8b1-50d4-9e44-0919b2fc2916') $$,
'42501', 'sheet.historical_read_only', 'the historical sheet is never deleted through the RPC');
select throws_ok($$ select public.delete_sheet_version(pg_temp.id('h.v')) $$,
'42501', 'sheet.historical_read_only', 'the historical draft is never deleted through the RPC');
select throws_ok($$ select public.restore_anatomical_sheet('503dc301-a8b1-50d4-9e44-0919b2fc2916') $$,
'42501', 'sheet.historical_read_only', 'the historical sheet is never restored through the RPC');
select throws_ok($$ select public.create_sheet_draft('503dc301-a8b1-50d4-9e44-0919b2fc2916', null, 'x') $$,
'42501', 'sheet.historical_read_only', 'no draft is opened on the historical sheet');
select throws_ok($$ select public.confirm_sheet_asset_upload((select id from public.anatomical_sheet_assets
where sheet_id = '503dc301-a8b1-50d4-9e44-0919b2fc2916' limit 1)) $$,
'42501', 'sheet.historical_read_only', 'an editor never confirms a drawing of the historical sheet');
select throws_ok($$ select public.create_official_sheet('r17-s13', pg_temp.doc(null, 'reviewed')) $$,
'P0001', 'sheet.slug_taken', 'a slug already used by an official sheet');
select throws_ok($$ select public.create_official_sheet('Bad Slug', pg_temp.doc(null, 'reviewed')) $$,
@@ -522,6 +533,13 @@ select throws_ok($$ select public.save_sheet_draft(pg_temp.id('s13.v'), 1,
select throws_ok($$ select public.save_sheet_draft(pg_temp.id('s13.v'), 1,
jsonb_set(pg_temp.doc(pg_temp.id('s13.asset'), 'reviewed'), '{schema_version}', '3'), 'x') $$,
'23514', 'document.schema_version', 'save refuses another schema version');
select throws_ok($$ select public.save_sheet_draft(pg_temp.id('s13.v'), 1,
jsonb_set(pg_temp.doc(pg_temp.id('s13.asset'), 'reviewed'), '{description,fr}', '"n"'), repeat('x', 1001)) $$,
'P0001', 'invalid_input', 'a change note over 1 000 characters is invalid input, not a raw constraint error');
insert into pg_temp.k select 'blank', public.create_official_sheet('r17-blank',
jsonb_set(pg_temp.doc(null, 'reviewed'), '{name,fr}', '" "'));
select is((select name from public.anatomical_sheets where id = pg_temp.id('blank')), 'R horse',
'a blank FR name falls back to the EN name at creation');
select throws_ok($$ select public.create_sheet_draft(pg_temp.id('m3'), null, 'x') $$,
'P0001', 'draft.exists', 'one draft per sheet');
select public.publish_sheet_version(pg_temp.id('m3b.r'));