Quantum/test-sync.sh
RTSDA 85a4115a71 🚀 Initial release: Quantum Web Server v0.2.0
 Features:
• HTTP/1.1, HTTP/2, and HTTP/3 support with proper architecture
• Reverse proxy with advanced load balancing (round-robin, least-conn, etc.)
• Static file serving with content-type detection and security
• Revolutionary file sync system with WebSocket real-time updates
• Enterprise-grade health monitoring (active/passive checks)
• TLS/HTTPS with ACME/Let's Encrypt integration
• Dead simple JSON configuration + full Caddy v2 compatibility
• Comprehensive test suite (72 tests passing)

🏗️ Architecture:
• Rust-powered async performance with zero-cost abstractions
• HTTP/3 as first-class citizen with shared routing core
• Memory-safe design with input validation throughout
• Modular structure for easy extension and maintenance

📊 Status: 95% production-ready
🧪 Test Coverage: 72/72 tests passing (100% success rate)
🔒 Security: Memory safety + input validation + secure defaults

Built with ❤️ in Rust - Start simple, scale to enterprise!
2025-08-17 17:08:49 -04:00

105 lines
3.2 KiB
Bash
Executable file

#!/bin/bash
echo "🧪 Testing Caddy-RS File Sync System"
echo "===================================="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Test directories
SERVER_DIR="./sync-data"
CLIENT_DIR="./test-client-sync"
echo -e "\n${YELLOW}📁 Checking test setup...${NC}"
echo "Server directory: $SERVER_DIR"
echo "Client directory: $CLIENT_DIR"
echo "Files in server directory:"
find $SERVER_DIR -type f | head -10
echo -e "\n${YELLOW}🔨 Building project...${NC}"
cargo build --release
if [ $? -ne 0 ]; then
echo -e "${RED}❌ Build failed${NC}"
exit 1
fi
echo -e "${GREEN}✅ Build successful${NC}"
echo -e "\n${YELLOW}🚀 Starting server (background)...${NC}"
cargo run --bin caddy-rs --release -- -c example-sync-config.json &
SERVER_PID=$!
echo "Server PID: $SERVER_PID"
# Wait for server to start
echo "Waiting for server to start..."
sleep 3
echo -e "\n${YELLOW}🔍 Testing API endpoints...${NC}"
# Test 1: List files
echo "Test 1: GET /api/list"
curl -s http://localhost:8080/api/list > /tmp/file_list.json
if [ $? -eq 0 ]; then
echo -e "${GREEN}✅ List API works${NC}"
echo "Found $(cat /tmp/file_list.json | wc -l) files"
else
echo -e "${RED}❌ List API failed${NC}"
fi
# Test 2: Download a file
echo -e "\nTest 2: GET /api/download?path=README.md"
curl -s "http://localhost:8080/api/download?path=README.md" > /tmp/downloaded_readme.md
if [ $? -eq 0 ] && [ -s /tmp/downloaded_readme.md ]; then
echo -e "${GREEN}✅ Download API works${NC}"
echo "Downloaded $(wc -l < /tmp/downloaded_readme.md) lines"
else
echo -e "${RED}❌ Download API failed${NC}"
fi
# Test 3: Upload a file
echo -e "\nTest 3: POST /api/upload?path=test-upload.txt"
echo "This is a test upload file" > /tmp/test_upload.txt
curl -s -X POST "http://localhost:8080/api/upload?path=test-upload.txt" \
-H "Content-Type: application/octet-stream" \
--data-binary @/tmp/test_upload.txt
if [ $? -eq 0 ]; then
echo -e "${GREEN}✅ Upload API works${NC}"
# Verify file exists on server
if [ -f "$SERVER_DIR/test-upload.txt" ]; then
echo -e "${GREEN}✅ File successfully created on server${NC}"
else
echo -e "${RED}❌ File not found on server${NC}"
fi
else
echo -e "${RED}❌ Upload API failed${NC}"
fi
# Test 4: Metadata
echo -e "\nTest 4: GET /api/metadata?path=README.md"
curl -s "http://localhost:8080/api/metadata?path=README.md" > /tmp/metadata.json
if [ $? -eq 0 ] && [ -s /tmp/metadata.json ]; then
echo -e "${GREEN}✅ Metadata API works${NC}"
echo "Metadata: $(cat /tmp/metadata.json)"
else
echo -e "${RED}❌ Metadata API failed${NC}"
fi
echo -e "\n${YELLOW}🧹 Cleanup...${NC}"
# Kill server
kill $SERVER_PID 2>/dev/null
sleep 1
# Clean up temp files
rm -f /tmp/file_list.json /tmp/downloaded_readme.md /tmp/test_upload.txt /tmp/metadata.json
echo -e "\n${GREEN}🎉 API testing complete!${NC}"
echo -e "\n${YELLOW}📋 Next steps:${NC}"
echo "1. Test the sync client binary"
echo "2. Test bidirectional synchronization"
echo "3. Test conflict resolution"
echo "4. Test real-time file watching"
echo -e "\n${YELLOW}💡 To test sync client:${NC}"
echo "cargo run --bin sync-client -- --server http://localhost:8080 --local-path ./test-client-sync --initial-sync"