Updates needed for running test on windows inbox (#189)

Test updates needed for running test on windows inbox
This commit is contained in:
Yanbing 2017-08-02 17:16:06 -07:00 committed by GitHub
parent 70231622a2
commit 3c90af89a2
3 changed files with 51 additions and 16 deletions

View File

@ -313,12 +313,12 @@ function Install-OpenSSHUtilsModule
}
$modulePath = Join-Path -Path $env:ProgramFiles -ChildPath WindowsPowerShell\Modules
if(-not (Test-Path $targetDirectory -PathType Container))
if(-not (Test-Path "$targetDirectory" -PathType Container))
{
New-Item -ItemType Directory -Path $targetDirectory -Force -ErrorAction SilentlyContinue | out-null
New-Item -ItemType Directory -Path "$targetDirectory" -Force -ErrorAction SilentlyContinue | out-null
}
Copy-item $manifestFile -Destination $targetDirectory -Force -ErrorAction SilentlyContinue | out-null
Copy-item $moduleFile -Destination $targetDirectory -Force -ErrorAction SilentlyContinue | out-null
Copy-item "$manifestFile" -Destination "$targetDirectory" -Force -ErrorAction SilentlyContinue | out-null
Copy-item "$moduleFile" -Destination "$targetDirectory" -Force -ErrorAction SilentlyContinue | out-null
if ($PSVersionTable.PSVersion.Major -lt 4)
{
@ -506,13 +506,18 @@ function Get-UnitTestDirectory
Run OpenSSH pester tests.
#>
function Invoke-OpenSSHE2ETest
{
{
[CmdletBinding()]
param
(
[ValidateSet('CI', 'Scenario')]
[string]$pri = "CI")
# Discover all CI tests and run them.
Import-Module pester -force -global
Push-Location $Script:E2ETestDirectory
Write-Log -Message "Running OpenSSH E2E tests..."
$testFolders = @(Get-ChildItem *.tests.ps1 -Recurse | ForEach-Object{ Split-Path $_.FullName} | Sort-Object -Unique)
Invoke-Pester $testFolders -OutputFormat NUnitXml -OutputFile $Script:E2ETestResultsFile -Tag 'CI'
Invoke-Pester $testFolders -OutputFormat NUnitXml -OutputFile $Script:E2ETestResultsFile -Tag $pri -PassThru
Pop-Location
}

View File

@ -18,7 +18,15 @@ Describe "E2E scenarios for ssh key management" -Tags "CI" {
}
$keypassphrase = "testpassword"
$keytypes = @("rsa","dsa","ecdsa","ed25519")
$WindowsInBox = $OpenSSHTestInfo["WindowsInBox"]
if($WindowsInBox)
{
$keytypes = @("ed25519")
}
else
{
$keytypes = @("rsa","dsa","ecdsa","ed25519")
}
$ssouser = $OpenSSHTestInfo["SSOUser"]
@ -117,8 +125,15 @@ Describe "E2E scenarios for ssh key management" -Tags "CI" {
foreach($type in $keytypes)
{
$keyPath = Join-Path $testDir "id_$type"
remove-item $keyPath -ErrorAction SilentlyContinue
ssh-keygen -t $type -P $keypassphrase -f $keyPath
remove-item $keyPath -ErrorAction SilentlyContinue
if($OpenSSHTestInfo["WindowsInBox"])
{
ssh-keygen -t $type -P $keypassphrase -f $keyPath -Z aes128-ctr
}
else
{
ssh-keygen -t $type -P $keypassphrase -f $keyPath
}
ValidateKeyFile -FilePath $keyPath
ValidateKeyFile -FilePath "$keyPath.pub"
}
@ -224,7 +239,15 @@ Describe "E2E scenarios for ssh key management" -Tags "CI" {
$keyFileName = "sshadd_userPermTestkey_ed25519"
$keyFilePath = Join-Path $testDir $keyFileName
Remove-Item -path "$keyFilePath*" -Force -ErrorAction SilentlyContinue
ssh-keygen.exe -t ed25519 -f $keyFilePath -P $keypassphrase
if($OpenSSHTestInfo["WindowsInBox"])
{
ssh-keygen.exe -t ed25519 -f $keyFilePath -P $keypassphrase -Z aes128-ctr
}
else
{
ssh-keygen.exe -t ed25519 -f $keyFilePath -P $keypassphrase
}
#set up SSH_ASKPASS
Add-PasswordSetting -Pass $keypassphrase
$tI=1
@ -331,7 +354,7 @@ Describe "E2E scenarios for ssh key management" -Tags "CI" {
}
Context "$tC - ssh-keyscan test cases" {
BeforeAll {
BeforeAll {
$tI=1
$port = $OpenSSHTestInfo["Port"]
Remove-item (join-path $testDir "$tC.$tI.out.txt") -force -ErrorAction SilentlyContinue
@ -341,23 +364,23 @@ Describe "E2E scenarios for ssh key management" -Tags "CI" {
}
AfterAll{$tC++}
It "$tC.$tI - ssh-keyscan with default arguments" {
It "$tC.$tI - ssh-keyscan with default arguments" -Skip:$WindowsInBox {
cmd /c "ssh-keyscan -p $port 127.0.0.1 2>&1 > $outputFile"
$outputFile | Should Contain '.*ssh-rsa.*'
}
It "$tC.$tI - ssh-keyscan with -p" {
It "$tC.$tI - ssh-keyscan with -p" -Skip:$WindowsInBox {
cmd /c "ssh-keyscan -p $port 127.0.0.1 2>&1 > $outputFile"
$outputFile | Should Contain '.*ssh-rsa.*'
}
It "$tC.$tI - ssh-keyscan with -f" {
It "$tC.$tI - ssh-keyscan with -f" -Skip:$WindowsInBox {
Set-Content -Path tmp.txt -Value "127.0.0.1"
cmd /c "ssh-keyscan -p $port -f tmp.txt 2>&1 > $outputFile"
$outputFile | Should Contain '.*ssh-rsa.*'
}
It "$tC.$tI - ssh-keyscan with -f -t" {
It "$tC.$tI - ssh-keyscan with -f -t" -Skip:$WindowsInBox {
Set-Content -Path tmp.txt -Value "127.0.0.1"
cmd /c "ssh-keyscan -p $port -f tmp.txt -t rsa,dsa 2>&1 > $outputFile"
$outputFile | Should Contain '.*ssh-rsa.*'

View File

@ -50,7 +50,14 @@ Describe "Tests for user Key file permission" -Tags "CI" {
$keyFileName = "sshtest_userPermTestkey_ed25519"
$keyFilePath = Join-Path $testDir $keyFileName
Remove-Item -path "$keyFilePath*" -Force -ErrorAction SilentlyContinue
ssh-keygen.exe -t ed25519 -f $keyFilePath -P $keypassphrase
if($OpenSSHTestInfo["WindowsInBox"])
{
ssh-keygen.exe -t ed25519 -f $keyFilePath -P $keypassphrase -Z aes128-ctr
}
else
{
ssh-keygen.exe -t ed25519 -f $keyFilePath -P $keypassphrase
}
$pubKeyUserProfilePath = Join-Path $pubKeyUserProfile .ssh
if(-not (Test-Path $pubKeyUserProfilePath -PathType Container)) {