Initial commit: unionflow-mobile-apps

Application Flutter complète (sans build artifacts).

Signed-off-by: lions dev Team
This commit is contained in:
dahoud
2026-03-15 16:30:08 +00:00
commit d094d6db9c
1790 changed files with 507435 additions and 0 deletions

122
scripts/README.md Normal file
View File

@@ -0,0 +1,122 @@
# Scripts UnionFlow Mobile Apps
Scripts utilitaires pour le développement et les tests de l'application mobile.
---
## 🔧 Scripts Disponibles
### 1. `start-integration-tests.ps1`
**Description:** Vérifie tous les prérequis pour les tests d'intégration mobile-backend
**Usage:**
```powershell
.\start-integration-tests.ps1
```
**Vérifie:**
- ✓ Backend Quarkus (port 8085)
- ✓ Keycloak (port 8180)
- ✓ PostgreSQL (port 5432)
- ✓ Realm `unionflow` existe
**Sortie:** Guide de démarrage si tout est prêt, ou instructions pour corriger les problèmes
---
### 2. `check-keycloak-state.ps1`
**Description:** Affiche l'état complet de Keycloak (realm unionflow)
**Usage:**
```powershell
.\check-keycloak-state.ps1
```
**Affiche:**
- Liste des realms
- Utilisateurs du realm unionflow
- Clients configurés
- État du client `unionflow-mobile`
---
### 3. `list-user-roles.ps1`
**Description:** Liste les rôles des utilisateurs Keycloak
**Usage:**
```powershell
# Lister tous les utilisateurs et leurs rôles
.\list-user-roles.ps1
# Lister les rôles d'un utilisateur spécifique
.\list-user-roles.ps1 -Username "admin.meska@unionflow.test"
```
**Affiche:**
- Rôles de chaque utilisateur
- Liste de tous les rôles disponibles dans le realm
---
## 📋 Ordre d'Exécution Recommandé
### Pour démarrer les tests d'intégration:
```powershell
# 1. Vérifier les prérequis
.\start-integration-tests.ps1
# 2. Si tout est OK, vérifier l'état de Keycloak
.\check-keycloak-state.ps1
# 3. Voir les rôles des utilisateurs de test
.\list-user-roles.ps1 -Username "admin.meska@unionflow.test"
.\list-user-roles.ps1 -Username "membre.meska@unionflow.test"
```
### Puis lancer l'app mobile:
```bash
cd unionflow/unionflow-mobile-apps
flutter run --dart-define=ENV=dev
```
---
## 🆘 Troubleshooting
### Erreur "script cannot be loaded because running scripts is disabled"
**Solution:** Exécuter PowerShell en tant qu'administrateur et autoriser l'exécution:
```powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
```
### Erreur "Connection refused" sur Keycloak
**Solution:** Démarrer Keycloak:
```bash
cd unionflow
docker-compose up -d keycloak
```
### Erreur "admin/admin credentials invalid"
**Solution:** Vérifier les credentials admin Keycloak dans docker-compose.yml
---
## 📚 Documentation Associée
- **Guide de tests:** `../docs/TESTS_INTEGRATION_FINANCE_WORKFLOW.md`
- **Architecture mobile:** `../docs/UNIONFLOW_DESIGN_V2.md`
---
**Créé:** 2026-03-14
**Dernière mise à jour:** 2026-03-14

View File

@@ -0,0 +1,34 @@
# Script pour auditer les use cases de chaque feature
$featuresPath = "C:\Users\dadyo\PersonalProjects\lions-workspace\unionflow\unionflow-mobile-apps\lib\features"
Write-Host "=== Audit Use Cases par Feature ===" -ForegroundColor Cyan
Write-Host ""
$features = Get-ChildItem -Path $featuresPath -Directory
foreach ($feature in $features) {
$usecasesPath = Join-Path $feature.FullName "domain\usecases"
if (Test-Path $usecasesPath) {
$usecases = Get-ChildItem -Path $usecasesPath -Filter "*.dart" -File
Write-Host "[$($feature.Name)]" -ForegroundColor Yellow
Write-Host " Use cases: $($usecases.Count)"
if ($usecases.Count -gt 0) {
foreach ($usecase in $usecases) {
$name = $usecase.Name -replace '\.dart$', ''
Write-Host " - $name" -ForegroundColor Gray
}
} else {
Write-Host " (aucun use case trouvé)" -ForegroundColor Red
}
Write-Host ""
}
}
Write-Host "=== Résumé ===" -ForegroundColor Cyan
$totalFeatures = ($features | Where-Object { Test-Path (Join-Path $_.FullName "domain\usecases") }).Count
Write-Host "Features avec use cases: $totalFeatures"

