mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Close pipe client handles after creating the child ssh process (#26491)
This commit is contained in:
@@ -70,3 +70,24 @@ Describe "SSHConnection parameter hashtable type conversions" -Tags 'Feature', '
|
||||
$err.FullyQualifiedErrorId | Should -Match 'PSSessionOpenFailed'
|
||||
}
|
||||
}
|
||||
|
||||
Describe "No hangs when host doesn't exist" -Tags "CI" {
|
||||
$testCases = @(
|
||||
@{
|
||||
Name = 'Verifies no hang for New-PSSession with non-existing host name'
|
||||
ScriptBlock = { New-PSSession -HostName "test-notexist" -UserName "test" -ErrorAction Stop }
|
||||
FullyQualifiedErrorId = 'PSSessionOpenFailed'
|
||||
},
|
||||
@{
|
||||
Name = 'Verifies no hang for Invoke-Command with non-existing host name'
|
||||
ScriptBlock = { Invoke-Command -HostName "test-notexist" -UserName "test" -ScriptBlock { 1 } -ErrorAction Stop }
|
||||
FullyQualifiedErrorId = 'PSSessionStateBroken'
|
||||
}
|
||||
)
|
||||
|
||||
It "<Name>" -TestCases $testCases {
|
||||
param ($ScriptBlock, $FullyQualifiedErrorId)
|
||||
|
||||
$ScriptBlock | Should -Throw -ErrorId $FullyQualifiedErrorId -ExceptionType 'System.Management.Automation.Remoting.PSRemotingTransportException'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user