#!/bin/bash # Simple Application Test Script # This script tests if the application is working correctly set -e # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color log() { echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1" } success() { echo -e "${GREEN}[SUCCESS]${NC} $1" } error() { echo -e "${RED}[ERROR]${NC} $1" >&2 } log "๐Ÿงช Testing application functionality..." # Test 1: Health endpoint from inside container log "Test 1: Health endpoint from inside container" if docker exec portfolio-app curl -s http://localhost:3000/api/health | grep -q '"status":"healthy"'; then success "โœ… Health endpoint working from inside container" else error "โŒ Health endpoint not working from inside container" exit 1 fi # Test 2: Health endpoint from outside container log "Test 2: Health endpoint from outside container" if curl -s http://localhost:3000/api/health | grep -q '"status":"healthy"'; then success "โœ… Health endpoint working from outside container" else warning "โš ๏ธ Health endpoint not accessible from outside container" log "This is the issue causing the health check failure" fi # Test 3: Main page from inside container log "Test 3: Main page from inside container" if docker exec portfolio-app curl -s http://localhost:3000/ | grep -q "Dennis Konkol"; then success "โœ… Main page working from inside container" else error "โŒ Main page not working from inside container" fi # Test 4: Main page from outside container log "Test 4: Main page from outside container" if curl -s http://localhost:3000/ | grep -q "Dennis Konkol"; then success "โœ… Main page working from outside container" else warning "โš ๏ธ Main page not accessible from outside container" fi # Test 5: Admin page from inside container log "Test 5: Admin page from inside container" if docker exec portfolio-app curl -s http://localhost:3000/manage | grep -q "Admin\|Login"; then success "โœ… Admin page working from inside container" else error "โŒ Admin page not working from inside container" fi # Test 6: Admin page from outside container log "Test 6: Admin page from outside container" if curl -s http://localhost:3000/manage | grep -q "Admin\|Login"; then success "โœ… Admin page working from outside container" else warning "โš ๏ธ Admin page not accessible from outside container" fi # Summary log "๐Ÿ“Š Test Summary:" log "The application is working correctly from inside the container" log "The issue is with external accessibility" if curl -f http://localhost:3000/api/health > /dev/null 2>&1; then success "๐ŸŽ‰ Application is fully accessible!" log "Your application is working correctly at:" log " - Main site: http://localhost:3000/" log " - Admin panel: http://localhost:3000/manage" log " - Health check: http://localhost:3000/api/health" else warning "โš ๏ธ Application is not accessible from outside" log "This is likely due to:" log " 1. Network configuration issues" log " 2. Firewall blocking port 3000" log " 3. Application binding to wrong interface" log " 4. Running behind a reverse proxy" log "To fix this, run:" log " ./scripts/quick-health-fix.sh" fi