Files
mtusi2026lab7/scripts/test-collector-mtls.sh
2026-11-26 23:34:55 +03:00

15 lines
842 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
# Allowed API cert; a valid empty OTLP envelope succeeds.
scripts/dc.sh run --rm -T --no-deps --entrypoint curl api \
-fsS --cacert /pki/ca.crt --cert /identity/api.crt --key /identity/api.key \
-H 'Content-Type: application/json' -d '{}' https://otel-collector:4318/v1/traces >/dev/null
set +e
scripts/dc.sh run --rm -T --no-deps -v "$PWD/certs/client-api:/wrong:ro" --entrypoint curl api \
-fsS --connect-timeout 3 --max-time 10 --cacert /pki/ca.crt --cert /wrong/client-api.crt --key /wrong/client-api.key \
-H 'Content-Type: application/json' -d '{}' https://otel-collector:4318/v1/traces >/dev/null 2>&1
rc=$?
set -e
case "$rc" in 35|52|55|56) echo 'PASS: Collector accepts api SAN and rejects client-api SAN' ;; *) echo "FAIL: unexpected result $rc"; exit 1 ;; esac