$ErrorActionPreference = "Stop" Write-Host "Testing Action Mappings Endpoint" -ForegroundColor Cyan Write-Host "="*60 # Try to login Write-Host "`n[1/3] Logging in..." -ForegroundColor Yellow $loginBody = @{ username = "admin" password = "admin" } try { $loginResponse = Invoke-RestMethod -Uri "http://localhost:8000/api/v1/auth/login" ` -Method Post ` -Body $loginBody ` -ContentType "application/x-www-form-urlencoded" $token = $loginResponse.access_token Write-Host " [OK] Login successful" -ForegroundColor Green } catch { Write-Host " [FAIL] Login failed" -ForegroundColor Red Write-Host "`nTrying alternative credentials..." -ForegroundColor Yellow $loginBody.password = "masterkey" try { $loginResponse = Invoke-RestMethod -Uri "http://localhost:8000/api/v1/auth/login" ` -Method Post ` -Body $loginBody ` -ContentType "application/x-www-form-urlencoded" $token = $loginResponse.access_token Write-Host " [OK] Login successful" -ForegroundColor Green } catch { Write-Host " [FAIL] All login attempts failed" -ForegroundColor Red exit 1 } } # Call action mappings endpoint Write-Host "`n[2/3] Calling action mappings endpoint..." -ForegroundColor Yellow $headers = @{ "Authorization" = "Bearer $token" } try { $response = Invoke-RestMethod -Uri "http://localhost:8000/api/v1/configuration/action-mappings/export" ` -Method Get ` -Headers $headers Write-Host " [OK] Request successful" -ForegroundColor Green } catch { Write-Host " [FAIL] Request failed" -ForegroundColor Red exit 1 } # Display results Write-Host "`n[3/3] Results:" -ForegroundColor Yellow Write-Host " Success: $($response.success)" Write-Host " Total Count: $($response.total_count)" if ($response.total_count -gt 0) { Write-Host "`nSUCCESS!" -ForegroundColor Green } else { Write-Host "`nFAILED: No mappings found" -ForegroundColor Red }