#!/usr/bin/env sh # Run direct probes from an ephemeral container on the Compose network. set -eu project=${COMPOSE_PROJECT_NAME:-mtusi2026lab7} network="${project}_default" mount="$(pwd)/secrets/pki:/pki:ro" if docker run --rm --network "$network" -v "$mount" curlimages/curl:8.11.1 \ -sk -o /dev/null https://api-1:8080/health/live; then echo 'FAIL: API accepted a connection without a client certificate' exit 1 fi status=$(docker run --rm --network "$network" -v "$mount" curlimages/curl:8.11.1 \ -sk --cert /pki/lb.crt --key /pki/lb.key -o /dev/null -w '%{http_code}' \ https://api-1:8080/health/live) [ "$status" = 200 ] || { echo "FAIL: LB identity returned HTTP $status"; exit 1; } status=$(docker run --rm --network "$network" -v "$mount" curlimages/curl:8.11.1 \ -sk --cert /pki/api.crt --key /pki/api.key -o /dev/null -w '%{http_code}' \ https://api-1:8080/health/live) [ "$status" = 403 ] || { echo "FAIL: wrong API identity returned HTTP $status"; exit 1; } echo 'PASS: API mTLS rejects no certificate and wrong SAN; accepts lb identity'