forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSSHRemotingAPI.Tests.ps1
More file actions
67 lines (55 loc) · 2.23 KB
/
Copy pathSSHRemotingAPI.Tests.ps1
File metadata and controls
67 lines (55 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Describe "SSH Remoting API Tests" -Tags "Feature" {
Context "SSHConnectionInfo Class Tests" {
AfterEach {
if ($null -ne $rs) {
$rs.Dispose()
}
}
It "SSHConnectionInfo constructor should throw null argument exception for null HostName parameter" {
{ [System.Management.Automation.Runspaces.SSHConnectionInfo]::new(
"UserName",
[System.Management.Automation.Internal.AutomationNull]::Value,
[System.Management.Automation.Internal.AutomationNull]::Value,
0) } | ShouldBeErrorId "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",
22)
$rs = [runspacefactory]::CreateRunspace($sshConnectionInfo)
$rs.Open()
throw "No Exception!"
}
catch
{
$_.Exception.InnerException.InnerException | Should BeOfType "System.IO.FileNotFoundException"
}
}
It "SSHConnectionInfo should throw argument exception for invalid port (non 16bit uint)" {
try
{
$sshConnectionInfo = [System.Management.Automation.Runspaces.SSHConnectionInfo]::new(
"UserName",
"localhost",
"ValidKeyFilePath",
99999)
$rs = [runspacefactory]::CreateRunspace($sshConnectionInfo)
$rs.Open()
throw "No Exception!"
}
catch
{
$expectedArgumentException = $_.Exception
if ($null -ne $_.Exception.InnerException)
{
$expectedArgumentException = $_.Exception.InnerException
}
$expectedArgumentException | Should BeOfType "System.ArgumentException"
}
}
}
}