From 22c1e2a60ad4cd7da4e6dbcaa221e1d78c0d7e1c Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Wed, 4 Oct 2017 12:09:36 -0700 Subject: [PATCH] [feature] increase timing on test service side to avoid a race condition for the test --- .../WebCmdlets.Tests.ps1 | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 index 86e239cfdfef..988d5d478f61 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 @@ -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 @@ -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 } @@ -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 '⡌⠁⠧⠑ ⠼⠁⠒ ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌' } @@ -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 } @@ -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'