fix: resolve homepage host validation issue using TDD approach
- Created test to verify homepage host validation issue - Identified that HOMEPAGE_ALLOWED_HOSTS environment variable was needed - Updated homepage Docker Compose with proper allowed hosts setting - Added 'localhost:4000,127.0.0.1:4000' to HOMEPAGE_ALLOWED_HOSTS - All tests now pass with no host validation errors - Updated prompt to emphasize TDD approach for all changes - Implemented atomic testing approach for immediate validation Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -11,6 +11,7 @@ services:
|
||||
- PORT=3000
|
||||
- HOMEPAGE_URL=http://localhost:4000
|
||||
- BASE_URL=http://localhost:4000
|
||||
- HOMEPAGE_ALLOWED_HOSTS=localhost:4000,127.0.0.1:4000
|
||||
volumes:
|
||||
- ./config/homepage:/app/config
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro # For Docker integration
|
||||
|
||||
36
artifacts/SupportStack/tests/test_homepage_host_validation.sh
Executable file
36
artifacts/SupportStack/tests/test_homepage_host_validation.sh
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Test for homepage host validation issue
|
||||
# Following TDD: Write test → Execute test → Test fails → Write minimal code to pass test
|
||||
|
||||
set -e
|
||||
|
||||
echo "Testing homepage host validation issue..."
|
||||
|
||||
# Check if homepage container is running
|
||||
if ! docker ps | grep -q "tsysdevstack-homepage"; then
|
||||
echo "❌ Homepage container is not running"
|
||||
echo "Test failed: Homepage host validation test failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test if we get the host validation error by checking the HTTP response
|
||||
response=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:4000/ 2>/dev/null || echo "ERROR")
|
||||
|
||||
if [ "$response" = "ERROR" ] || [ "$response" != "200" ]; then
|
||||
# Let's also check the page content to see if it contains the host validation error message
|
||||
content=$(curl -s http://127.0.0.1:4000/ 2>/dev/null || echo "")
|
||||
if [[ "$content" == *"Host validation failed"* ]]; then
|
||||
echo "❌ Homepage is showing 'Host validation failed' error"
|
||||
echo "Test confirmed: Host validation issue exists"
|
||||
exit 1
|
||||
else
|
||||
echo "⚠️ Homepage is not accessible but not showing host validation error"
|
||||
echo "Test failed: Homepage not accessible"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "✅ Homepage is accessible and host validation is working"
|
||||
echo "Test passed: No host validation issue"
|
||||
exit 0
|
||||
fi
|
||||
Reference in New Issue
Block a user