2017-07-01 03:36:09 +02:00
|
|
|
|
If ($PSVersiontable.PSVersion.Major -le 2) {$PSScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path}
|
|
|
|
|
Import-Module $PSScriptRoot\CommonUtils.psm1 -Force
|
|
|
|
|
$tC = 1
|
2017-05-16 02:36:22 +02:00
|
|
|
|
$tI = 0
|
|
|
|
|
$suite = "portfwd"
|
2017-04-04 21:35:11 +02:00
|
|
|
|
|
2017-05-16 02:36:22 +02:00
|
|
|
|
Describe "E2E scenarios for port forwarding" -Tags "CI" {
|
|
|
|
|
BeforeAll {
|
2017-07-01 03:36:09 +02:00
|
|
|
|
if($OpenSSHTestInfo -eq $null)
|
|
|
|
|
{
|
|
|
|
|
Throw "`$OpenSSHTestInfo is null. Please run Set-OpenSSHTestEnvironment to set test environments."
|
|
|
|
|
}
|
2017-05-16 02:36:22 +02:00
|
|
|
|
$testDir = Join-Path $OpenSSHTestInfo["TestDataPath"] $suite
|
|
|
|
|
if(-not (Test-Path $testDir))
|
2017-04-04 21:35:11 +02:00
|
|
|
|
{
|
2017-05-16 02:36:22 +02:00
|
|
|
|
$null = New-Item $testDir -ItemType directory -Force -ErrorAction SilentlyContinue
|
2017-04-04 21:35:11 +02:00
|
|
|
|
}
|
2017-07-01 03:36:09 +02:00
|
|
|
|
$platform = Get-Platform
|
|
|
|
|
$skip = ($platform -eq [PlatformType]::Windows) -and ($PSVersionTable.PSVersion.Major -le 2)
|
2017-05-16 02:36:22 +02:00
|
|
|
|
}
|
2016-11-29 23:50:13 +01:00
|
|
|
|
|
2017-05-16 02:36:22 +02:00
|
|
|
|
BeforeEach {
|
|
|
|
|
$stderrFile=Join-Path $testDir "$tC.$tI.stderr.txt"
|
|
|
|
|
$stdoutFile=Join-Path $testDir "$tC.$tI.stdout.txt"
|
|
|
|
|
$logFile = Join-Path $testDir "$tC.$tI.log.txt"
|
|
|
|
|
}
|
|
|
|
|
AfterEach {$tI++;}
|
2016-11-29 23:50:13 +01:00
|
|
|
|
|
2017-05-16 02:36:22 +02:00
|
|
|
|
Context "$tC - Basic port forwarding scenarios" {
|
|
|
|
|
BeforeAll {$tI=1}
|
|
|
|
|
AfterAll{$tC++}
|
2016-11-29 23:50:13 +01:00
|
|
|
|
|
2017-05-16 02:36:22 +02:00
|
|
|
|
#TODO - this relies on winrm (that is windows specific)
|
2017-07-01 03:36:09 +02:00
|
|
|
|
It "$tC.$tI - local port forwarding" -skip:$skip {
|
2017-05-16 02:36:22 +02:00
|
|
|
|
ssh -L 5432:127.0.0.1:47001 test_target powershell.exe Test-WSMan -computer 127.0.0.1 -port 5432 | Set-Content $stdoutFile
|
|
|
|
|
$stdoutFile | Should Contain "wsmid"
|
|
|
|
|
}
|
2016-11-29 23:50:13 +01:00
|
|
|
|
|
2017-07-01 03:36:09 +02:00
|
|
|
|
It "$tC.$tI - remote port forwarding" -skip:$skip {
|
2017-05-16 02:36:22 +02:00
|
|
|
|
ssh -R 5432:127.0.0.1:47001 test_target powershell.exe Test-WSMan -computer 127.0.0.1 -port 5432 | Set-Content $stdoutFile
|
|
|
|
|
$stdoutFile | Should Contain "wsmid"
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-29 23:50:13 +01:00
|
|
|
|
}
|