Files
PowerShell-PowerShell/test/powershell/engine/Remoting/SSHRemotingAPI.Tests.ps1
T
Paul Higinbotham 0ba1e2d9d1 Minor improvements to SSH remoting cmdlets (#2249)
* Fix for relative paths for KeyFilePath cmdlet parameter, renamed cmdlet KeyPath parameter to KeyFilePath parameter, and added tests.

* Code review comment update

* Added missing KeyFilePath check

* Test fix from review comment
2016-09-14 15:13:10 -07:00

66 lines
2.4 KiB
PowerShell

Describe "SSH Remoting API Tests" -Tags "Feature" {
Context "SSHConnectionInfo Class Tests" {
It "SSHConnectionInfo constructor should throw null argument exception for null UserName parameter" {
try
{
[System.Management.Automation.Runspaces.SSHConnectionInfo]::new(
[System.Management.Automation.Internal.AutomationNull]::Value,
"localhost",
[System.Management.Automation.Internal.AutomationNull]::Value)
throw "SSHConnectionInfo constructor did not throw expected PSArgumentNullException exception"
}
catch
{
$_.FullyQualifiedErrorId | Should Match "PSArgumentNullException"
}
}
It "SSHConnectionInfo constructor should throw null argument exception for null HostName parameter" {
try
{
[System.Management.Automation.Runspaces.SSHConnectionInfo]::new(
"UserName",
[System.Management.Automation.Internal.AutomationNull]::Value,
[System.Management.Automation.Internal.AutomationNull]::Value)
throw "SSHConnectionInfo constructor did not throw expected PSArgumentNullException exception"
}
catch
{
$_.FullyQualifiedErrorId | Should Match "PSArgumentNullException"
}
}
It "SSHConnectionInfo should throw file not found exception for invalid key file path" {
try
{
$sshConnectionInfo = [System.Management.Automation.Runspaces.SSHConnectionInfo]::new(
"UserName",
"localhost",
"NoValidKeyFilePath")
$rs = [runspacefactory]::CreateRunspace($sshConnectionInfo)
$rs.Open()
throw "SSHConnectionInfo did not throw expected FileNotFoundException exception"
}
catch
{
$expectedFileNotFoundExecption = $null
if (($_.Exception -ne $null) -and ($_.Exception.InnerException -ne $null))
{
$expectedFileNotFoundExecption = $_.Exception.InnerException.InnerException
}
($expectedFileNotFoundExecption.GetType().FullName) | Should Be "System.IO.FileNotFoundException"
}
}
}
}