From 1a3f6d36e1c01f89b47cb1e05b39d31fdccb0516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2=20Maximillian?= =?UTF-8?q?=20=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Sat, 28 Nov 2026 20:18:36 +0300 Subject: [PATCH] test(openbao): lab7 verify token TTL and access for each service role --- student-tests/openbao-acl.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 student-tests/openbao-acl.sh diff --git a/student-tests/openbao-acl.sh b/student-tests/openbao-acl.sh new file mode 100755 index 0000000..a888fcc --- /dev/null +++ b/student-tests/openbao-acl.sh @@ -0,0 +1,21 @@ +#!/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