Skip to content

Commit e5df5ab

Browse files
committed
test(outbox): deepen ADMIN destructive-authority RED
1 parent 2a2884a commit e5df5ab

1 file changed

Lines changed: 28 additions & 17 deletions

File tree

tests/smoke_context_lifecycle_outbox_role_admin_destructive_authority.sh

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,31 +64,39 @@ INSERT INTO public.llm_context_lifecycle_outbox (
6464
6565
CREATE ROLE cwl_llm_batch_outbox_destructive_leaf NOLOGIN
6666
NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS;
67-
CREATE ROLE cwl_llm_batch_outbox_destructive_bridge NOLOGIN
67+
CREATE ROLE cwl_llm_batch_outbox_destructive_inner NOLOGIN
6868
NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS;
69-
CREATE ROLE cwl_llm_batch_outbox_destructive_admin LOGIN
69+
CREATE ROLE cwl_llm_batch_outbox_destructive_outer NOLOGIN
70+
NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS;
71+
CREATE ROLE cwl_llm_batch_outbox_destructive_login LOGIN
7072
NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS;
7173
7274
GRANT USAGE ON SCHEMA public
7375
TO cwl_llm_batch_outbox_destructive_leaf,
74-
cwl_llm_batch_outbox_destructive_bridge,
75-
cwl_llm_batch_outbox_destructive_admin;
76+
cwl_llm_batch_outbox_destructive_inner,
77+
cwl_llm_batch_outbox_destructive_outer,
78+
cwl_llm_batch_outbox_destructive_login;
79+
GRANT SELECT, INSERT ON public.llm_context_lifecycle_outbox
80+
TO cwl_llm_batch_outbox_destructive_login;
7681
GRANT TRUNCATE ON public.llm_context_lifecycle_outbox
7782
TO cwl_llm_batch_outbox_destructive_leaf;
7883
GRANT cwl_llm_batch_outbox_destructive_leaf
79-
TO cwl_llm_batch_outbox_destructive_bridge
84+
TO cwl_llm_batch_outbox_destructive_inner
8085
WITH INHERIT FALSE, SET TRUE;
81-
GRANT cwl_llm_batch_outbox_destructive_bridge
82-
TO cwl_llm_batch_outbox_destructive_admin
86+
GRANT cwl_llm_batch_outbox_destructive_inner
87+
TO cwl_llm_batch_outbox_destructive_outer
8388
WITH ADMIN TRUE, INHERIT FALSE, SET FALSE;
89+
GRANT cwl_llm_batch_outbox_destructive_outer
90+
TO cwl_llm_batch_outbox_destructive_login
91+
WITH INHERIT FALSE, SET TRUE;
8492
SQL
8593

86-
initial_set="$(
94+
initial_inner_set="$(
8795
docker exec "${container}" psql -U postgres -d postgres -Atqc \
88-
"SELECT pg_catalog.pg_has_role('cwl_llm_batch_outbox_destructive_admin', 'cwl_llm_batch_outbox_destructive_bridge', 'SET')"
96+
"SELECT pg_catalog.pg_has_role('cwl_llm_batch_outbox_destructive_login', 'cwl_llm_batch_outbox_destructive_inner', 'SET')"
8997
)"
90-
if [[ "${initial_set}" != "f" ]]; then
91-
echo "ADMIN specimen unexpectedly began with SET authority" >&2
98+
if [[ "${initial_inner_set}" != "f" ]]; then
99+
echo "recursive ADMIN specimen unexpectedly began with inner SET authority" >&2
92100
exit 1
93101
fi
94102

@@ -98,7 +106,7 @@ from pg_llm_batch.context_lifecycle_outbox import PostgresContextLifecycleOutbox
98106
from pg_llm_batch.exceptions import ConfigError
99107
100108
store = PostgresContextLifecycleOutboxStore(
101-
"postgresql://cwl_llm_batch_outbox_destructive_admin@127.0.0.1/postgres",
109+
"postgresql://cwl_llm_batch_outbox_destructive_login@127.0.0.1/postgres",
102110
tenant_scope="tenant-a",
103111
tenant_scope_sha256="a" * 64,
104112
)
@@ -113,10 +121,13 @@ PY
113121
)"
114122

115123
docker exec -i "${container}" psql -h 127.0.0.1 \
116-
-U cwl_llm_batch_outbox_destructive_admin -d postgres -v ON_ERROR_STOP=1 <<'SQL'
117-
GRANT cwl_llm_batch_outbox_destructive_bridge
118-
TO cwl_llm_batch_outbox_destructive_admin
124+
-U cwl_llm_batch_outbox_destructive_login -d postgres -v ON_ERROR_STOP=1 <<'SQL'
125+
SET ROLE cwl_llm_batch_outbox_destructive_outer;
126+
GRANT cwl_llm_batch_outbox_destructive_inner
127+
TO cwl_llm_batch_outbox_destructive_login
119128
WITH INHERIT FALSE, SET TRUE;
129+
RESET ROLE;
130+
SET ROLE cwl_llm_batch_outbox_destructive_inner;
120131
SET ROLE cwl_llm_batch_outbox_destructive_leaf;
121132
TRUNCATE TABLE public.llm_context_lifecycle_outbox;
122133
SQL
@@ -126,11 +137,11 @@ remaining="$(
126137
"SELECT pg_catalog.count(*) FROM public.llm_context_lifecycle_outbox"
127138
)"
128139
if [[ "${remaining}" != "0" ]]; then
129-
echo "ADMIN specimen did not materialize SET-reachable TRUNCATE authority" >&2
140+
echo "recursive ADMIN specimen did not materialize SET-reachable TRUNCATE authority" >&2
130141
exit 1
131142
fi
132143

133144
if [[ "${admission}" != "REJECTED" ]]; then
134-
echo "runtime admitted ADMIN-delegatable SET path to destructive outbox authority" >&2
145+
echo "runtime admitted selectable-role ADMIN path to destructive outbox authority" >&2
135146
exit 1
136147
fi

0 commit comments

Comments
 (0)