View File

@@ -0,0 +1,86 @@
# Script pour vérifier l'état de Keycloak (realm unionflow)
# Usage: .\check-keycloak-state.ps1
Write-Host "=== Vérification Keycloak ===" -ForegroundColor Cyan
Write-Host ""
try {
# Test connexion Keycloak
$testUrl = Invoke-WebRequest -Uri 'http://localhost:8180' -UseBasicParsing -Method Get
Write-Host "[OK] Keycloak accessible" -ForegroundColor Green
} catch {
Write-Host "[ERREUR] Keycloak non accessible sur http://localhost:8180" -ForegroundColor Red
Write-Host "Démarrer avec: docker-compose up -d keycloak" -ForegroundColor Yellow
exit 1
}
# Obtenir le token admin
try {
$tokenResponse = Invoke-RestMethod -Method Post `
-Uri 'http://localhost:8180/realms/master/protocol/openid-connect/token' `
-ContentType 'application/x-www-form-urlencoded' `
-Body 'username=admin&password=admin&grant_type=password&client_id=admin-cli'
$token = $tokenResponse.access_token
Write-Host "[OK] Authentifié avec succès" -ForegroundColor Green
Write-Host ""
} catch {
Write-Host "[ERREUR] Impossible de s'authentifier à Keycloak" -ForegroundColor Red
Write-Host "Vérifier les credentials admin/admin" -ForegroundColor Yellow
exit 1
}
# Lister les realms
$realms = Invoke-RestMethod -Method Get `
-Uri 'http://localhost:8180/admin/realms' `
-Headers @{ Authorization = "Bearer $token" }
Write-Host "=== REALMS DISPONIBLES ===" -ForegroundColor Cyan
$realms | ForEach-Object { Write-Host " - $($_.realm)" }
# Vérifier realm unionflow
$unionflow = $realms | Where-Object { $_.realm -eq 'unionflow' }
if (-not $unionflow) {
Write-Host "`n[ERREUR] Realm 'unionflow' non trouvé" -ForegroundColor Red
exit 1
}
Write-Host "`n[OK] Realm 'unionflow' existe" -ForegroundColor Green
# Utilisateurs
$users = Invoke-RestMethod -Method Get `
-Uri 'http://localhost:8180/admin/realms/unionflow/users' `
-Headers @{ Authorization = "Bearer $token" }
Write-Host "`n=== UTILISATEURS (total: $($users.Count)) ===" -ForegroundColor Cyan
$users | ForEach-Object {
Write-Host " - $($_.username) | $($_.email)"
}
# Clients
$clients = Invoke-RestMethod -Method Get `
-Uri 'http://localhost:8180/admin/realms/unionflow/clients' `
-Headers @{ Authorization = "Bearer $token" }
Write-Host "`n=== CLIENTS ===" -ForegroundColor Cyan
$mobileClient = $null
$clients | Where-Object { $_.clientId -like '*unionflow*' } | ForEach-Object {
Write-Host " - $($_.clientId)"
if ($_.clientId -eq 'unionflow-mobile') {
$mobileClient = $_
}
}
if ($mobileClient) {
Write-Host "`n[OK] Client 'unionflow-mobile' existe" -ForegroundColor Green
} else {
Write-Host "`n[ERREUR] Client 'unionflow-mobile' non trouvé" -ForegroundColor Red
}
Write-Host "`n=== RÉSUMÉ ===" -ForegroundColor Cyan
Write-Host "Realm unionflow: OK" -ForegroundColor Green
Write-Host "Client unionflow-mobile: $(if ($mobileClient) { 'OK' } else { 'MANQUANT' })" -ForegroundColor $(if ($mobileClient) { 'Green' } else { 'Red' })
Write-Host "Utilisateurs: $($users.Count)"
Write-Host ""
Write-Host "Prêt pour les tests d'intégration mobile !" -ForegroundColor Green

