# Test correct login path
$body = '{"tenantCode":"T202605253515","username":"admin","password":"admin123"}'

Write-Host "=== Test /login on fs-company (8006) ==="
try {
    $r = Invoke-WebRequest -Uri 'http://localhost:8006/login' -Method Post -ContentType 'application/json' -Body $body -UseBasicParsing
    $json = $r.Content | ConvertFrom-Json
    Write-Host "Code: $($json.code), Msg: $($json.msg)"
    if ($json.token) {
        Write-Host "Token length: $($json.token.Length)"
        Write-Host "Token first 30: $($json.token.Substring(0,30))..."
    }
} catch {
    Write-Host "Error: $($_.Exception.Message)"
}

Write-Host "`n=== Test /login via frontend proxy (80) ==="
try {
    $r = Invoke-WebRequest -Uri 'http://localhost:80/prod-api/login' -Method Post -ContentType 'application/json' -Body $body -UseBasicParsing
    $json = $r.Content | ConvertFrom-Json
    Write-Host "Code: $($json.code), Msg: $($json.msg)"
    if ($json.token) {
        Write-Host "Token length: $($json.token.Length)"
    }
} catch {
    Write-Host "Error: $($_.Exception.Message)"
}
