- Added password management utilities for user administration - Added PowerShell scripts for testing attachment endpoints - Enhanced development and testing workflow capabilities - Completed v1.4.0 with all maintenance tools included"
46 lines
1.8 KiB
PowerShell
46 lines
1.8 KiB
PowerShell
# Test script para attachments endpoint
|
|
Write-Host "=== Testing Attachments Endpoint ===" -ForegroundColor Cyan
|
|
|
|
# 1. Login
|
|
$body = '{"email":"admin@aduanasoft.com","password":"admin123","tenant_slug":"aduanasoft"}'
|
|
try {
|
|
$login = Invoke-RestMethod -Uri "http://localhost:8000/v1/auth/login" -Method POST -Body $body -ContentType "application/json"
|
|
Write-Host "[OK] Login exitoso" -ForegroundColor Green
|
|
|
|
$token = $login.access_token
|
|
$tenantId = $login.user.tenant_id
|
|
|
|
Write-Host "Token: $($token.Substring(0,20))..." -ForegroundColor Gray
|
|
Write-Host "Tenant ID: $tenantId" -ForegroundColor Gray
|
|
|
|
# 2. Test attachments endpoint
|
|
$headers = @{
|
|
"Authorization" = "Bearer $token"
|
|
"X-Tenant-ID" = $tenantId
|
|
}
|
|
|
|
$url = "http://localhost:8000/v1/tickets/68eaf0fe-b5c3-4d42-9b36-895b439be583/attachments"
|
|
Write-Host "`nProbando GET $url" -ForegroundColor Yellow
|
|
|
|
try {
|
|
$response = Invoke-WebRequest -Uri $url -Headers $headers -Method GET
|
|
Write-Host "[OK] Status Code: $($response.StatusCode)" -ForegroundColor Green
|
|
|
|
$data = $response.Content | ConvertFrom-Json
|
|
Write-Host "[OK] Attachments encontrados: $($data.Count)" -ForegroundColor Green
|
|
|
|
if ($data.Count -gt 0) {
|
|
$data | Format-Table id, original_filename, file_size
|
|
} else {
|
|
Write-Host " (No hay attachments para este ticket)" -ForegroundColor Gray
|
|
}
|
|
|
|
} catch {
|
|
Write-Host "[ERROR] En request: $($_.Exception.Message)" -ForegroundColor Red
|
|
Write-Host "Status Code: $($_.Exception.Response.StatusCode.value__)" -ForegroundColor Red
|
|
}
|
|
|
|
} catch {
|
|
Write-Host "[ERROR] En login: $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|