fix test failures on win7 (#335)

This commit is contained in:
Yanbing 2018-08-01 12:31:10 -07:00 committed by GitHub
parent 0f9808f190
commit fde0994a30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 16 deletions

View File

@ -56,7 +56,7 @@ Describe "E2E scenarios for ssh key management" -Tags "CI" {
$a.PropagationFlags | Should Be ([System.Security.AccessControl.PropagationFlags]::None) $a.PropagationFlags | Should Be ([System.Security.AccessControl.PropagationFlags]::None)
} }
$entries = Get-ChildItem $agentPath\keys $entries = @(Get-ChildItem $agentPath\keys)
$entries.Count | Should Be $count $entries.Count | Should Be $count
if($count -gt 0) if($count -gt 0)
{ {
@ -241,6 +241,12 @@ Describe "E2E scenarios for ssh key management" -Tags "CI" {
foreach($type in $keytypes) foreach($type in $keytypes)
{ {
$keyPath = Join-Path $testDir "id_$type" $keyPath = Join-Path $testDir "id_$type"
# for ssh-add to consume SSh_ASKPASS, stdin should not be TTY
iex "cmd /c `"ssh-add $keyPath < $nullFile 2> nul `""
#Check if -Raw presents for Get-Content cmdlet
$rawParam = (get-command Get-Content).Parametersets | Select -ExpandProperty Parameters | ? {$_.Name -ieq "Raw"}
if($rawParam)
{
$keyPathDifferentEnding = Join-Path $testDir "id_$($type)_DifferentEnding" $keyPathDifferentEnding = Join-Path $testDir "id_$($type)_DifferentEnding"
if((Get-Content -Path $keyPath -raw).Contains("`r`n")) if((Get-Content -Path $keyPath -raw).Contains("`r`n"))
{ {
@ -252,10 +258,9 @@ Describe "E2E scenarios for ssh key management" -Tags "CI" {
} }
Set-content -Path $keyPathDifferentEnding -value "$newcontent" Set-content -Path $keyPathDifferentEnding -value "$newcontent"
Repair-UserKeyPermission $keyPathDifferentEnding -confirm:$false Repair-UserKeyPermission $keyPathDifferentEnding -confirm:$false
# for ssh-add to consume SSh_ASKPASS, stdin should not be TTY
iex "cmd /c `"ssh-add $keyPath < $nullFile 2> nul `""
iex "cmd /c `"ssh-add $keyPathDifferentEnding < $nullFile 2> nul `"" iex "cmd /c `"ssh-add $keyPathDifferentEnding < $nullFile 2> nul `""
} }
}
#remove SSH_ASKPASS #remove SSH_ASKPASS
Remove-PasswordSetting Remove-PasswordSetting
@ -290,7 +295,7 @@ Describe "E2E scenarios for ssh key management" -Tags "CI" {
@($allkeys | where { $_.contains($pubkeyraw) }).count | Should Be 0 @($allkeys | where { $_.contains($pubkeyraw) }).count | Should Be 0
} }
$allkeys = ssh-add -L $allkeys = @(ssh-add -L)
ValidateRegistryACL -count $allkeys.count ValidateRegistryACL -count $allkeys.count
} }
} }

View File

@ -294,7 +294,7 @@ Describe "E2E scenarios for ssh client" -Tags "CI" {
$nul | Set-Content $kh $nul | Set-Content $kh
# doing via cmd to intercept and drain stderr output # doing via cmd to intercept and drain stderr output
iex "cmd /c `"ssh -o UserKnownHostsFile=`"$kh`" -o StrictHostKeyChecking=no test_target hostname 2>&1`"" iex "cmd /c `"ssh -o UserKnownHostsFile=`"$kh`" -o StrictHostKeyChecking=no test_target hostname 2>&1`""
(Get-Content $kh).Count | Should Be 1 @(Get-Content $kh).Count | Should Be 1
} }
} }