Watch
0
0
Fork
You've already forked hyperhive
0

store_list: pin the mount-refusal and unreachable-store answers too

The script test's stub gains the two remaining rows of bao's table: a
token with no access to the mount (403 on the preflight) and a store that
is not there. Both end with status 2 and an error on stderr, and both must
be errors, not an empty list.
This commit is contained in:
maia 2026-11-24 18:21:43 +01:00
commit 56423beef7
2 changed files with 18 additions and 2 deletions

View file

@ -19,7 +19,9 @@ let
# set, and as bao answers a prefix that holds nothing when it is not: status
# 2, `{}`, nothing on stderr. `FAKE_BAO_LIST_DENY` and `FAKE_BAO_LIST_SEALED`
# are the errors, which end with status 2 as well but print on stderr, and
# `FAKE_BAO_LIST_NOISY` is an empty answer with a line on stderr.
# `FAKE_BAO_LIST_NOMOUNT` is a token with no access to the mount,
# `FAKE_BAO_LIST_DOWN` a store that is not there, and `FAKE_BAO_LIST_NOISY` is
# an empty answer with a line on stderr.
# `FAKE_BAO_RACE` has another run create the leaf between this one's read and
# its write. `FAKE_BAO_READ_DELAY` holds each read that long and records, in
# `$FAKE_BAO_KV/.peak`, how many reads were in flight with it. Every call is
@ -58,6 +60,8 @@ let
# As bao answers: a refusal and a sealed store end with status 2, the
# error on stderr and nothing on stdout.
[ -z "''${FAKE_BAO_LIST_DENY-}" ] || { printf 'Error listing %s: Code: 403. Errors:\n\n* 1 error occurred:\n\t* permission denied\n' "$4" >&2; exit 2; }
[ -z "''${FAKE_BAO_LIST_NOMOUNT-}" ] || { printf 'Error making API request.\n\nURL: GET http://127.0.0.1:8200/v1/sys/internal/ui/mounts/secret\nCode: 403. Errors:\n\n* preflight capability check returned 403, please ensure client'"'"'s policies grant access to path "secret/"\n' >&2; exit 2; }
[ -z "''${FAKE_BAO_LIST_DOWN-}" ] || { echo 'Get "http://127.0.0.1:8200/v1/sys/internal/ui/mounts/secret": dial tcp 127.0.0.1:8200: connect: connection refused' >&2; exit 2; }
[ -z "''${FAKE_BAO_LIST_SEALED-}" ] || { echo "Error making API request. Code: 503. Errors: * Vault is sealed" >&2; exit 2; }
# An empty answer with something on stderr is not "nothing there".
[ -z "''${FAKE_BAO_LIST_NOISY-}" ] || { echo "fake bao: a warning" >&2; echo '{}'; exit 2; }

View file

@ -22,7 +22,7 @@ setup() {
dir=$(mktemp -d)
mkdir "$dir/kv"
export FAKE_BAO_KV=$dir/kv FAKE_BAO_LOG=$dir/bao.log FAKE_BAO_LOGIN_RC=0
unset FAKE_BAO_DENY_READ FAKE_BAO_DENY_WRITE FAKE_BAO_RACE FAKE_BAO_READ_TIMEOUT FAKE_BAO_READ_5XX FAKE_BAO_READ_DELAY FAKE_BAO_LIST FAKE_BAO_LIST_DENY FAKE_BAO_LIST_SEALED FAKE_BAO_LIST_NOISY PREFETCH
unset FAKE_BAO_DENY_READ FAKE_BAO_DENY_WRITE FAKE_BAO_RACE FAKE_BAO_READ_TIMEOUT FAKE_BAO_READ_5XX FAKE_BAO_READ_DELAY FAKE_BAO_LIST FAKE_BAO_LIST_DENY FAKE_BAO_LIST_SEALED FAKE_BAO_LIST_NOISY FAKE_BAO_LIST_NOMOUNT FAKE_BAO_LIST_DOWN PREFETCH
: >"$FAKE_BAO_LOG"
earlier=$dir/earlier
minted=$dir/minted
@ -335,6 +335,18 @@ run_list secret/swarm/services/archive/users
expect 1 ""
err_has "permission denied"
setup "a token with no access to the mount is an error, with the store's message"
export FAKE_BAO_LIST_NOMOUNT=1
run_list secret/swarm/services/archive/users
expect 1 ""
err_has "preflight capability check returned 403"
setup "a store that is not there is an error, with the store's message"
export FAKE_BAO_LIST_DOWN=1
run_list secret/swarm/services/archive/users
expect 1 ""
err_has "connection refused"
setup "an empty answer with something on stderr is an error"
export FAKE_BAO_LIST_NOISY=1
run_list secret/swarm/services/archive/users