mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Change Web Cmdlet Tests to Use 127.0.0.1 not Localhost (#6069)
Change Web Cmdlets Tests to Use 127.0.0.1 instead of localhost due to dotnet/corefx#24104 This provides a decent speed boost to the WebCmdlet tests (Faster in dozens of times).
This commit is contained in:
@@ -496,15 +496,15 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
|
||||
|
||||
It "Validate Invoke-WebRequest error with -Proxy and -NoProxy option" {
|
||||
$uri = Get-WebListenerUrl -Test 'Delay' -TestValue '10'
|
||||
$command = "Invoke-WebRequest -Uri '$uri' -Proxy 'http://localhost:8080' -NoProxy -TimeoutSec 2"
|
||||
$command = "Invoke-WebRequest -Uri '$uri' -Proxy 'http://127.0.0.1:8080' -NoProxy -TimeoutSec 2"
|
||||
|
||||
$result = ExecuteWebCommand -command $command
|
||||
$result.Error.FullyQualifiedErrorId | Should Be "AmbiguousParameterSet,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
|
||||
}
|
||||
|
||||
$testCase = @(
|
||||
@{ proxy_address = "http://localhost:9"; name = 'http_proxy'; protocol = 'http' }
|
||||
@{ proxy_address = "http://localhost:9"; name = 'https_proxy'; protocol = 'https' }
|
||||
@{ proxy_address = "http://127.0.0.1:9"; name = 'http_proxy'; protocol = 'http' }
|
||||
@{ proxy_address = "http://127.0.0.1:9"; name = 'https_proxy'; protocol = 'https' }
|
||||
)
|
||||
|
||||
It "Validate Invoke-WebRequest error with -Proxy option set - '<name>'" -TestCases $testCase {
|
||||
@@ -1632,15 +1632,15 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
|
||||
|
||||
It "Validate Invoke-RestMethod error with -Proxy and -NoProxy option" {
|
||||
$uri = Get-WebListenerUrl -Test 'Delay' -TestValue '10'
|
||||
$command = "Invoke-RestMethod -Uri '$uri' -Proxy 'http://localhost:8080' -NoProxy -TimeoutSec 2"
|
||||
$command = "Invoke-RestMethod -Uri '$uri' -Proxy 'http://127.0.0.1:8080' -NoProxy -TimeoutSec 2"
|
||||
|
||||
$result = ExecuteWebCommand -command $command
|
||||
$result.Error.FullyQualifiedErrorId | Should Be "AmbiguousParameterSet,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
|
||||
}
|
||||
|
||||
$testCase = @(
|
||||
@{ proxy_address = "http://localhost:9"; name = 'http_proxy'; protocol = 'http' }
|
||||
@{ proxy_address = "http://localhost:9"; name = 'https_proxy'; protocol = 'https' }
|
||||
@{ proxy_address = "http://127.0.0.1:9"; name = 'http_proxy'; protocol = 'http' }
|
||||
@{ proxy_address = "http://127.0.0.1:9"; name = 'https_proxy'; protocol = 'https' }
|
||||
)
|
||||
|
||||
It "Validate Invoke-RestMethod error with -Proxy option - '<name>'" -TestCases $testCase {
|
||||
|
||||
@@ -174,7 +174,8 @@ function Get-WebListenerUrl {
|
||||
return $null
|
||||
}
|
||||
$Uri = [System.UriBuilder]::new()
|
||||
$Uri.Host = 'localhost'
|
||||
# Use 127.0.0.1 and not localhost due to https://github.com/dotnet/corefx/issues/24104
|
||||
$Uri.Host = '127.0.0.1'
|
||||
$Uri.Port = $runningListener.HttpPort
|
||||
$Uri.Scheme = 'Http'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user