@@ -5,9 +5,9 @@ Import-Module $PSScriptRoot\CommonUtils.psm1 -Force
5
5
$tC = 1
6
6
$tI = 0
7
7
$suite = " sshclient"
8
-
8
+
9
9
Describe " E2E scenarios for ssh client" - Tags " CI" {
10
- BeforeAll {
10
+ BeforeAll {
11
11
if ($OpenSSHTestInfo -eq $null )
12
12
{
13
13
Throw " `$ OpenSSHTestInfo is null. Please run Set-OpenSSHTestEnvironment to set test environments."
@@ -27,12 +27,12 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
27
27
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($ssouser , $rights , " ContainerInherit,Objectinherit" , " None" , " Allow" )
28
28
$acl.SetAccessRule ($accessRule )
29
29
Set-Acl - Path $testDir - AclObject $acl
30
- # skip on ps 2 becase non-interactive cmd require a ENTER before it returns on ps2
30
+ # skip on ps 2 because non-interactive cmd require a ENTER before it returns on ps2
31
31
$skip = $IsWindows -and ($PSVersionTable.PSVersion.Major -le 2 )
32
32
33
33
<# $testData = @(
34
34
@{
35
- Title = 'Simple logon no option';
35
+ Title = 'Simple logon no option';
36
36
LogonStr = "$($server.localAdminUserName)@$($server.MachineName)"
37
37
Options = ""
38
38
},
@@ -42,7 +42,7 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
42
42
Options = "-C -l $($server.localAdminUserName)"
43
43
}
44
44
)
45
-
45
+
46
46
$testData1 = @(
47
47
@{
48
48
Title = "logon using -i -q option"
@@ -84,7 +84,7 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
84
84
[string ] $default_shell_path ,
85
85
[string ] $default_shell_cmd_option_val = $null
86
86
)
87
-
87
+
88
88
if (! (Test-Path $dfltShellRegPath )) {
89
89
New-Item - Path $dfltShellRegPath - Force | Out-Null
90
90
}
@@ -99,12 +99,12 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
99
99
$stderrFile = Join-Path $testDir " $tC .$tI .stderr.txt"
100
100
$stdoutFile = Join-Path $testDir " $tC .$tI .stdout.txt"
101
101
$logFile = Join-Path $testDir " $tC .$tI .log.txt"
102
- }
102
+ }
103
103
104
104
AfterEach {$tI ++ ;}
105
105
106
106
Context " $tC - Basic Scenarios" {
107
-
107
+
108
108
BeforeAll {$tI = 1 }
109
109
AfterAll{$tC ++ }
110
110
@@ -117,13 +117,13 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
117
117
iex " cmd /c `" ssh -? 2> $stderrFile `" "
118
118
$stderrFile | Should Contain " usage: ssh"
119
119
}
120
-
120
+
121
121
It " $tC .$tI - remote echo command" {
122
122
iex " $sshDefaultCmd echo 1234" | Should Be " 1234"
123
123
}
124
124
125
125
}
126
-
126
+
127
127
Context " $tC - exit code (exit-status.sh)" {
128
128
BeforeAll {$tI = 1 }
129
129
AfterAll{$tC ++ }
@@ -132,12 +132,12 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
132
132
foreach ($i in (0 , 1 , 4 , 5 , 44 )) {
133
133
ssh - p $port $ssouser @$server exit $i
134
134
$LASTEXITCODE | Should Be $i
135
- }
135
+ }
136
136
}
137
137
}
138
138
139
139
Context " $tC - Redirection Scenarios" {
140
-
140
+
141
141
BeforeAll {$tI = 1 }
142
142
AfterAll{$tC ++ }
143
143
@@ -192,7 +192,7 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
192
192
193
193
}
194
194
}
195
-
195
+
196
196
Context " $tC - configure powershell default shell Scenarios" {
197
197
BeforeAll {
198
198
$tI = 1
@@ -205,13 +205,13 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
205
205
$tC ++
206
206
Remove-ItemProperty - Path $dfltShellRegPath - Name $dfltShellRegKeyName - ErrorAction SilentlyContinue
207
207
Remove-ItemProperty - Path $dfltShellRegPath - Name $dfltShellCmdOptionRegKeyName - ErrorAction SilentlyContinue
208
- }
208
+ }
209
209
210
210
It " $tC .$tI - basic powershell" - skip:$skip {
211
211
$o = ssh test_target Write-Output 1234
212
212
$o | Should Be " 1234"
213
213
}
214
-
214
+
215
215
It " $tC .$tI - basic in powershell cmdlet" - skip:$skip {
216
216
$o = ssh test_target " cd `$ env:ProgramFiles;pwd"
217
217
$LASTEXITCODE | Should Be 0
@@ -240,7 +240,7 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
240
240
It " $tC .$tI - single quotes in powershell cmdlet" - skip:$skip {
241
241
# actual command line ssh target echo '$env:computername'
242
242
$o = ssh test_target " echo '`$ env:computername'"
243
- $LASTEXITCODE | Should Be 0
243
+ $LASTEXITCODE | Should Be 0
244
244
$o | Should Be `$ env:computername
245
245
}
246
246
}
@@ -257,9 +257,9 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
257
257
Remove-ItemProperty - Path $dfltShellRegPath - Name $dfltShellRegKeyName - ErrorAction SilentlyContinue
258
258
Remove-ItemProperty - Path $dfltShellRegPath - Name $dfltShellCmdOptionRegKeyName - ErrorAction SilentlyContinue
259
259
}
260
- It " $tC .$tI - default shell as cmd" - skip:$skip {
260
+ It " $tC .$tI - default shell as cmd" - skip:$skip {
261
261
$o = ssh test_target where cmd
262
- $o | Should Contain " cmd"
262
+ $o | Should Contain " cmd"
263
263
}
264
264
It " $tC .$tI - cmd as default shell and double quotes in cmdline" {
265
265
# actual command line ssh target echo "hello"
@@ -269,7 +269,7 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
269
269
It " $tC .$tI - single quotes in powershell cmdlet" - skip:$skip {
270
270
# actual command line ssh target echo '$env:computername'
271
271
$o = ssh test_target " echo 'hello'"
272
- $LASTEXITCODE | Should Be 0
272
+ $LASTEXITCODE | Should Be 0
273
273
$o | Should Be " 'hello'"
274
274
}
275
275
}
@@ -290,15 +290,15 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
290
290
$o | Should Be " `" hello`" "
291
291
}
292
292
}
293
-
294
- Context " $tC - cmdline parameters" {
293
+
294
+ Context " $tC - cmdline parameters" {
295
295
BeforeAll {$tI = 1 }
296
296
AfterAll{$tC ++ }
297
297
298
298
It " $tC .$tI - verbose to file (-v -E)" {
299
299
$o = ssh - v - E $logFile test_target echo 1234
300
300
$o | Should Be " 1234"
301
- # TODO - checks below are very inefficient (time taking).
301
+ # TODO - checks below are very inefficient (time taking).
302
302
$logFile | Should Contain " OpenSSH_"
303
303
$logFile | Should Contain " Exit Status 0"
304
304
}
@@ -333,11 +333,11 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
333
333
" Port $port " | Add-Content $goodConfigFile
334
334
" User $ssouser " | Add-Content $goodConfigFile
335
335
$o = ssh -F $goodConfigFile myhost echo 1234
336
- $o | Should Be " 1234"
336
+ $o | Should Be " 1234"
337
337
}
338
338
339
339
It " $tC .$tI - IP options - (-4) (-6)" {
340
- # TODO - this test assumes target is localhost.
340
+ # TODO - this test assumes target is localhost.
341
341
# make it work independent of target
342
342
# -4
343
343
$o = ssh -4 - v - E $logFile test_target echo 1234
@@ -346,11 +346,23 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
346
346
# -4
347
347
$o = ssh -6 - v - E $logFile test_target echo 1234
348
348
$o | Should Be " 1234"
349
- $logFile | Should Contain " [::1]"
349
+ $logFile | Should Contain " [::1]"
350
+ }
351
+
352
+ It " $tC .$tI - tilde expand for path with forward slash" {
353
+ $o = ssh - v - i ~/ test/ key/ path - E $logFile test_target echo 1234
354
+ $o | Should Be " 1234"
355
+ $logFile | Should Not Contain " tilde_expand: No such user"
356
+ }
357
+
358
+ It " $tC .$tI - tilde expand for path with backslash" {
359
+ $o = ssh - v - i ~\test\key\path - E $logFile test_target echo 1234
360
+ $o | Should Be " 1234"
361
+ $logFile | Should Not Contain " tilde_expand: No such user"
350
362
}
351
363
352
364
It " $tC .$tI - auto populate known hosts" {
353
-
365
+
354
366
$kh = Join-Path $testDir " $tC .$tI .known_hosts"
355
367
$nul | Set-Content $kh
356
368
# doing via cmd to intercept and drain stderr output
0 commit comments