From 63870ab4407b8cf2975f94d3a869123b6ddededb Mon Sep 17 00:00:00 2001 From: James Truher Date: Tue, 18 Apr 2023 13:19:46 -0700 Subject: [PATCH 1/3] Harden 'All approved Cmdlets present' Change logic for comparing approved cmdlet list. --- test/powershell/engine/Basic/DefaultCommands.Tests.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 b/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 index 9d1b030a6a5..27be013ec6b 100644 --- a/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 +++ b/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -Describe "Verify approved aliases list" -Tags "CI" { +Describe "Verify aliases and cmdlets" -Tags "CI" { BeforeAll { function ConvertTo-Hashtable { [CmdletBinding()] @@ -612,9 +612,9 @@ Describe "Verify approved aliases list" -Tags "CI" { } It "All approved Cmdlets present (no new Cmdlets added, no Cmdlets removed)" { - $expectedCmdletList = $commandList.Where({$_.Present -eq "True" -and $_.CommandType -eq "Cmdlet"}).Name | Sort-Object - $observedCmdletList = $currentCmdletList.Name | Sort-Object - $observedCmdletList | Should -Be $expectedCmdletList + $observedCmdletNames = $currentCmdletList.ForEach({"{0}" -f $_.Name}) | Sort-Object + $expectedCmdletNames = $commandHashTableList.ForEach({"{0}" -f $_.Name}) | Sort-Object + $observedCmdletNames | Should -Be $expectedCmdletNames } It "'' Cmdlet should have the correct ConfirmImpact ''" -TestCases $commandHashtableList { From b3d7bcd4200dc5127a8a1002bf036412a9c6037a Mon Sep 17 00:00:00 2001 From: James Truher Date: Tue, 18 Apr 2023 16:01:03 -0700 Subject: [PATCH 2/3] harden the webrequest cancellation tests. --- .../Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 index 5deb9308bd2..84c50fe99cd 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 @@ -4225,9 +4225,10 @@ Describe 'Invoke-WebRequest and Invoke-RestMethod support Cancellation through C $pwsh = [PowerShell]::Create() $invoke = "`$result = $Command -Uri `"$Uri`" $Arguments" $task = $pwsh.AddScript($invoke).InvokeAsync() - Start-Sleep -Milliseconds $DelayMs - $task.IsCompleted | Should -Be $WillComplete.ToBool() + # if this times out, it really means that we didn't get there in a reasonable time. + Wait-UntilTrue { $task.IsCompleted -eq $WillComplete.ToBool() } | Should -BeTrue $pwsh.Stop() + # this check handles the case that WillComplete was false above Wait-UntilTrue { [bool]($Task.IsCompleted) } | Should -BeTrue $result = $pwsh.Runspace.SessionStateProxy.GetVariable('result') $pwsh.Dispose() From bac0eea7ed36dbc0d334401de14087ab6013ffcd Mon Sep 17 00:00:00 2001 From: James Truher Date: Wed, 19 Apr 2023 16:13:42 -0700 Subject: [PATCH 3/3] Revert "harden the webrequest cancellation tests." This reverts commit b3d7bcd4200dc5127a8a1002bf036412a9c6037a. --- .../Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 index 84c50fe99cd..5deb9308bd2 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 @@ -4225,10 +4225,9 @@ Describe 'Invoke-WebRequest and Invoke-RestMethod support Cancellation through C $pwsh = [PowerShell]::Create() $invoke = "`$result = $Command -Uri `"$Uri`" $Arguments" $task = $pwsh.AddScript($invoke).InvokeAsync() - # if this times out, it really means that we didn't get there in a reasonable time. - Wait-UntilTrue { $task.IsCompleted -eq $WillComplete.ToBool() } | Should -BeTrue + Start-Sleep -Milliseconds $DelayMs + $task.IsCompleted | Should -Be $WillComplete.ToBool() $pwsh.Stop() - # this check handles the case that WillComplete was false above Wait-UntilTrue { [bool]($Task.IsCompleted) } | Should -BeTrue $result = $pwsh.Runspace.SessionStateProxy.GetVariable('result') $pwsh.Dispose()