@@ -494,20 +494,22 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
494494
495495 It " Validate Invoke-WebRequest -MaximumRedirection" {
496496
497- $command = " Invoke-WebRequest -Uri 'http://httpbin.org/redirect/3' -MaximumRedirection 4 -TimeoutSec 5"
497+ $uri = Get-WebListenerUrl - Test ' Redirect/3'
498+ $command = " Invoke-WebRequest -Uri '$uri ' -MaximumRedirection 4"
498499
499500 $result = ExecuteWebCommand - command $command
500501 ValidateResponse - response $result
501502
502503 # Validate response content
503504 $jsonContent = $result.Output.Content | ConvertFrom-Json
504- $jsonContent.headers.Host | Should Match " httpbin.org "
505+ $jsonContent.headers.Host | Should Match $uri .Authority
505506 $jsonContent.headers .' User-Agent' | Should Match " WindowsPowerShell"
506507 }
507508
508509 It " Validate Invoke-WebRequest error for -MaximumRedirection" {
509510
510- $command = " Invoke-WebRequest -Uri 'http://httpbin.org/redirect/3' -MaximumRedirection 2 -TimeoutSec 5"
511+ $uri = Get-WebListenerUrl - Test ' Redirect/3'
512+ $command = " Invoke-WebRequest -Uri '$uri ' -MaximumRedirection 2"
511513
512514 $result = ExecuteWebCommand - command $command
513515 $result.Error.FullyQualifiedErrorId | Should Be " WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
@@ -1355,18 +1357,20 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
13551357
13561358 It " Validate Invoke-RestMethod -MaximumRedirection" {
13571359
1358- $command = " Invoke-RestMethod -Uri 'http://httpbin.org/redirect/3' -MaximumRedirection 4 -TimeoutSec 5"
1360+ $uri = Get-WebListenerUrl - Test ' Redirect/3'
1361+ $command = " Invoke-RestMethod -Uri '$uri ' -MaximumRedirection 4"
13591362
13601363 $result = ExecuteWebCommand - command $command
13611364
13621365 # Validate response
1363- $result.Output.headers.Host | Should Match " httpbin.org "
1366+ $result.Output.headers.Host | Should Match $uri .Authority
13641367 $result.Output.headers .' User-Agent' | Should Match " WindowsPowerShell"
13651368 }
13661369
13671370 It " Validate Invoke-RestMethod error for -MaximumRedirection" {
13681371
1369- $command = " Invoke-RestMethod -Uri 'http://httpbin.org/redirect/3' -MaximumRedirection 2 -TimeoutSec 5"
1372+ $uri = Get-WebListenerUrl - Test ' Redirect/3'
1373+ $command = " Invoke-RestMethod -Uri '$uri ' -MaximumRedirection 2"
13701374
13711375 $result = ExecuteWebCommand - command $command
13721376 $result.Error.FullyQualifiedErrorId | Should Be " WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
0 commit comments