| #!/bin/bash |
|
|
| |
|
|
| echo "🧪 Testing OpenCode + Nginx Integration" |
| echo "======================================" |
|
|
| |
| echo "📋 Environment Check:" |
| echo " • OpenCode will be installed in Docker" |
| echo " • Nginx will listen on port 7860" |
| echo " • OpenCode will listen on port 57860" |
| echo " • Basic Auth: admin/admin123" |
| echo "" |
|
|
| |
| echo "🎯 Test Plan:" |
| echo " 1. Docker build and run" |
| echo " 2. Nginx authentication test" |
| echo " 3. OpenCode proxy test" |
| echo " 4. API documentation access" |
| echo " 5. End-to-end AI coding test" |
| echo "" |
|
|
| |
| echo "📡 Expected Endpoints:" |
| echo " • Main Site: http://localhost:7860/" |
| echo " • Health Check: http://localhost:7860/health" |
| echo " • OpenCode API: http://localhost:7860/opencode/" |
| echo " • OpenCode Docs: http://localhost:7860/opencode/doc" |
| echo " • Global Health: http://localhost:7860/opencode/global/health" |
| echo "" |
|
|
| |
| echo "🧪 Test Commands:" |
| echo "" |
|
|
| echo "# 1. Nginx Health Check" |
| echo "curl -u admin:admin123 http://localhost:7860/health" |
| echo "" |
|
|
| echo "# 2. OpenCode Health Check (through proxy)" |
| echo "curl -u admin:admin123 http://localhost:7860/opencode/global/health" |
| echo "" |
|
|
| echo "# 3. API Documentation" |
| echo "curl -u admin:admin123 http://localhost:7860/opencode/doc" |
| echo "" |
|
|
| echo "# 4. Create AI Coding Session" |
| echo "curl -u admin:admin123 -X POST \\" |
| echo " -H 'Content-Type: application/json' \\" |
| echo " -d '{\"title\": \"AI Development Session\"}' \\" |
| echo " http://localhost:7860/opencode/session" |
| echo "" |
|
|
| echo "# 5. Send AI Request" |
| echo "# (Replace {session_id} with actual session ID from previous command)" |
| echo "curl -u admin:admin123 -X POST \\" |
| echo " -H 'Content-Type: application/json' \\" |
| echo " -d '{" |
| echo " \"parts\": [" |
| echo " {\"type\": \"text\", \"text\": \"Create a Python Flask web app with Hello World\"}" |
| echo " ]" |
| echo " }' \\" |
| echo " http://localhost:7860/opencode/session/{session_id}/message" |
| echo "" |
|
|
| echo "# 6. List Projects" |
| echo "curl -u admin:admin123 http://localhost:7860/opencode/project" |
| echo "" |
|
|
| echo "# 7. Check Providers" |
| echo "curl -u admin:admin123 http://localhost:7860/opencode/provider" |
| echo "" |
|
|
| echo "📊 Expected Responses:" |
| echo " • Nginx should return: OK" |
| echo " • OpenCode should return: {\"healthy\":true,\"version\":\"1.x.x\"}" |
| echo " • Auth failures should return: 401 Unauthorized" |
| echo " • API should return JSON responses" |
| echo "" |
|
|
| echo "🚀 Ready to deploy!" |
| echo "Run: docker build -t opencode-nginx . && docker run -p 7860:7860 opencode-nginx" |