Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,20 @@ Describe "Test-Connection" -tags "CI" {
$result | Should -BeTrue
}
}
}

Context "Connection" {
BeforeAll {
# Ensure the local host listen on port 80
$WebListener = Start-WebListener
}
Describe "Connection" -Tag "CI", "RequireAdminOnWindows" {
BeforeAll {
# Ensure the local host listen on port 80
$WebListener = Start-WebListener
$UnreachableAddress = "10.11.12.13"
}

It "Test connection to local host port 80" {
Test-Connection '127.0.0.1' -TCPPort $WebListener.HttpPort | Should -BeTrue
}
It "Test connection to local host port 80" {
Test-Connection '127.0.0.1' -TCPPort $WebListener.HttpPort | Should -BeTrue
}

It "Test connection to unreachable host port 80" {
Test-Connection $UnreachableAddress -TCPPort 80 -TimeOut 1 | Should -BeFalse
}
It "Test connection to unreachable host port 80" {
Test-Connection $UnreachableAddress -TCPPort 80 -TimeOut 1 | Should -BeFalse
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ $redirectTests = @(
@{redirectType = 'relative'; redirectedMethod = 'GET'}
)

Describe "Invoke-WebRequest tests" -Tags "Feature" {
Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
BeforeAll {
$WebListener = Start-WebListener
}
Expand Down Expand Up @@ -1785,7 +1785,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
}
}

Describe "Invoke-RestMethod tests" -Tags "Feature" {
Describe "Invoke-RestMethod tests" -Tags "Feature", "RequireAdminOnWindows" {
BeforeAll {
$WebListener = Start-WebListener
}
Expand Down Expand Up @@ -3069,7 +3069,7 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
}
}

Describe "Validate Invoke-WebRequest and Invoke-RestMethod -InFile" -Tags "Feature" {
Describe "Validate Invoke-WebRequest and Invoke-RestMethod -InFile" -Tags "Feature", "RequireAdminOnWindows" {
BeforeAll {
$WebListener = Start-WebListener
}
Expand Down Expand Up @@ -3149,7 +3149,7 @@ Describe "Validate Invoke-WebRequest and Invoke-RestMethod -InFile" -Tags "Featu
}
}

Describe "Web cmdlets tests using the cmdlet's aliases" -Tags "CI" {
Describe "Web cmdlets tests using the cmdlet's aliases" -Tags "CI", "RequireAdminOnWindows" {
BeforeAll {
$WebListener = Start-WebListener
}
Expand Down
12 changes: 6 additions & 6 deletions test/tools/Modules/WebListener/WebListener.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function Start-WebListener
}

$initTimeoutSeconds = 15
$appDll = 'WebListener.dll'
$appExe = (get-command WebListener).Path
$serverPfx = 'ServerCert.pfx'
$serverPfxPassword = New-RandomHexString
$clientPfx = 'ClientCert.pfx'
Expand All @@ -136,22 +136,23 @@ function Start-WebListener
$Job = Start-Job {
$path = Split-Path -parent (get-command WebListener).Path -Verbose
Push-Location $path -Verbose
'appDLL: {0}' -f $using:appDll
'appEXE: {0}' -f $using:appExe
'serverPfxPath: {0}' -f $using:serverPfxPath
'serverPfxPassword: {0}' -f $using:serverPfxPassword
'HttpPort: {0}' -f $using:HttpPort
'Https: {0}' -f $using:HttpsPort
'Tls11Port: {0}' -f $using:Tls11Port
'TlsPort: {0}' -f $using:TlsPort
$env:ASPNETCORE_ENVIRONMENT = 'Development'
dotnet $using:appDll $using:serverPfxPath $using:serverPfxPassword $using:HttpPort $using:HttpsPort $using:Tls11Port $using:TlsPort
& $using:appExe $using:serverPfxPath $using:serverPfxPassword $using:HttpPort $using:HttpsPort $using:Tls11Port $using:TlsPort
}

$Script:WebListener = [WebListener]@{
HttpPort = $HttpPort
HttpsPort = $HttpsPort
Tls11Port = $Tls11Port
TlsPort = $TlsPort
Job = $Job
Job = $Job
}

# Count iterations of $sleepMilliseconds instead of using system time to work around possible CI VM sleep/delays
Expand All @@ -172,8 +173,7 @@ function Start-WebListener
$jobVerbose = $Job.ChildJobs[0].Verbose | Out-String
$Job | Stop-Job
$Job | Remove-Job -Force
$message = 'WebListener did not start before the timeout was reached.{0}Errors:{0}{1}{0}Output:{0}{2}{0}Verbose:{0}{3}' -f
([System.Environment]::NewLine), $jobErrors, $jobOutput, $jobVerbose
$message = 'WebListener did not start before the timeout was reached.{0}Errors:{0}{1}{0}Output:{0}{2}{0}Verbose:{0}{3}' -f ([System.Environment]::NewLine), $jobErrors, $jobOutput, $jobVerbose
throw $message
}
return $Script:WebListener
Expand Down