Skip to content

Commit 3b4c742

Browse files
committed
testsuite: cover remote sdbus access to rank 0
Problem: there is no test coverage for the restriction that sdbus on rank 0 can only be accessed locally. Add tests to 2407-sdbus.t.
1 parent c2104d4 commit 3b4c742

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

t/t2407-sdbus.t

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if ! busctl --user status >/dev/null; then
1818
test_done
1919
fi
2020

21-
test_under_flux 1 minimal
21+
test_under_flux 2 minimal
2222

2323
flux setattr log-stderr-level 1
2424

@@ -264,6 +264,27 @@ test_expect_success NO_CHAIN_LINT 'all test units triggered signals' '
264264
test $(grep flux-t2406-3 signals.out | wc -l) -gt 0 &&
265265
test $(grep flux-t2406-4 signals.out | wc -l) -gt 0
266266
'
267+
# Test restriction of RPCs to sdbus on rank 0 from rank 1
268+
# N.B. requests are forwarded upstream b/c sdbus is not loaded on rank 1
269+
test_expect_success 'subscribe from rank 1 is restricted' '
270+
test_must_fail flux exec -r 1 flux python ./subscribe.py 2>sub1.err &&
271+
grep "not allowed" sub1.err
272+
'
273+
test_expect_success 'create list script' '
274+
cat >list.py <<-EOT &&
275+
import sys
276+
import flux
277+
print(flux.Flux().rpc("sdbus.call",{"member":"ListUnitsByPatterns","params":[[],["*"]]}).get_str())
278+
EOT
279+
chmod +x list.py
280+
'
281+
test_expect_success 'list from rank 0 is allowed' '
282+
flux python ./list.py >/dev/null
283+
'
284+
test_expect_success 'list-units-leader from rank 1 is restricted' '
285+
test_must_fail flux exec -r 1 flux python ./list.py 2>list1.err &&
286+
grep "not allowed" list1.err
287+
'
267288

268289
test_expect_success 'remove sdbus module' '
269290
flux module remove sdbus

0 commit comments

Comments
 (0)