ferrero-naming-tool/test-api.sh
DJP 7233a49252 Add v2 with PostgreSQL tracking ID system for asset lifecycle management
Implements complete tracking ID system for linking derivative assets to master files with automatic metadata inheritance.

Major features:
- v2 web interface (public-v2/) with tracking ID support
- PostgreSQL database (Docker) for master asset metadata storage
- 6-character alphanumeric tracking IDs with collision-free generation
- OpenText DAM integration with metadata import script
- Upload simulator showing filename transformations (strips job number and tracking ID)
- Visual transformation flow display
- Complete asset lifecycle event logging with triggers
- Database schema with optimized indexes and views
- Helper scripts for database management (db-start.sh, db-stop.sh)

Technical implementation:
- PostgreSQL 15 in Docker on port 5433 (md5 auth for MAMP compatibility)
- PHP PDO with singleton database class
- Automatic event logging via PostgreSQL triggers
- JSON storage for naming convention data (shared with v1)
- Case-sensitive tracking ID input fields

Both v1 (simple) and v2 (tracking) versions coexist for different workflows.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-27 12:24:35 -04:00

31 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
# Test API endpoints
echo "Testing API endpoints..."
echo ""
# Test 1: Data endpoint (should work without database)
echo "1. Testing data endpoint..."
php -r '$_GET["action"] = "data"; $_SERVER["REQUEST_METHOD"] = "GET"; ob_start(); include "public-v2/api.php"; $output = ob_get_clean(); $data = json_decode($output, true); echo isset($data["brands"]) ? "✅ Data loaded successfully\n" : "❌ Failed to load data\n";'
# Test 2: Database connection
echo "2. Testing database connection..."
PGPASSWORD=ferrero_pass_2025 psql -h localhost -p 5433 -U ferrero_user -d ferrero_tracking -c "SELECT 1;" > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "✅ Database connection successful"
else
echo "❌ Database connection failed"
fi
# Test 3: Check tracking ID exists
echo "3. Checking tracking ID 'rQ0Ijf'..."
RESULT=$(PGPASSWORD=ferrero_pass_2025 psql -h localhost -p 5433 -U ferrero_user -d ferrero_tracking -t -c "SELECT COUNT(*) FROM master_assets WHERE tracking_id = 'rQ0Ijf';")
if [ "$RESULT" -gt 0 ]; then
echo "✅ Tracking ID found in database"
else
echo "❌ Tracking ID not found"
fi
echo ""
echo "If all tests pass, the tracking ID validation should work in the browser."
echo "Try refreshing the page and validating again."