Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

increase timing on test service for webcmdlet timeout test to make it more robust #5005

Merged
merged 1 commit into from Oct 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -359,7 +359,7 @@ function ExecuteRestMethod
return $result
}

function GetMultipartBody
function GetMultipartBody
{
param
(
Expand Down Expand Up @@ -389,7 +389,7 @@ function GetMultipartBody
$multipartContent.Add($fileContent)
}
# unary comma required to prevent $multipartContent from being unwrapped/enumerated
return ,$multipartContent
return ,$multipartContent
}

<#
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1190,42 +1190,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
}
Expand Down Expand Up @@ -1365,7 +1365,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 '⡌⠁⠧⠑ ⠼⠁⠒ ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌'
}

Expand Down Expand Up @@ -1757,37 +1757,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
}
Expand Down Expand Up @@ -2051,7 +2051,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'
Expand Down