#!/usr/bin/env bash set -euo pipefail BASE_URL="${BASE_URL:-http://127.0.0.1:8085}" TMP_DIR="$(mktemp -d)" trap 'rm -rf "$TMP_DIR"' EXIT echo "== Feature test 1: baseline auth-status before feature call ==" curl --fail --silent --show-error \ "${BASE_URL}/api/tvdb/auth-status" \ -o "${TMP_DIR}/auth_status_before.json" cat "${TMP_DIR}/auth_status_before.json" python3 - "${TMP_DIR}/auth_status_before.json" <<'PY' import json import sys from pathlib import Path path = Path(sys.argv[1]) data = json.loads(path.read_text(encoding="utf-8")) assert isinstance(data, dict), "auth-status before must be an object" assert "token_source" in data, "auth-status before missing token_source" print("feature baseline auth-status validation passed") PY echo echo "== Feature test 2: replace this block with the specific endpoint under test ==" echo "Example target:" echo " ${BASE_URL}/api/tvdb/series/430543/episodes?order_type=aired" echo echo "Example implementation pattern:" echo " curl --fail --silent --show-error \"\${BASE_URL}/api/your/new/endpoint\" -o \"\${TMP_DIR}/feature.json\"" echo " python3 - \"\${TMP_DIR}/feature.json\" <<'PY'" echo " import json, sys" echo " from pathlib import Path" echo " data = json.loads(Path(sys.argv[1]).read_text(encoding='utf-8'))" echo " assert isinstance(data, dict)" echo " # add exact assertions here" echo " print('feature JSON validation passed')" echo " PY" echo echo "== Feature test 3: verify auth-status after feature call ==" curl --fail --silent --show-error \ "${BASE_URL}/api/tvdb/auth-status" \ -o "${TMP_DIR}/auth_status_after.json" cat "${TMP_DIR}/auth_status_after.json" python3 - "${TMP_DIR}/auth_status_after.json" <<'PY' import json import sys from pathlib import Path path = Path(sys.argv[1]) data = json.loads(path.read_text(encoding="utf-8")) assert isinstance(data, dict), "auth-status after must be an object" assert "token_source" in data, "auth-status after missing token_source" assert data["token_source"] in {"none", "login", "cached", "renewed"}, \ "token_source after must be valid" print("feature post-check auth-status validation passed") PY echo echo "Feature test template completed." echo "Replace feature test 2 with the exact endpoint and assertions for the new functionality."