mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
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
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user