diff --git a/nix/script-tests/store-seeded-secret.nix b/nix/script-tests/store-seeded-secret.nix index dcc905bc2..d7c7a6683 100644 --- a/nix/script-tests/store-seeded-secret.nix +++ b/nix/script-tests/store-seeded-secret.nix @@ -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; } diff --git a/nix/script-tests/store-seeded-secret.sh b/nix/script-tests/store-seeded-secret.sh index 16a0d7421..c504d9613 100644 --- a/nix/script-tests/store-seeded-secret.sh +++ b/nix/script-tests/store-seeded-secret.sh @@ -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