uxoxo/eb2ab
0
1#!/bin/bash2# Test script for deployed HF Spaces REST API3# Usage: ./test_deployed_api.sh <API_KEY>4 5API_BASE="https://uxoxo-eb2ab.hf.space/api/v1"6API_KEY="${1:-test-key}"7 8echo "========================================"9echo "HF Spaces REST API Test Suite"10echo "========================================"11echo "Base URL: $API_BASE"12echo "API Key: ${API_KEY:0:10}..."13echo ""14 15# Test 1: Health Check (no auth)16echo "[1/6] Testing health endpoint (no auth)..."17curl -s -w "\nStatus: %{http_code}\n" "$API_BASE/health" || echo "FAILED"18echo ""19 20# Test 2: Detailed Health Check21echo "[2/6] Testing detailed health endpoint..."22curl -s -w "\nStatus: %{http_code}\n" "$API_BASE/health/detailed" || echo "FAILED"23echo ""24 25# Test 3: List Voices (with auth)26echo "[3/6] Testing voices list endpoint (with auth)..."27curl -s -w "\nStatus: %{http_code}\n" \28 -H "X-API-Key: $API_KEY" \29 "$API_BASE/tts/voices" | head -5030echo ""31 32# Test 4: Submit TTS Job (with auth)33echo "[4/6] Testing TTS conversion submission..."34JOB_RESPONSE=$(curl -s -X POST \35 -H "Content-Type: application/json" \36 -H "X-API-Key: $API_KEY" \37 -d '{"text":"Hello world! This is a test of the TTS API.","language":"eng","output_format":"mp3"}' \38 "$API_BASE/tts/convert")39 40echo "$JOB_RESPONSE"41JOB_ID=$(echo "$JOB_RESPONSE" | grep -o '"job_id":"[^"]*' | cut -d'"' -f4)42echo "Job ID: $JOB_ID"43echo ""44 45# Test 5: Check Job Status46if [ -n "$JOB_ID" ]; then47 echo "[5/6] Testing job status endpoint..."48 for i in {1..5}; do49 echo " Poll $i/5..."50 curl -s -H "X-API-Key: $API_KEY" \51 "$API_BASE/tts/status/$JOB_ID"52 echo ""53 sleep 254 done55else56 echo "[5/6] Skipped - no job ID"57fi58echo ""59 60# Test 6: Test invalid auth61echo "[6/6] Testing authentication (invalid key)..."62curl -s -w "\nStatus: %{http_code}\n" \63 -H "X-API-Key: invalid-key-should-fail" \64 "$API_BASE/tts/voices"65echo ""66 67echo "========================================"68echo "Test Suite Complete"69echo "========================================"70 