CREATE EXTENSION pg_htmldoc;
-- pg_htmldoc.c gates the pg_write_server_files-equivalent write path,
-- htmldoc_addhtml(), and the whitelist-bypass "privileged" flag entirely on
-- superuser() (see require_superuser()/htmldoc_addfile()/htmldoc_addurl()
-- in pg_htmldoc.c) -- no predefined-role membership is consulted at all.
-- This session (pg_htmldoc_test_orig_user, captured below) is a superuser,
-- so it exercises the privileged path directly, with no role setup needed.
-- One additional role, genuinely non-superuser, is used below for the
-- unprivileged/whitelist path -- it needs LOGIN, since those tests need to
-- \c into it directly (ALTER ROLE ... SET only takes effect for a new
-- connection as that role, not retroactively via SET ROLE in an
-- already-open session).
SELECT current_user AS pg_htmldoc_test_orig_user \gset
CREATE ROLE htmldoc_test_none LOGIN;
--
-- No document queued: convert2pdf()/convert2pdf(file)/convert2ps()/
-- convert2ps(file) all check for a queued document before anything
-- else -- before even require_superuser() or the NULL-argument check --
-- so calling any of them with nothing queued yet must fail with the
-- same "!document" internal error regardless of call form.
--
SELECT convert2pdf();
SELECT convert2pdf('/tmp/pg_htmldoc_test_no_document.pdf');
SELECT convert2ps();
SELECT convert2ps('/tmp/pg_htmldoc_test_no_document.ps');
--
-- Without superuser, every entry point must be denied by default (no
-- pg_htmldoc.whitelist is configured for htmldoc_test_none yet): the
-- render pipeline can resolve
/
/