View File

@@ -0,0 +1,41 @@
# Keycloak - Lire les rôles et la config du realm unionflow
# Usage: .\keycloak_get_roles.ps1
# Prérequis: Keycloak sur http://localhost:8180, admin/admin
$baseUrl = 'http://localhost:8180'
$body = @{
username = 'admin'
password = 'admin'
grant_type = 'password'
client_id = 'admin-cli'
}
Write-Host "1. Obtention du token admin (realm master)..." -ForegroundColor Cyan
try {
$tokenResponse = Invoke-RestMethod -Uri "$baseUrl/realms/master/protocol/openid-connect/token" -Method Post -Body $body -ContentType 'application/x-www-form-urlencoded'
$token = $tokenResponse.access_token
Write-Host " Token obtenu (expire dans $($tokenResponse.expires_in) s)" -ForegroundColor Green
} catch {
Write-Host " Erreur: $_" -ForegroundColor Red
exit 1
}
Write-Host "`n2. Rôles du realm unionflow:" -ForegroundColor Cyan
try {
$roles = Invoke-RestMethod -Uri "$baseUrl/admin/realms/unionflow/roles" -Headers @{ Authorization = "Bearer $token" }
$roles | ForEach-Object { Write-Host " - $($_.name)" }
if (-not $roles) { Write-Host " (aucun rôle ou realm inexistant)" -ForegroundColor Yellow }
} catch {
Write-Host " Erreur: $_" -ForegroundColor Red
}
Write-Host "`n3. Config du realm unionflow (realm, displayName):" -ForegroundColor Cyan
try {
$realm = Invoke-RestMethod -Uri "$baseUrl/admin/realms/unionflow" -Headers @{ Authorization = "Bearer $token" }
Write-Host " realm: $($realm.realm)"
Write-Host " displayName: $($realm.displayName)"
} catch {
Write-Host " Erreur: $_" -ForegroundColor Red
}
Write-Host "`nTerminé." -ForegroundColor Green

View File

