Increase timing on test service side to avoid a race condition in the webcmdlet timeout test (#5005)
increase timing on test service side to avoid a race condition for the test
This commit is contained in:
parent
ffec170b22
commit
5eee6a8f38
|
@ -359,7 +359,7 @@ function ExecuteRestMethod
|
|||
return $result
|
||||
}
|
||||
|
||||
function GetMultipartBody
|
||||
function GetMultipartBody
|
||||
{
|
||||
param
|
||||
(
|
||||
|
@ -389,7 +389,7 @@ function GetMultipartBody
|
|||
$multipartContent.Add($fileContent)
|
||||
}
|
||||
# unary comma required to prevent $multipartContent from being unwrapped/enumerated
|
||||
return ,$multipartContent
|
||||
return ,$multipartContent
|
||||
}
|
||||
|
||||
<#
|
||||
|
@ -527,7 +527,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
|
|||
|
||||
It "Invoke-WebRequest validate timeout option" {
|
||||
|
||||
$uri = Get-WebListenerUrl -Test 'Delay' -TestValue '5'
|
||||
$uri = Get-WebListenerUrl -Test 'Delay' -TestValue '6'
|
||||
$command = "Invoke-WebRequest -Uri '$uri' -TimeoutSec 5"
|
||||
|
||||
$result = ExecuteWebCommand -command $command
|
||||
|
@ -1183,42 +1183,42 @@ Describe "Invoke-WebRequest tests" -Tags "Feature" {
|
|||
$command = "Invoke-WebRequest -Uri '$Uri'"
|
||||
$result = ExecuteWebCommand -command $command
|
||||
$result.Error.FullyQualifiedErrorId | Should Be "WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
|
||||
|
||||
|
||||
# validate that no exception is thrown for URI with expired certificate when using -SkipCertificateCheck option
|
||||
$Uri = Get-WebListenerUrl -Https
|
||||
$command = "Invoke-WebRequest -Uri '$Uri' -SkipCertificateCheck"
|
||||
$result = ExecuteWebCommand -command $command
|
||||
$result.Error | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
|
||||
It "Validate Invoke-WebRequest returns native HTTPS error message in exception" {
|
||||
$uri = Get-WebListenerUrl -Https
|
||||
$command = "Invoke-WebRequest -Uri '$uri'"
|
||||
$result = ExecuteWebCommand -command $command
|
||||
|
||||
|
||||
# need to check against inner exception since Linux and Windows uses different HTTP client libraries so errors aren't the same
|
||||
$result.Error.ErrorDetails.Message | Should Match $result.Error.Exception.InnerException.Message
|
||||
$result.Error.FullyQualifiedErrorId | Should Be "WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"
|
||||
}
|
||||
|
||||
|
||||
It "Verifies Invoke-WebRequest Certificate Authentication Fails without -Certificate" {
|
||||
$uri = Get-WebListenerUrl -Https -Test 'Cert'
|
||||
$result = Invoke-WebRequest -Uri $uri -SkipCertificateCheck |
|
||||
$result = Invoke-WebRequest -Uri $uri -SkipCertificateCheck |
|
||||
Select-Object -ExpandProperty Content |
|
||||
ConvertFrom-Json
|
||||
|
||||
|
||||
$result.Status | Should Be 'FAILED'
|
||||
}
|
||||
|
||||
|
||||
# Test skipped on macOS and CentOS pending support for Client Certificate Authentication
|
||||
# https://github.com/PowerShell/PowerShell/issues/4650
|
||||
It "Verifies Invoke-WebRequest Certificate Authentication Successful with -Certificate" -Pending:$PendingCertificateTest {
|
||||
$uri = Get-WebListenerUrl -Https -Test 'Cert'
|
||||
$certificate = Get-WebListenerClientCertificate
|
||||
$result = Invoke-WebRequest -Uri $uri -Certificate $certificate -SkipCertificateCheck |
|
||||
$result = Invoke-WebRequest -Uri $uri -Certificate $certificate -SkipCertificateCheck |
|
||||
Select-Object -ExpandProperty Content |
|
||||
ConvertFrom-Json
|
||||
|
||||
|
||||
$result.Status | Should Be 'OK'
|
||||
$result.Thumbprint | Should Be $certificate.Thumbprint
|
||||
}
|
||||
|
@ -1358,7 +1358,7 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
|
|||
$uri = Get-WebListenerUrl -Test 'Encoding' -TestValue 'Utf8'
|
||||
$command = "Invoke-RestMethod -Uri '$uri'"
|
||||
|
||||
$result = ExecuteWebCommand -command $command
|
||||
$result = ExecuteWebCommand -command $command
|
||||
$Result.Output | Should Match '⡌⠁⠧⠑ ⠼⠁⠒ ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌'
|
||||
}
|
||||
|
||||
|
@ -1741,37 +1741,37 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
|
|||
$command = "Invoke-RestMethod -Uri '$uri' -Method HEAD"
|
||||
$result = ExecuteWebCommand -command $command
|
||||
$result.Error.FullyQualifiedErrorId | Should Be "WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
|
||||
|
||||
|
||||
# validate that no exception is thrown for URI with expired certificate when using -SkipCertificateCheck option
|
||||
$command = "Invoke-RestMethod -Uri '$uri' -SkipCertificateCheck -Method HEAD"
|
||||
$result = ExecuteWebCommand -command $command
|
||||
$result.Error | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
|
||||
It "Validate Invoke-RestMethod returns native HTTPS error message in exception" {
|
||||
$uri = Get-WebListenerUrl -Https
|
||||
$command = "Invoke-RestMethod -Uri '$uri'"
|
||||
$result = ExecuteWebCommand -command $command
|
||||
|
||||
|
||||
# need to check against inner exception since Linux and Windows uses different HTTP client libraries so errors aren't the same
|
||||
$result.Error.ErrorDetails.Message | Should Match $result.Error.Exception.InnerException.Message
|
||||
$result.Error.FullyQualifiedErrorId | Should Be "WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand"
|
||||
}
|
||||
|
||||
|
||||
It "Verifies Invoke-RestMethod Certificate Authentication Fails without -Certificate" {
|
||||
$uri = Get-WebListenerUrl -Https -Test 'Cert'
|
||||
$result = Invoke-RestMethod -Uri $uri -SkipCertificateCheck
|
||||
|
||||
|
||||
$result.Status | Should Be 'FAILED'
|
||||
}
|
||||
|
||||
|
||||
# Test skipped on macOS and CentOS pending support for Client Certificate Authentication
|
||||
# https://github.com/PowerShell/PowerShell/issues/4650
|
||||
It "Verifies Invoke-RestMethod Certificate Authentication Successful with -Certificate" -Pending:$PendingCertificateTest {
|
||||
$uri = Get-WebListenerUrl -Https -Test 'Cert'
|
||||
$certificate = Get-WebListenerClientCertificate
|
||||
$result = Invoke-RestMethod -uri $uri -Certificate $certificate -SkipCertificateCheck
|
||||
|
||||
|
||||
$result.Status | Should Be 'OK'
|
||||
$result.Thumbprint | Should Be $certificate.Thumbprint
|
||||
}
|
||||
|
@ -2035,7 +2035,7 @@ Describe "Invoke-RestMethod tests" -Tags "Feature" {
|
|||
$headers.'Content-Type' | Should Be 'text/html; charset=utf-8'
|
||||
$headers.Server | Should Be 'Kestrel'
|
||||
}
|
||||
|
||||
|
||||
It "Verifies Invoke-RestMethod supports -ResponseHeadersVariable overwriting existing variable" {
|
||||
$uri = Get-WebListenerUrl -Test '/'
|
||||
$headers = 'prexisting'
|
||||
|
|
Loading…
Reference in a new issue