# Instructions de Test - Lions User Manager ## โœ… Configuration Terminรฉe Tous les composants sont maintenant configurรฉs et opรฉrationnels ! ## ๐Ÿš€ Architecture Actuelle ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Navigateur Web โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ 1. http://localhost:8080 โ”‚ Redirection OIDC โ†’ โ”‚ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ KEYCLOAK (Port 8180) โœ… โ”‚ โ”‚ - Realm: lions-user-manager โ”‚ โ”‚ - Client: lions-user-manager-client โ”‚ โ”‚ - Secret: client-secret-lions-2025 โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ 2. Authentification โ”‚ testuser / test123 โ”‚ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ FRONTEND (Port 8080) โœ… โ”‚ โ”‚ - OIDC activรฉ โ”‚ โ”‚ - Reรงoit token JWT โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ 3. Appels API avec token JWT โ”‚ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ BACKEND (Port 8081) โœ… โ”‚ โ”‚ - Vรฉrifie le token JWT โ”‚ โ”‚ - Appelle Keycloak Admin API โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ## ๐Ÿ“‹ ร‰tapes de Test ### 1. Vรฉrifier que tous les services tournent ```bash # Backend (port 8081) curl http://localhost:8081/q/health # Keycloak (port 8180) curl http://localhost:8180/realms/lions-user-manager # Frontend (port 8080) - devrait rediriger curl -I http://localhost:8080 ``` ### 2. Tester l'authentification complรจte 1. **Ouvrir le navigateur** : http://localhost:8080 2. **Redirection automatique** vers Keycloak : - URL sera : `http://localhost:8180/realms/lions-user-manager/protocol/openid-connect/auth?...` 3. **Se connecter** avec les credentials : - **Username** : `testuser` - **Password** : `test123` 4. **Redirection** vers le frontend authentifiรฉ 5. **Accรฉder aux pages protรฉgรฉes** : - http://localhost:8080/pages/user-manager/users/list.xhtml ### 3. Tester les API Backend directement #### Avec token (authentifiรฉ) ```bash # 1. Obtenir un token TOKEN=$(curl -s -X POST "http://localhost:8180/realms/lions-user-manager/protocol/openid-connect/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "client_id=lions-user-manager-client" \ -d "client_secret=client-secret-lions-2025" \ -d "username=testuser" \ -d "password=test123" \ -d "grant_type=password" | grep -o '"access_token":"[^"]*' | cut -d'"' -f4) # 2. Appeler l'API avec le token curl -H "Authorization: Bearer $TOKEN" \ "http://localhost:8081/api/users?realm=lions-user-manager" ``` ## ๐Ÿ”‘ Credentials ### Keycloak Admin - **URL** : http://localhost:8180/admin - **Username** : `admin` - **Password** : `admin` - **Realm** : `master` ### Test User (Application) - **URL** : http://localhost:8080 - **Username** : `testuser` - **Password** : `test123` - **Realm** : `lions-user-manager` ### Client Configuration - **Client ID** : `lions-user-manager-client` - **Client Secret** : `client-secret-lions-2025` - **Realm** : `lions-user-manager` ## ๐Ÿ“Š Endpoints de Test ### Frontend - **Accueil** : http://localhost:8080 - **Users List** : http://localhost:8080/pages/user-manager/users/list.xhtml - **Roles List** : http://localhost:8080/pages/user-manager/roles/list.xhtml ### Backend API - **Swagger UI** : http://localhost:8081/q/swagger-ui - **Dev UI** : http://localhost:8081/q/dev - **Health** : http://localhost:8081/q/health - **Keycloak Health** : http://localhost:8081/api/health/keycloak - **Users API** : http://localhost:8081/api/users?realm=lions-user-manager - **Roles API** : http://localhost:8081/api/roles/realm?realm=lions-user-manager ### Keycloak - **Admin Console** : http://localhost:8180/admin - **Realm Info** : http://localhost:8180/realms/lions-user-manager - **Well-known** : http://localhost:8180/realms/lions-user-manager/.well-known/openid-configuration ## โš ๏ธ Troubleshooting ### Frontend retourne "Forbidden" - **Cause** : Pas authentifiรฉ - **Solution** : Allez sur http://localhost:8080, laissez-vous rediriger vers Keycloak et authentifiez-vous ### Erreur "Client not found" - **Cause** : Configuration Keycloak incorrecte - **Solution** : Vรฉrifier que le client `lions-user-manager-client` existe dans le realm `lions-user-manager` ### Backend retourne 403 - **Cause** : Token invalide ou manquant - **Solution** : S'assurer que le frontend envoie bien le token JWT dans l'en-tรชte `Authorization` ### "Invalid redirect_uri" - **Cause** : Les redirect URIs ne sont pas configurรฉes correctement - **Solution** : Dans Keycloak Admin, vรฉrifier que `http://localhost:8080/*` est bien dans les Valid Redirect URIs ## ๐Ÿงช Scรฉnarios de Test ### Scรฉnario 1 : Authentification et Liste des Utilisateurs 1. Ouvrir http://localhost:8080 2. Se connecter avec testuser/test123 3. Naviguer vers la liste des utilisateurs 4. Vรฉrifier que les utilisateurs s'affichent ### Scรฉnario 2 : Crรฉer un Utilisateur 1. S'authentifier (voir Scรฉnario 1) 2. Cliquer sur "Nouveau Utilisateur" 3. Remplir le formulaire 4. Sauvegarder 5. Vรฉrifier que l'utilisateur apparaรฎt dans la liste ### Scรฉnario 3 : Gestion des Rรดles 1. S'authentifier 2. Aller sur la page des rรดles 3. Assigner des rรดles ร  un utilisateur 4. Vรฉrifier que les rรดles sont bien assignรฉs ### Scรฉnario 4 : API Backend Directe ```bash # Obtenir token TOKEN=$(curl -s -X POST "http://localhost:8180/realms/lions-user-manager/protocol/openid-connect/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "client_id=lions-user-manager-client" \ -d "client_secret=client-secret-lions-2025" \ -d "username=testuser" \ -d "password=test123" \ -d "grant_type=password" | grep -o '"access_token":"[^"]*' | cut -d'"' -f4) # Lister utilisateurs curl -H "Authorization: Bearer $TOKEN" \ "http://localhost:8081/api/users?realm=lions-user-manager" # Lister rรดles curl -H "Authorization: Bearer $TOKEN" \ "http://localhost:8081/api/roles/realm?realm=lions-user-manager" ``` ## โœ… Checklist de Validation - [ ] Backend dรฉmarre sur port 8081 - [ ] Keycloak accessible sur port 8180 - [ ] Frontend dรฉmarre sur port 8080 - [ ] Redirection OIDC fonctionne (frontend โ†’ Keycloak) - [ ] Authentification rรฉussie avec testuser/test123 - [ ] Pages protรฉgรฉes accessibles aprรจs authentification - [ ] API Backend retourne des donnรฉes - [ ] Token JWT est correctement transmis - [ ] Swagger UI accessible et fonctionnel ## ๐ŸŽฏ Prochaines ร‰tapes (Post-Test) 1. โœ… Validation de l'authentification complรจte 2. โณ Tests fonctionnels de toutes les pages 3. โณ Tests CRUD complets (Create, Read, Update, Delete) 4. โณ Tests de gestion des rรดles 5. โณ Tests d'audit 6. โณ Tests de synchronisation ## ๐Ÿ“ Notes - Le frontend utilise maintenant OIDC avec Keycloak local - Le backend vรฉrifie les tokens JWT via OIDC - Tous les appels API nรฉcessitent un token valide - Le test user `testuser` a les rรดles : `admin`, `user_manager` --- **Date de configuration** : 2025-12-05 **Environnement** : Dรฉveloppement (DEV)