Files
at-container-registry/scripts/test-hold-endpoints.sh

113 lines
4.3 KiB
Bash
Executable File

#!/bin/bash
# Test script for ATProto sync endpoints on hold service
# Usage: ./test-hold-endpoints.sh [HOLD_URL] [DID]
HOLD_URL="${1:-http://172.28.0.3:8080}"
# You'll need to replace this with your hold's actual DID
DID="${2:-did:web:172.28.0.3%3A8080}"
echo "Testing ATProto sync endpoints on: $HOLD_URL"
echo "Using DID: $DID"
echo "=========================================="
echo ""
# Test 1: List repositories
echo "1. Testing com.atproto.sync.listRepos"
echo " GET $HOLD_URL/xrpc/com.atproto.sync.listRepos"
echo " Response:"
curl -s -w "\n HTTP Status: %{http_code}\n" \
"$HOLD_URL/xrpc/com.atproto.sync.listRepos" | jq . 2>/dev/null || cat
echo ""
echo "=========================================="
echo ""
# Test 2: Describe repo
echo "2. Testing com.atproto.repo.describeRepo"
echo " GET $HOLD_URL/xrpc/com.atproto.repo.describeRepo?repo=$DID"
echo " Response:"
curl -s -w "\n HTTP Status: %{http_code}\n" \
"$HOLD_URL/xrpc/com.atproto.repo.describeRepo?repo=$DID" | jq . 2>/dev/null || cat
echo ""
echo "=========================================="
echo ""
# Test 3: Get repository (CAR file)
echo "3. Testing com.atproto.sync.getRepo"
echo " GET $HOLD_URL/xrpc/com.atproto.sync.getRepo?did=$DID"
echo " Response (showing first 200 bytes of CAR file):"
curl -s -w "\n HTTP Status: %{http_code}\n Content-Type: %{content_type}\n" \
"$HOLD_URL/xrpc/com.atproto.sync.getRepo?did=$DID" | head -c 200
echo ""
echo " [truncated...]"
echo ""
echo "=========================================="
echo ""
# Test 4: List records (captain record)
echo "4. Testing com.atproto.repo.listRecords (captain)"
echo " GET $HOLD_URL/xrpc/com.atproto.repo.listRecords?repo=$DID&collection=io.atcr.hold.captain"
echo " Response:"
curl -s -w "\n HTTP Status: %{http_code}\n" \
"$HOLD_URL/xrpc/com.atproto.repo.listRecords?repo=$DID&collection=io.atcr.hold.captain" | jq . 2>/dev/null || cat
echo ""
echo "=========================================="
echo ""
# Test 5: List records (crew records)
echo "5. Testing com.atproto.repo.listRecords (crew)"
echo " GET $HOLD_URL/xrpc/com.atproto.repo.listRecords?repo=$DID&collection=io.atcr.hold.crew"
echo " Response:"
curl -s -w "\n HTTP Status: %{http_code}\n" \
"$HOLD_URL/xrpc/com.atproto.repo.listRecords?repo=$DID&collection=io.atcr.hold.crew" | jq . 2>/dev/null || cat
echo ""
echo "=========================================="
echo ""
# Test 6: Get blob (this will likely return an error without a valid CID)
echo "6. Testing com.atproto.sync.getBlob (requires valid CID)"
echo " Skipping - needs a real blob CID from your hold"
echo " Example command:"
echo " curl \"$HOLD_URL/xrpc/com.atproto.sync.getBlob?did=$DID&cid=bafyrei...\""
echo ""
echo "=========================================="
echo ""
# Test 7: WebSocket - subscribeRepos
echo "7. Testing com.atproto.sync.subscribeRepos (WebSocket)"
echo " This requires a WebSocket client like websocat or wscat"
echo ""
# Check if websocat is available
if command -v websocat &> /dev/null; then
echo " Found websocat! Connecting for 5 seconds..."
WS_URL="${HOLD_URL/http:/ws:}"
WS_URL="${WS_URL/https:/wss:}"
echo " WS URL: $WS_URL/xrpc/com.atproto.sync.subscribeRepos"
timeout 5 websocat "$WS_URL/xrpc/com.atproto.sync.subscribeRepos" 2>&1 || echo " Connection closed or timeout"
elif command -v wscat &> /dev/null; then
echo " Found wscat! Connecting for 5 seconds..."
WS_URL="${HOLD_URL/http:/ws:}"
WS_URL="${WS_URL/https:/wss:}"
echo " WS URL: $WS_URL/xrpc/com.atproto.sync.subscribeRepos"
timeout 5 wscat -c "$WS_URL/xrpc/com.atproto.sync.subscribeRepos" 2>&1 || echo " Connection closed or timeout"
else
echo " WebSocket client not found. Install websocat or wscat:"
echo " - websocat: cargo install websocat"
echo " - wscat: npm install -g wscat"
echo ""
echo " Manual test command:"
WS_URL="${HOLD_URL/http:/ws:}"
WS_URL="${WS_URL/https:/wss:}"
echo " websocat '$WS_URL/xrpc/com.atproto.sync.subscribeRepos'"
echo " OR"
echo " wscat -c '$WS_URL/xrpc/com.atproto.sync.subscribeRepos'"
fi
echo ""
echo "=========================================="
echo "Tests complete!"
echo ""
echo "Note: If you need to test with a specific blob, first push an image"
echo "to get real blob CIDs, then use them with getBlob endpoint."