From 42f2e3ca820d7fd7f9dd57f2bbb90e5da2ab2de0 Mon Sep 17 00:00:00 2001 From: Rune Darrud Date: Mon, 3 Apr 2017 02:31:22 +0200 Subject: [PATCH] Fix tests to work as expected under Linux (#3474) - Removed the -TimeoutSec option and modified the expected Error to be consistent across platforms. - Changed the port of the phony proxy to 9 which is reserved for the Discard Protocol. So even if the system is listening, it's supposed to discard that TCP request (UDP may use it for Wake-on-Lan, but doesn't affect this). --- .../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 041953be9..2d319219f 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 @@ -258,8 +258,8 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" { } $testCase = @( - @{ proxy_address = "http://localhost:8080"; name = 'http_proxy'; protocol = 'http' } - @{ proxy_address = "http://localhost:8080"; name = 'https_proxy'; protocol = 'https' } + @{ proxy_address = "http://localhost:9"; name = 'http_proxy'; protocol = 'http' } + @{ proxy_address = "http://localhost:9"; name = 'https_proxy'; protocol = 'https' } ) It "Validate Invoke-WebRequest error with -Proxy option set - ''" -TestCases $testCase { @@ -629,17 +629,17 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" { } $testCase = @( - @{ proxy_address = "http://localhost:8080"; name = 'http_proxy'; protocol = 'http' } - @{ proxy_address = "http://localhost:8080"; name = 'https_proxy'; protocol = 'https' } + @{ proxy_address = "http://localhost:9"; name = 'http_proxy'; protocol = 'http' } + @{ proxy_address = "http://localhost:9"; name = 'https_proxy'; protocol = 'https' } ) It "Validate Invoke-RestMethod error with -Proxy option - ''" -TestCases $testCase { param($proxy_address, $name, $protocol) - $command = "Invoke-RestMethod -Uri '${protocol}://httpbin.org/' -Proxy '${proxy_address}' -TimeoutSec 2" + $command = "Invoke-RestMethod -Uri '${protocol}://httpbin.org/' -Proxy '${proxy_address}'" $result = ExecuteWebCommand -command $command - $result.Error.FullyQualifiedErrorId | Should Be "System.Threading.Tasks.TaskCanceledException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand" + $result.Error.FullyQualifiedErrorId | Should Be "WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand" } It "Validate Invoke-RestMethod error with environment proxy set - ''" -TestCases $testCase {