AvanzaCast/scripts/verify_token_server_after_update.sh
Cesar Mendivil 8b458a3ddf feat: add initial LiveKit Meet integration with utility scripts, configs, and core components
- Add Next.js app structure with base configs, linting, and formatting
- Implement LiveKit Meet page, types, and utility functions
- Add Docker, Compose, and deployment scripts for backend and token server
- Provide E2E and smoke test scaffolding with Puppeteer and Playwright helpers
- Include CSS modules and global styles for UI
- Add postMessage and studio integration utilities
- Update package.json with dependencies and scripts for development and testing
2025-11-20 12:50:38 -07:00

67 lines
2.2 KiB
Bash

#!/usr/bin/env bash
# scripts/verify_token_server_after_update.sh
# Verify token-server can create a session and provide a token, and test LiveKit WS connect (basic)
# Usage:
# ./scripts/verify_token_server_after_update.sh --session-room ROOM --session-user USER --token-server-url URL
set -euo pipefail
ROOM="e2e_room"
USER="e2e_user"
TOKEN_SERVER_URL="https://avanzacast-servertokens.bfzqqk.easypanel.host"
while [[ $# -gt 0 ]]; do
case $1 in
--session-room) ROOM="$2"; shift 2;;
--session-user) USER="$2"; shift 2;;
--token-server-url) TOKEN_SERVER_URL="$2"; shift 2;;
-h|--help) echo "Usage: $0 --session-room ROOM --session-user USER --token-server-url URL"; exit 0;;
*) echo "Unknown arg $1"; exit 2;;
esac
done
echo "Creating session via $TOKEN_SERVER_URL/api/session"
resp=$(curl -s -X POST "$TOKEN_SERVER_URL/api/session" -H 'Content-Type: application/json' -d "{\"room\":\"$ROOM\",\"username\":\"$USER\"}")
if [[ -z "$resp" ]]; then
echo "No response from token-server" >&2
exit 2
fi
echo "Response: $resp"
id=$(echo "$resp" | jq -r '.id // empty')
if [[ -z "$id" ]]; then
echo "Failed to parse id from response" >&2
exit 2
fi
echo "Created session id: $id"
# now fetch token
echo "Fetching token for session $id"
tokresp=$(curl -s "$TOKEN_SERVER_URL/api/session/$id/token")
echo "$tokresp"
tok=$(echo "$tokresp" | jq -r '.token // empty')
if [[ -z "$tok" ]]; then
echo "Failed to get token" >&2
exit 2
fi
echo "Token obtained (first 20 chars): ${tok:0:20}..."
# Try a websocket connect test using websocat if available (best-effort)
if command -v websocat >/dev/null 2>&1; then
LIVEKIT_WS=$(echo "$tokresp" | jq -r '.url // empty')
if [[ -z "$LIVEKIT_WS" ]]; then
echo "No livekit url returned in token response; skipping websocat test"
exit 0
fi
echo "Attempting simple websocat connect to $LIVEKIT_WS with token (no RTC handshake)"
# Note: websocat may require additional parameters for TLS; this is just a connect test
websocat -t "$LIVEKIT_WS/rtc?access_token=$tok" || echo "websocat connect failed (expected if LiveKit expects protocol handshake)"
else
echo "websocat not installed; skipping websocket connect test"
fi
exit 0