@@ -0,0 +1,77 @@
# Keycloak lire les rôles et la config UnionFlow (curl)
Base URL Keycloak : **http://localhost:8180**
Identifiants admin : **username=admin**, **password=admin**.
## 1. Obtenir un token admin (realm master)
```bash
curl -s -X POST "http://localhost:8180/realms/master/protocol/openid-connect/token" ^
-H "Content-Type: application/x-www-form-urlencoded" ^
-d "username=admin" ^
-d "password=admin" ^
-d "grant_type=password" ^
-d "client_id=admin-cli"
```
Sous Linux/macOS, remplacer `^` par `\`.
Réponse attendue : JSON avec `access_token`, `expires_in`, etc.
Copier la valeur de `access_token` pour les appels suivants (ou parser avec `jq` : `... | jq -r .access_token`).
## 2. Lister les rôles du realm **unionflow**
Remplacez `ACCESS_TOKEN` par le token obtenu à létape 1.
```bash
curl -s -H "Authorization: Bearer ACCESS_TOKEN" ^
"http://localhost:8180/admin/realms/unionflow/roles"
```
Rôles typiques côté UnionFlow : `ADMIN`, `ADMIN_ORGANISATION`, `MEMBRE`, `MODERATEUR`, etc.
## 3. Récupérer la configuration du realm **unionflow**
```bash
curl -s -H "Authorization: Bearer ACCESS_TOKEN" ^
"http://localhost:8180/admin/realms/unionflow"
```
Contient la config générale du realm (nom, login, thème, tokens, etc.).
## 4. Rôles par client (ex. application UnionFlow)
Si les rôles sont définis sur un client (client scope), lister les rôles du client :
```bash
# Récupérer lid du client (ex. unionflow-mobile ou account)
curl -s -H "Authorization: Bearer ACCESS_TOKEN" ^
"http://localhost:8180/admin/realms/unionflow/clients?clientId=unionflow-mobile"
# Puis lister les rôles du client (remplacer CLIENT_UUID par lid du client)
curl -s -H "Authorization: Bearer ACCESS_TOKEN" ^
"http://localhost:8180/admin/realms/unionflow/clients/CLIENT_UUID/roles"
```
## 5. Exemple PowerShell (token + rôles en une fois)
```powershell
$body = @{
username = 'admin'
password = 'admin'
grant_type = 'password'
client_id = 'admin-cli'
}
$tokenResponse = Invoke-RestMethod -Uri 'http://localhost:8180/realms/master/protocol/openid-connect/token' -Method Post -Body $body -ContentType 'application/x-www-form-urlencoded'
$token = $tokenResponse.access_token
# Rôles du realm unionflow
Invoke-RestMethod -Uri 'http://localhost:8180/admin/realms/unionflow/roles' -Headers @{ Authorization = "Bearer $token" }
# Config du realm unionflow
Invoke-RestMethod -Uri 'http://localhost:8180/admin/realms/unionflow' -Headers @{ Authorization = "Bearer $token" }
```
## Note
LAPI Admin Keycloak (`/admin/realms/...`) exige un utilisateur du realm **master** (admin). Les rôles visibles dans le JWT des utilisateurs connectés à lapp (realm **unionflow**) viennent du realm **unionflow** (realm roles ou client roles selon la config).

View File

@@ -0,0 +1,62 @@
# Script pour lister les rôles des utilisateurs Keycloak
# Usage: .\list-user-roles.ps1 [username]
# Exemple: .\list-user-roles.ps1 admin.meska@unionflow.test
param(
[string]$Username = ""
)
Write-Host "=== Rôles des Utilisateurs (Realm: unionflow) ===" -ForegroundColor Cyan
Write-Host ""
# Obtenir le token admin
$tokenResponse = Invoke-RestMethod -Method Post `
-Uri 'http://localhost:8180/realms/master/protocol/openid-connect/token' `
-ContentType 'application/x-www-form-urlencoded' `
-Body 'username=admin&password=admin&grant_type=password&client_id=admin-cli'
$token = $tokenResponse.access_token
# Récupérer les utilisateurs
$users = Invoke-RestMethod -Method Get `
-Uri 'http://localhost:8180/admin/realms/unionflow/users' `
-Headers @{ Authorization = "Bearer $token" }
# Filtrer si un username est spécifié
if ($Username) {
$users = $users | Where-Object { $_.username -eq $Username }
if (-not $users) {
Write-Host "[ERREUR] Utilisateur '$Username' non trouvé" -ForegroundColor Red
exit 1
}
}
# Parcourir les utilisateurs
foreach ($user in $users) {
Write-Host "[$($user.username)]" -ForegroundColor Yellow
Write-Host " Email: $($user.email)"
Write-Host " Enabled: $($user.enabled)"
# Realm roles
$realmRoles = Invoke-RestMethod -Method Get `
-Uri "http://localhost:8180/admin/realms/unionflow/users/$($user.id)/role-mappings/realm" `
-Headers @{ Authorization = "Bearer $token" }
if ($realmRoles) {
Write-Host " Rôles:"
$realmRoles | Where-Object { $_.name -ne 'default-roles-unionflow' -and $_.name -ne 'offline_access' -and $_.name -ne 'uma_authorization' } | ForEach-Object {
Write-Host " - $($_.name)" -ForegroundColor Green
}
}
Write-Host ""
}
Write-Host "=== Rôles Disponibles ===" -ForegroundColor Cyan
$allRoles = Invoke-RestMethod -Method Get `
-Uri "http://localhost:8180/admin/realms/unionflow/roles" `
-Headers @{ Authorization = "Bearer $token" }
$allRoles | Where-Object { $_.name -notlike 'default-*' -and $_.name -ne 'offline_access' -and $_.name -ne 'uma_authorization' } | ForEach-Object {
Write-Host " - $($_.name)"
}

View File

