fix: Export-RdpRepairDiagnosticReport ломался на одном cert (foreach PS 5.1)
foreach по PSCustomObject перечисляет свойства, не cert — нужен @(). Рекурсивное flatten в Get-RdpRepairCertificateArray, самотест Export-паттерна. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -100,6 +100,22 @@ Assert-Test 'Get-RdpRepairCertificateArray flattens nested Object[]' {
|
||||
if ($first.Thumbprint -ne 'NESTED01') { throw "expected NESTED01 got $($first.Thumbprint)" }
|
||||
}
|
||||
|
||||
Assert-Test 'foreach must use @() wrapper on single cert (Export pattern)' {
|
||||
$mock = [PSCustomObject]@{
|
||||
Thumbprint = 'LOOP01'
|
||||
Subject = 'CN=loop'
|
||||
NotAfter = (Get-Date).AddDays(1)
|
||||
HasKey = $true
|
||||
}
|
||||
$lines = @()
|
||||
foreach ($c in @(Get-RdpRepairCertificateArray @($mock))) {
|
||||
$lines += $c.Subject
|
||||
}
|
||||
if ($lines.Count -ne 1 -or $lines[0] -ne 'CN=loop') {
|
||||
throw "expected CN=loop got $($lines -join ',')"
|
||||
}
|
||||
}
|
||||
|
||||
Assert-Test 'Get-RdpRepairDiagnosticSnapshot object shape' {
|
||||
if (-not (Test-RdpRepairIsAdministrator)) {
|
||||
Write-Host ' (skip snapshot fields - not admin)' -ForegroundColor DarkYellow
|
||||
|
||||
Reference in New Issue
Block a user