#!/bin/bash # Test script for the E2EE Bridge HTTP API # Run the bridge first: python bridge-e2ee.py API_URL="${API_URL:-http://127.0.0.1:8284}" echo "Testing E2EE Bridge API at $API_URL" echo "==================================" echo # Test 1: Health check echo "1. Health Check" echo "---------------" curl -s "$API_URL/api/health" | jq . echo # Test 2: List rooms echo "2. List Rooms" echo "-------------" curl -s "$API_URL/api/list_rooms" | jq . echo # Test 3: Read room (requires a room_id) if [ -n "$ROOM_ID" ]; then echo "3. Read Room ($ROOM_ID)" echo "-----------------------" curl -s -X POST "$API_URL/api/read_room" \ -H "Content-Type: application/json" \ -d "{\"room_id\": \"$ROOM_ID\", \"limit\": 5}" | jq . echo fi # Test 4: Send message (requires a room_id and message) if [ -n "$ROOM_ID" ] && [ -n "$MESSAGE" ]; then echo "4. Send Message to $ROOM_ID" echo "---------------------------" curl -s -X POST "$API_URL/api/send_message" \ -H "Content-Type: application/json" \ -d "{\"room_id\": \"$ROOM_ID\", \"text\": \"$MESSAGE\"}" | jq . echo fi echo "==================================" echo "Test complete!" echo echo "To test with a specific room:" echo " ROOM_ID='!yourroom:server.com' ./test_api.sh" echo echo "To send a test message:" echo " ROOM_ID='!yourroom:server.com' MESSAGE='Hello from API!' ./test_api.sh"