From 869cdf9ba4083d4e33cddd860b1a95220daff72a Mon Sep 17 00:00:00 2001 From: Mark Kraus Date: Thu, 14 Sep 2017 00:22:52 -0500 Subject: [PATCH] Replace httpbin.org/headers with WebListener Get (#4799) * Replace httpbin.org/headers with WebListener Get * [feature] -SkipCertificateCheck to avoid Cert issue * [Feature] Rebase & Rerun CI --- .../WebCmdlets.Tests.ps1 | 15 +++++++++------ 1 file changed, 9 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 efc0007a0b..b72e566a4d 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 @@ -461,14 +461,15 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" { It "Invoke-WebRequest returns headers dictionary" { - $command = "Invoke-WebRequest -Uri http://httpbin.org/headers -TimeoutSec 5" + $uri = Get-WebListenerUrl -Test 'Get' + $command = "Invoke-WebRequest -Uri '$uri' -TimeoutSec 5" $result = ExecuteWebCommand -command $command ValidateResponse -response $result # Validate response content $jsonContent = $result.Output.Content | ConvertFrom-Json - $jsonContent.headers.Host | Should Match "httpbin.org" + $jsonContent.headers.Host | Should Be $Uri.Authority $jsonContent.headers.'User-Agent' | Should Match "WindowsPowerShell" } @@ -569,14 +570,15 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" { # Configure the environment variable. New-Item -Name ${name} -Value ${proxy_address} -ItemType Variable -Path Env: -Force - $command = "Invoke-WebRequest -Uri '${protocol}://httpbin.org/headers' -TimeoutSec 5 -NoProxy" + $uri = Get-WebListenerUrl -Test 'Get' -Https:$($protocol -eq 'https') + $command = "Invoke-WebRequest -Uri '$uri' -TimeoutSec 5 -NoProxy -SkipCertificateCheck" $result = ExecuteWebCommand -command $command ValidateResponse -response $result # Validate response content $jsonContent = $result.Output.Content | ConvertFrom-Json - $jsonContent.headers.Host | Should Match "httpbin.org" + $jsonContent.headers.Host | Should Be $uri.Authority $jsonContent.headers.'User-Agent' | Should Match "WindowsPowerShell" } @@ -1319,12 +1321,13 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" { It "Invoke-RestMethod returns headers dictionary" { - $command = "Invoke-RestMethod -Uri http://httpbin.org/headers -TimeoutSec 5" + $uri = Get-WebListenerUrl -Test 'Get' + $command = "Invoke-RestMethod -Uri '$uri' -TimeoutSec 5" $result = ExecuteWebCommand -command $command # Validate response - $result.Output.headers.Host | Should Match "httpbin.org" + $result.Output.headers.Host | Should Be $Uri.Authority $result.Output.headers.'User-Agent' | Should Match "WindowsPowerShell" }