Refactoring
This commit is contained in:
85
test-final.sh
Normal file
85
test-final.sh
Normal file
@@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "============================================================================="
|
||||
echo "🧪 TEST FINAL AUTHENTIFICATION UNIONFLOW"
|
||||
echo "============================================================================="
|
||||
echo ""
|
||||
|
||||
# Comptes à tester
|
||||
declare -A accounts=(
|
||||
["marie.active"]="Marie123!"
|
||||
["superadmin"]="SuperAdmin123!"
|
||||
["jean.simple"]="Jean123!"
|
||||
["tech.lead"]="TechLead123!"
|
||||
["rh.manager"]="RhManager123!"
|
||||
)
|
||||
|
||||
success_count=0
|
||||
total_count=${#accounts[@]}
|
||||
|
||||
echo "Test d'authentification avec les comptes créés..."
|
||||
echo ""
|
||||
|
||||
for username in "${!accounts[@]}"; do
|
||||
password="${accounts[$username]}"
|
||||
|
||||
echo -n "Test $username... "
|
||||
|
||||
response=$(curl -s -X POST \
|
||||
"http://192.168.1.145:8180/realms/unionflow/protocol/openid-connect/token" \
|
||||
-H "Content-Type: application/x-www-form-urlencoded" \
|
||||
-d "username=${username}&password=${password}&grant_type=password&client_id=unionflow-mobile")
|
||||
|
||||
if echo "$response" | grep -q "access_token"; then
|
||||
echo "✓ SUCCÈS"
|
||||
((success_count++))
|
||||
|
||||
# Extraire quelques infos du token
|
||||
access_token=$(echo "$response" | grep -o '"access_token":"[^"]*' | cut -d'"' -f4)
|
||||
|
||||
# Obtenir les infos utilisateur
|
||||
user_info=$(curl -s -X GET \
|
||||
"http://192.168.1.145:8180/realms/unionflow/protocol/openid-connect/userinfo" \
|
||||
-H "Authorization: Bearer ${access_token}")
|
||||
|
||||
if echo "$user_info" | grep -q "email"; then
|
||||
email=$(echo "$user_info" | grep -o '"email":"[^"]*' | cut -d'"' -f4)
|
||||
echo " → Email: $email"
|
||||
fi
|
||||
else
|
||||
echo "✗ ÉCHEC"
|
||||
echo " → Réponse: ${response:0:100}..."
|
||||
fi
|
||||
echo ""
|
||||
done
|
||||
|
||||
echo "============================================================================="
|
||||
echo "📊 RÉSULTATS FINAUX"
|
||||
echo "============================================================================="
|
||||
echo ""
|
||||
echo "✅ Comptes fonctionnels : $success_count/$total_count"
|
||||
echo ""
|
||||
|
||||
if [ $success_count -eq $total_count ]; then
|
||||
echo "🎉 PARFAIT ! Tous les comptes fonctionnent !"
|
||||
echo ""
|
||||
echo "🚀 PRÊT POUR L'APPLICATION MOBILE :"
|
||||
echo " • Utilisez marie.active / Marie123! pour tester"
|
||||
echo " • Ou superadmin / SuperAdmin123! pour les tests admin"
|
||||
echo " • L'authentification Keycloak est 100% opérationnelle"
|
||||
echo ""
|
||||
elif [ $success_count -gt 0 ]; then
|
||||
echo "⚠️ Configuration partielle réussie"
|
||||
echo " • $success_count comptes fonctionnent"
|
||||
echo " • Vous pouvez tester avec les comptes qui marchent"
|
||||
echo ""
|
||||
else
|
||||
echo "❌ Aucun compte ne fonctionne"
|
||||
echo " • Vérifiez la configuration Keycloak"
|
||||
echo " • Relancez le script de configuration si nécessaire"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo "============================================================================="
|
||||
echo "✅ TEST TERMINÉ"
|
||||
echo "============================================================================="
|
||||
Reference in New Issue
Block a user