fix(tests): UTF-8 in Invoke-Api korrekt escapen fuer PS5.1 Kompatibilitaet

PS5.1 kodiert String-Bodies in Invoke-RestMethod mit der Windows-Systemkodierung
(Windows-1252) statt UTF-8. Fix: Non-ASCII-Zeichen werden vor dem Senden als
\uXXXX escaped, sodass der HTTP-Body reines ASCII ist und korrekt interpretiert
wird. Schliesst die UTF-8-Testfaelle (Szenario 6a) vollstaendig ab: 35/35 PASS.
This commit is contained in:
Jens Reinemann 2026-05-17 22:33:45 +02:00
parent 90cfac70a0
commit 00e3f88980

View file

@ -1,4 +1,4 @@
<# <#
.SYNOPSIS .SYNOPSIS
Bollwerk Integration Test Suite Bollwerk Integration Test Suite
.DESCRIPTION .DESCRIPTION
@ -60,6 +60,16 @@ function Invoke-Api {
$headers = @{ "Content-Type" = "application/json" } $headers = @{ "Content-Type" = "application/json" }
if ($Token) { $headers["Authorization"] = "Bearer $Token" } if ($Token) { $headers["Authorization"] = "Bearer $Token" }
$bodyJson = if ($Body) { $Body | ConvertTo-Json -Depth 10 -Compress } else { $null } $bodyJson = if ($Body) { $Body | ConvertTo-Json -Depth 10 -Compress } else { $null }
# PS5.1 sendet String-Body mit Windows-Systemkodierung statt UTF-8.
# Alle Non-ASCII-Zeichen als \uXXXX escapen → Body ist ASCII-sicher.
if ($bodyJson) {
$sb = [System.Text.StringBuilder]::new($bodyJson.Length * 2)
foreach ($ch in $bodyJson.ToCharArray()) {
if ([int]$ch -gt 127) { [void]$sb.Append('\u{0:x4}' -f [int]$ch) }
else { [void]$sb.Append($ch) }
}
$bodyJson = $sb.ToString()
}
try { try {
$response = Invoke-RestMethod -Method $Method ` $response = Invoke-RestMethod -Method $Method `
-Uri "$BaseUrl$Path" ` -Uri "$BaseUrl$Path" `