#!/usr/bin/env bash
# Verify exact Actions Gateway identity and its authenticated read-only contract.
set -euo pipefail

(($# == 5)) || { printf 'usage: %s <url> <config> <node-bin> <component> <sha>\n' "$0" >&2; exit 64; }
url=$1
config=$2
node_bin=$3
component=$4
sha=$5
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

[[ -x "$node_bin" ]] || { printf 'actions-gateway-readiness: node runtime unavailable\n' >&2; exit 69; }
bash "$script_dir/backend-readiness.sh" actions-gateway "$url/health" - "$component" "$sha"
"$node_bin" "$script_dir/test-actions-gateway-r0.mjs" --endpoint "$url" --config "$config"
