#!/bin/sh set -eu cd "$(dirname "$0")/.." for role in api worker reconciler; do docker compose exec -T "$role" sh -eu <<'CHECK' addr=https://openbao:8200/v1 req() { curl -sS --max-time 8 --cacert /tls/ca.crt --cert /tls/client.crt --key /tls/client.key "$@"; } login=$(req -f --data "{\"name\":\"$BAO_ROLE\"}" "$addr/auth/cert/login") token=$(printf %s "$login" | jq -er '.auth.client_token | strings') printf %s "$login" | jq -e '.auth.lease_duration > 0 and .auth.lease_duration <= 120' >/dev/null header() { printf 'X-Vault-Token: %s\n' "$token"; } for other in api worker reconciler; do expected=403 if [ "$other" = "$BAO_ROLE" ]; then expected=200; fi code=$(header | req -H @- -o /dev/null -w '%{http_code}' "$addr/lab7/data/$other") echo "$BAO_ROLE → $other: HTTP $code" test "$code" = "$expected" done header | req -f -H @- -X POST "$addr/auth/token/revoke-self" >/dev/null CHECK done