diff --git a/.claude/tasks/contracts/2026-11-02-v1-2-5-admin-catalogue.md b/.claude/tasks/contracts/2026-11-02-v1-2-5-admin-catalogue.md index 2372f630..7ee14a98 100644 --- a/.claude/tasks/contracts/2026-11-02-v1-2-5-admin-catalogue.md +++ b/.claude/tasks/contracts/2026-11-02-v1-2-5-admin-catalogue.md @@ -66,3 +66,23 @@ reopened. The editor (V1-2.6), the review and publication screens (V1-2.7), deprecation and archive actions (V1-2.7), the equine working copy content work (V1-2.8), any DEV operation (§16.11), recovery runbook rehearsal (V1-2.9). + +## CLARIFICATIONS (after the fresh reviews of 2026-11-02 on 3d2b5a5) + +- Skips: `apps/app/e2e/shell/admin.spec.ts` skips A0, A1 and S1 on the `chromium-375` project only (three + `test.skip(isPhone(info))`). These journeys run on desktop; every admin page at 375 px is covered by the + unskipped screens test and the access-per-right test. Deliberate, not a reduction. +- C4 gap fixed: `/app/admin/sheets/new` shows « Accès non autorisé » to any account without an active + `sheet_editor` grant (display rule; the server refuses creation anyway); unit tests for a reviewer, a + publisher and an owner without the capability. +- Security MEDIUM fixed: M7 restates the grants of the redefined `get_sheet_version`. LOW fixed: the e2e + enrolment check no longer prints the throwaway setup key on failure. +- Run evidence for the criteria a read-only verifier cannot run (orchestrator runs, sandbox only): + C1 `mfa-behaviour.sandbox.ts` 10/10 (twice by the executor, once on a fresh install); C9 sandbox fresh + install and upgrade from M6, pgTAP 1941 pass, types match (after the fixes: fresh install, 1941 pass, types + match); C11 `pnpm check:all` all checks passed on 4f6c0ba code (= 3d2b5a5 code), `pnpm e2e:shell` 108 + passed / 6 skipped (slice J run, and again after the fixes), unit core-wasm 66, supabase 148, app 653. +- Tracked, not fixed: the P1 catalogue journey on `chromium-375` failed once in three full `e2e:shell` runs + (search typed, 8 cards instead of 1, FR and EN in the same run); passed alone twice and in the next full + run; cause not found, page snapshot overwritten. pgTAP 014 (« nine species ») fails on a stack where the + shell suite already ran (test species left behind): run `test-db` before `e2e:shell` on one stack. diff --git a/apps/app/e2e/shell/admin.spec.ts b/apps/app/e2e/shell/admin.spec.ts index 19984a9f..b5472469 100644 --- a/apps/app/e2e/shell/admin.spec.ts +++ b/apps/app/e2e/shell/admin.spec.ts @@ -113,7 +113,8 @@ async function enrolFromPage( box.getByRole('img', { name: dict['mfa.enrol.qr_alt'] }), ).toBeVisible() const secret = (await box.locator('code').textContent())?.trim() ?? '' - expect(secret).toMatch(/^[A-Z2-7]{16,}$/) + // A boolean, so a failure report never prints the secret. + expect(/^[A-Z2-7]{16,}$/.test(secret), 'base32 setup key shown').toBe(true) await enterCode(box, dict, secret) await expect(page.getByText(dict['mfa.enrol.done'])).toBeVisible() return secret diff --git a/apps/app/src/app/routes/app/admin/AdminSheetCreateRoute.tsx b/apps/app/src/app/routes/app/admin/AdminSheetCreateRoute.tsx index fbba95f8..db8e6a5d 100644 --- a/apps/app/src/app/routes/app/admin/AdminSheetCreateRoute.tsx +++ b/apps/app/src/app/routes/app/admin/AdminSheetCreateRoute.tsx @@ -18,6 +18,7 @@ import Input from '@/components/ui/Input' import Notice from '@/components/ui/Notice' import Select from '@/components/ui/Select' import { failureMessage, speciesName } from '@/admin/labels' +import { useAdminPermissions } from '@/admin/permissions' import { isRightsRefusal, useAdminQuery } from '@/admin/useAdminQuery' import { parseSheet, @@ -93,6 +94,7 @@ export default function AdminSheetCreateRoute() { const heading = usePageHeading() const navigate = useNavigate() const locale = useLocaleStore((s) => s.locale) + const { editor } = useAdminPermissions() const species = useAdminQuery('species', listCatalogSpecies) const [values, setValues] = useState(EMPTY) const [slugEdited, setSlugEdited] = useState(false) @@ -108,9 +110,13 @@ export default function AdminSheetCreateRoute() { if (first) document.getElementById(fieldId(first))?.focus() }, [errorRound, errors]) + // A display rule like the « Nouvelle fiche » button: a reviewer or a + // publisher reaching the address is not offered the form. The server still + // refuses the creation to anyone without the editor capability. if ( - species.state.status === 'error' && - isRightsRefusal(species.state.failure) + !editor || + (species.state.status === 'error' && + isRightsRefusal(species.state.failure)) ) return diff --git a/apps/app/tests/unit/routes.admin.test.tsx b/apps/app/tests/unit/routes.admin.test.tsx index d47c3f83..a2c86f16 100644 --- a/apps/app/tests/unit/routes.admin.test.tsx +++ b/apps/app/tests/unit/routes.admin.test.tsx @@ -642,6 +642,19 @@ describe('Official sheets list (H1)', () => { }) describe('Sheet creation (A1)', () => { + it.each([ + ['a reviewer', [grant('sheet_reviewer')], []], + ['a publisher', [grant('sheet_publisher')], []], + ['an owner without the editor capability', [], ['owner']], + ] as const)('offers no form to %s reaching the address', async (_, grants, roles) => { + mount('/app/admin/sheets/new', [...grants], [...roles]) + expect( + await screen.findByRole('heading', { name: fr['access_denied.title'] }), + ).toBeInTheDocument() + expect(screen.queryByLabelText('Espèce')).toBeNull() + expect(rpcArgs('create_official_sheet')).toEqual([]) + }) + it('proposes a slug from the French name', () => { expect(proposeSlug('Chien : squelette et rachis ')).toBe( 'chien-squelette-et-rachis', diff --git a/supabase/migrations/20261102100000_sheet_admin_reads.sql b/supabase/migrations/20261102100000_sheet_admin_reads.sql index ad99bf13..81dd9df8 100644 --- a/supabase/migrations/20261102100000_sheet_admin_reads.sql +++ b/supabase/migrations/20261102100000_sheet_admin_reads.sql @@ -244,3 +244,6 @@ revoke all on function public.list_official_sheets_admin() from public, anon, se revoke all on function public.get_official_sheet_admin(uuid) from public, anon, service_role; grant execute on function public.list_official_sheets_admin() to authenticated; grant execute on function public.get_official_sheet_admin(uuid) to authenticated; +-- Kept by `create or replace`, stated again so this file stands alone. +revoke all on function public.get_sheet_version(uuid) from public, anon, service_role; +grant execute on function public.get_sheet_version(uuid) to authenticated;