From d92edb7fa9d5247d5307cb9abbc60c3acafd1544 Mon Sep 17 00:00:00 2001 From: Mark Kraus Date: Tue, 30 Jan 2018 12:03:30 -0600 Subject: [PATCH 1/3] [feature] Change Web Cmdlet Tests to Use 127.0.0.1 not Localhost --- test/tools/Modules/WebListener/WebListener.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tools/Modules/WebListener/WebListener.psm1 b/test/tools/Modules/WebListener/WebListener.psm1 index 7f9c69e307d..8d49e19d2d8 100644 --- a/test/tools/Modules/WebListener/WebListener.psm1 +++ b/test/tools/Modules/WebListener/WebListener.psm1 @@ -158,7 +158,7 @@ function Get-WebListenerUrl { return $null } $Uri = [System.UriBuilder]::new() - $Uri.Host = 'localhost' + $Uri.Host = '127.0.0.1' $Uri.Port = $runningListener.HttpPort $Uri.Scheme = 'Http' From 40b431cf1eb3c5162a2e0a6279180ef23b9b20af Mon Sep 17 00:00:00 2001 From: Mark Kraus Date: Wed, 31 Jan 2018 03:42:49 -0600 Subject: [PATCH 2/3] [feature] Replace localhost with 127.0.0.1 for proxy tests --- .../WebCmdlets.Tests.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 index 05356b2edf8..d9c62aa13b3 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 @@ -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 - ''" -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 - ''" -TestCases $testCase { From 56504d163d00f5fb83043deb41945c9b0d6312a6 Mon Sep 17 00:00:00 2001 From: Mark Kraus Date: Wed, 31 Jan 2018 04:57:51 -0600 Subject: [PATCH 3/3] Add Comment about CoreFX issue --- test/tools/Modules/WebListener/WebListener.psm1 | 1 + 1 file changed, 1 insertion(+) diff --git a/test/tools/Modules/WebListener/WebListener.psm1 b/test/tools/Modules/WebListener/WebListener.psm1 index 8d49e19d2d8..017c5a1c415 100644 --- a/test/tools/Modules/WebListener/WebListener.psm1 +++ b/test/tools/Modules/WebListener/WebListener.psm1 @@ -158,6 +158,7 @@ function Get-WebListenerUrl { return $null } $Uri = [System.UriBuilder]::new() + # 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'