@@ -0,0 +1,90 @@
# Script de démarrage pour les tests d'intégration mobile-backend
# Vérifie tous les prérequis et guide l'utilisateur
Write-Host "=== Démarrage Tests d'Intégration Finance Workflow ===" -ForegroundColor Cyan
Write-Host ""
$allGood = $true
# 1. Vérifier Quarkus
Write-Host "[1/3] Vérification Backend Quarkus..." -ForegroundColor Yellow
try {
$quarkusHealth = Invoke-RestMethod -Uri 'http://localhost:8085/q/health' -Method Get
Write-Host " [OK] Quarkus actif sur port 8085" -ForegroundColor Green
} catch {
Write-Host " [KO] Quarkus non accessible" -ForegroundColor Red
Write-Host " Démarrer avec:" -ForegroundColor Yellow
Write-Host " cd unionflow/unionflow-server-impl-quarkus" -ForegroundColor Gray
Write-Host " mvn compile quarkus:dev -D`"quarkus.http.port=8085`"" -ForegroundColor Gray
$allGood = $false
}
# 2. Vérifier Keycloak
Write-Host "`n[2/3] Vérification Keycloak..." -ForegroundColor Yellow
try {
$keycloakTest = Invoke-WebRequest -Uri 'http://localhost:8180' -UseBasicParsing -Method Get
Write-Host " [OK] Keycloak actif sur port 8180" -ForegroundColor Green
# Vérifier realm unionflow
$tokenResponse = Invoke-RestMethod -Method Post `
-Uri 'http://localhost:8180/realms/master/protocol/openid-connect/token' `
-ContentType 'application/x-www-form-urlencoded' `
-Body 'username=admin&password=admin&grant_type=password&client_id=admin-cli'
$token = $tokenResponse.access_token
$realms = Invoke-RestMethod -Method Get `
-Uri 'http://localhost:8180/admin/realms' `
-Headers @{ Authorization = "Bearer $token" }
$unionflow = $realms | Where-Object { $_.realm -eq 'unionflow' }
if ($unionflow) {
Write-Host " [OK] Realm 'unionflow' existe" -ForegroundColor Green
} else {
Write-Host " [KO] Realm 'unionflow' manquant" -ForegroundColor Red
$allGood = $false
}
} catch {
Write-Host " [KO] Keycloak non accessible" -ForegroundColor Red
Write-Host " Démarrer avec:" -ForegroundColor Yellow
Write-Host " cd unionflow" -ForegroundColor Gray
Write-Host " docker-compose up -d keycloak" -ForegroundColor Gray
$allGood = $false
}
# 3. Vérifier PostgreSQL
Write-Host "`n[3/3] Vérification PostgreSQL..." -ForegroundColor Yellow
try {
$pgTest = Test-NetConnection -ComputerName localhost -Port 5432 -WarningAction SilentlyContinue
if ($pgTest.TcpTestSucceeded) {
Write-Host " [OK] PostgreSQL actif sur port 5432" -ForegroundColor Green
} else {
Write-Host " [KO] PostgreSQL non accessible" -ForegroundColor Red
Write-Host " Démarrer avec:" -ForegroundColor Yellow
Write-Host " cd unionflow" -ForegroundColor Gray
Write-Host " docker-compose up -d postgres" -ForegroundColor Gray
$allGood = $false
}
} catch {
Write-Host " [KO] Impossible de vérifier PostgreSQL" -ForegroundColor Red
$allGood = $false
}
# Résumé
Write-Host "`n=== RÉSUMÉ ===" -ForegroundColor Cyan
if ($allGood) {
Write-Host "[OK] Tous les services sont prêts !" -ForegroundColor Green
Write-Host ""
Write-Host "Prochaine étape:" -ForegroundColor Yellow
Write-Host " 1. Lancer l'app mobile:" -ForegroundColor Gray
Write-Host " cd unionflow/unionflow-mobile-apps" -ForegroundColor Gray
Write-Host " flutter run --dart-define=ENV=dev" -ForegroundColor Gray
Write-Host ""
Write-Host " 2. Consulter le guide de test:" -ForegroundColor Gray
Write-Host " unionflow-mobile-apps/docs/TESTS_INTEGRATION_FINANCE_WORKFLOW.md" -ForegroundColor Gray
Write-Host ""
} else {
Write-Host "[KO] Certains services ne sont pas prêts" -ForegroundColor Red
Write-Host "Corriger les problèmes ci-dessus avant de lancer les tests" -ForegroundColor Yellow
}