#!/bin/bash
echo "Testing Password Change API endpoint..."
echo ""
echo "1. Testing route exists (should get 401 without auth):"
curl -s -o /dev/null -w "Status: %{http_code}\n" -X PUT http://localhost:3000/api/password/change -H "Content-Type: application/json" -d '{"current_password":"test","new_password":"test123","confirm_password":"test123"}'
echo ""
echo "2. Testing with invalid token (should get 401):"
curl -s -o /dev/null -w "Status: %{http_code}\n" -X PUT http://localhost:3000/api/password/change -H "Content-Type: application/json" -H "Authorization: Bearer invalid" -d '{"current_password":"test","new_password":"test123","confirm_password":"test123"}'
echo ""
echo "3. Checking backend logs for route registration:"
pm2 logs erp-backend --lines 1 --nostream | grep -i "listening" | tail -1
echo ""
echo "Test complete!"
