#!/bin/bash

echo "Test d'authentification admin..."

response=$(curl -s -X POST \
    "http://localhost:8180/realms/master/protocol/openid-connect/token" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -d "username=admin&password=admin123&grant_type=password&client_id=admin-cli")

echo "Réponse complète:"
echo "$response"

if echo "$response" | grep -q "access_token"; then
    echo "✅ Authentification réussie"
else
    echo "❌ Échec de l'authentification"
fi
