From e46b0a68fb4e4e795a4d5a26d5ca3e1239030529 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 2 Feb 2022 09:04:31 -0800 Subject: [PATCH 01/11] Update to use 'windows-latest' as the build agent image --- .vsts-ci/templates/ci-build.yml | 2 +- .vsts-ci/templates/nanoserver.yml | 2 +- .vsts-ci/templates/verify-xunit.yml | 2 +- .vsts-ci/windows-daily.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.vsts-ci/templates/ci-build.yml b/.vsts-ci/templates/ci-build.yml index cbbd5349417..e64ab4967a2 100644 --- a/.vsts-ci/templates/ci-build.yml +++ b/.vsts-ci/templates/ci-build.yml @@ -1,5 +1,5 @@ parameters: - pool: 'vs2017-win2016' + pool: 'windows-latest' jobName: 'win_build' displayName: Windows Build diff --git a/.vsts-ci/templates/nanoserver.yml b/.vsts-ci/templates/nanoserver.yml index c989d01c2f8..ae9f639b3b2 100644 --- a/.vsts-ci/templates/nanoserver.yml +++ b/.vsts-ci/templates/nanoserver.yml @@ -1,5 +1,5 @@ parameters: - vmImage: 'windows-2019' + vmImage: 'windows-latest' jobName: 'Nanoserver_Tests' continueOnError: false diff --git a/.vsts-ci/templates/verify-xunit.yml b/.vsts-ci/templates/verify-xunit.yml index 9e09584d5c3..d2799f53ae0 100644 --- a/.vsts-ci/templates/verify-xunit.yml +++ b/.vsts-ci/templates/verify-xunit.yml @@ -1,6 +1,6 @@ parameters: parentJobs: [] - pool: 'vs2017-win2016' + pool: 'windows-latest' jobName: 'xunit_verify' jobs: diff --git a/.vsts-ci/windows-daily.yml b/.vsts-ci/windows-daily.yml index 9171112b362..55470e6dd53 100644 --- a/.vsts-ci/windows-daily.yml +++ b/.vsts-ci/windows-daily.yml @@ -53,7 +53,7 @@ stages: jobs: - job: win_test pool: - vmImage: vs2017-win2016 + vmImage: windows-latest displayName: Windows Test timeoutInMinutes: 90 From 509d17983be06f5a9bb816701d26b17ad6bd82dd Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 2 Feb 2022 10:09:33 -0800 Subject: [PATCH 02/11] Update additional files --- .vsts-ci/templates/credscan.yml | 4 ++-- .vsts-ci/templates/windows-test.yml | 4 ++-- .vsts-ci/windows/templates/windows-packaging.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.vsts-ci/templates/credscan.yml b/.vsts-ci/templates/credscan.yml index f6ed5b8fd23..60094ff3d77 100644 --- a/.vsts-ci/templates/credscan.yml +++ b/.vsts-ci/templates/credscan.yml @@ -1,12 +1,12 @@ parameters: - pool: 'Hosted VS2017' + pool: 'windows-latest' jobName: 'credscan' displayName: Secret Scan jobs: - job: ${{ parameters.jobName }} pool: - name: ${{ parameters.pool }} + vmImage: ${{ parameters.pool }} displayName: ${{ parameters.displayName }} diff --git a/.vsts-ci/templates/windows-test.yml b/.vsts-ci/templates/windows-test.yml index b316f8f360e..475c40c665c 100644 --- a/.vsts-ci/templates/windows-test.yml +++ b/.vsts-ci/templates/windows-test.yml @@ -1,5 +1,5 @@ parameters: - pool: 'Hosted VS2017' + pool: 'windows-latest' parentJobs: [] purpose: '' tagSet: 'CI' @@ -9,7 +9,7 @@ jobs: dependsOn: ${{ parameters.parentJobs }} pool: - name: ${{ parameters.pool }} + vmImage: ${{ parameters.pool }} displayName: Windows Test - ${{ parameters.purpose }} - ${{ parameters.tagSet }} diff --git a/.vsts-ci/windows/templates/windows-packaging.yml b/.vsts-ci/windows/templates/windows-packaging.yml index 88a557ca032..832fe73af5e 100644 --- a/.vsts-ci/windows/templates/windows-packaging.yml +++ b/.vsts-ci/windows/templates/windows-packaging.yml @@ -1,6 +1,6 @@ parameters: - name: pool - default: 'Hosted VS2017' + default: 'windows-latest' - name: jobName default: 'win_packaging' - name: runtimePrefix @@ -24,7 +24,7 @@ jobs: value: $(Agent.BuildDirectory)\$(complianceRepoFolder) pool: - name: ${{ parameters.pool }} + vmImage: ${{ parameters.pool }} displayName: Windows Packaging - ${{ parameters.architecture }} - ${{ parameters.channel }} From a927e9799376c7f8eea42bdb9bf93f272904bfa6 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 2 Feb 2022 13:08:55 -0800 Subject: [PATCH 03/11] debug test failures --- .../CompatiblePSEditions.Module.Tests.ps1 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 index f9094254ec3..8ab9ecc98ea 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 @@ -603,6 +603,13 @@ Describe "Additional tests for Import-Module with WinCompat" -Tag "Feature" { Import-Module Microsoft.PowerShell.Management -UseWindowsPowerShell $modules = Get-Module -Name Microsoft.PowerShell.Management + + foreach ($m in $modules) { + Write-Verbose -Verbose $m.Name + Write-Verbose -Verbose (" Module Base: " + $m.ModuleBase) + Write-Verbose -Verbose (" Module Path: " + $m.Path) + } + $modules.Count | Should -Be 2 $proxyModule = $modules | Where-Object {$_.ModuleType -eq 'Script'} $coreModule = $modules | Where-Object {$_.ModuleType -eq 'Manifest'} @@ -731,7 +738,14 @@ Remove-Module $desktopModuleToUse $originalModulePath = $env:PSModulePath try { $env:PSModulePath += ";$mypath" - Import-Module $ModuleName2 -UseWindowsPowerShell -Force -WarningAction Ignore + + Write-Verbose -Verbose ("pwsh PSModulePath: " + $env:PSModulePath) + + Import-Module $ModuleName2 -UseWindowsPowerShell -Force + + $m = Get-Module $ModuleName2 + Write-Verbose -Verbose ($m.ModuleBase) + $s = Get-PSSession -Name WinPSCompatSession $winpsPaths = Invoke-Command -Session $s -ScriptBlock {$env:psmodulepath} $winpsPaths | Should -BeLike "*$mypath*" From f45d694b1835b77cc60e8a332a8dd605bb61f8cf Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Feb 2022 15:31:19 -0800 Subject: [PATCH 04/11] Added some more wincompat debug info --- .../CompatiblePSEditions.Module.Tests.ps1 | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 index 8ab9ecc98ea..9c2343e2116 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 @@ -600,6 +600,16 @@ Describe "Additional tests for Import-Module with WinCompat" -Tag "Feature" { It "NoClobber WinCompat import works for an engine module through -UseWindowsPowerShell parameter" { + "==============" | Write-Verbose -Verbose + "Check for if module is already pre-loaded " | Write-Verbose -Verbose + $modules = Get-Module -Name Microsoft.PowerShell.Management + foreach ($m in $modules) { + Write-Verbose -Verbose $m.Name + Write-Verbose -Verbose (" Module Base: " + $m.ModuleBase) + Write-Verbose -Verbose (" Module Path: " + $m.Path) + } + "==============" | Write-Verbose -Verbose + Import-Module Microsoft.PowerShell.Management -UseWindowsPowerShell $modules = Get-Module -Name Microsoft.PowerShell.Management @@ -610,6 +620,11 @@ Describe "Additional tests for Import-Module with WinCompat" -Tag "Feature" { Write-Verbose -Verbose (" Module Path: " + $m.Path) } + "==============" | Write-Verbose -Verbose + "Check for bad WinPS module manifest " | Write-Verbose -Verbose + Get-Content "C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1" | Out-String | Write-Verbose -Verbose + "==============" | Write-Verbose -Verbose + $modules.Count | Should -Be 2 $proxyModule = $modules | Where-Object {$_.ModuleType -eq 'Script'} $coreModule = $modules | Where-Object {$_.ModuleType -eq 'Manifest'} @@ -741,6 +756,15 @@ Remove-Module $desktopModuleToUse Write-Verbose -Verbose ("pwsh PSModulePath: " + $env:PSModulePath) + "==============" | Write-Verbose -Verbose + "Check for pre-existing WinPSCompatSession" | Write-Verbose -Verbose + Get-PSSession -Name WinPSCompatSession | Out-String | Write-Verbose -Verbose + $s = Get-PSSession -Name WinPSCompatSession + if ($s) { + Invoke-Command -Session $s -ScriptBlock {$env:psmodulepath} | Out-String | Write-Verbose -Verbose + } + "==============" | Write-Verbose -Verbose + Import-Module $ModuleName2 -UseWindowsPowerShell -Force $m = Get-Module $ModuleName2 From fc0ebe141d33c39c19da45ad575c02ce13bcc244 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Feb 2022 18:05:02 -0800 Subject: [PATCH 05/11] Added some more wincompat debug info 2 --- .../CompatiblePSEditions.Module.Tests.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 index 9c2343e2116..1688a7d16a8 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 @@ -600,6 +600,10 @@ Describe "Additional tests for Import-Module with WinCompat" -Tag "Feature" { It "NoClobber WinCompat import works for an engine module through -UseWindowsPowerShell parameter" { + # pre-test cleanup + Get-Module -Name Microsoft.PowerShell.Management | Remove-Module + Import-Module -Name Microsoft.PowerShell.Management # import the one that comes with PSCore + "==============" | Write-Verbose -Verbose "Check for if module is already pre-loaded " | Write-Verbose -Verbose $modules = Get-Module -Name Microsoft.PowerShell.Management @@ -727,6 +731,7 @@ Remove-Module $desktopModuleToUse AfterEach { Get-Module $allModules | Remove-Module -Force + Get-PSSession -Name WinPSCompatSession -ErrorAction SilentlyContinue | Remove-PSSession } It 'WinCompat process does not inherit PowerShell-Core-specific paths' { From bb6528488001cb14ea68ea3853b65121254759fe Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Feb 2022 18:41:16 -0800 Subject: [PATCH 06/11] Stabilizing some wincompat tests when they are run on OS with compatibility-bugged WindowsPS buitin modules --- .../CompatiblePSEditions.Module.Tests.ps1 | 44 +++---------------- 1 file changed, 5 insertions(+), 39 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 index 1688a7d16a8..0fba3547b41 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 @@ -604,31 +604,10 @@ Describe "Additional tests for Import-Module with WinCompat" -Tag "Feature" { Get-Module -Name Microsoft.PowerShell.Management | Remove-Module Import-Module -Name Microsoft.PowerShell.Management # import the one that comes with PSCore - "==============" | Write-Verbose -Verbose - "Check for if module is already pre-loaded " | Write-Verbose -Verbose - $modules = Get-Module -Name Microsoft.PowerShell.Management - foreach ($m in $modules) { - Write-Verbose -Verbose $m.Name - Write-Verbose -Verbose (" Module Base: " + $m.ModuleBase) - Write-Verbose -Verbose (" Module Path: " + $m.Path) - } - "==============" | Write-Verbose -Verbose - - Import-Module Microsoft.PowerShell.Management -UseWindowsPowerShell + Import-Module Microsoft.PowerShell.Management -UseWindowsPowerShell # import through proxy the one that comes with WindowsPS $modules = Get-Module -Name Microsoft.PowerShell.Management - foreach ($m in $modules) { - Write-Verbose -Verbose $m.Name - Write-Verbose -Verbose (" Module Base: " + $m.ModuleBase) - Write-Verbose -Verbose (" Module Path: " + $m.Path) - } - - "==============" | Write-Verbose -Verbose - "Check for bad WinPS module manifest " | Write-Verbose -Verbose - Get-Content "C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1" | Out-String | Write-Verbose -Verbose - "==============" | Write-Verbose -Verbose - $modules.Count | Should -Be 2 $proxyModule = $modules | Where-Object {$_.ModuleType -eq 'Script'} $coreModule = $modules | Where-Object {$_.ModuleType -eq 'Manifest'} @@ -729,9 +708,12 @@ Remove-Module $desktopModuleToUse Restore-ModulePath } + BeforeEach { + Get-PSSession -Name WinPSCompatSession -ErrorAction SilentlyContinue | Remove-PSSession + } + AfterEach { Get-Module $allModules | Remove-Module -Force - Get-PSSession -Name WinPSCompatSession -ErrorAction SilentlyContinue | Remove-PSSession } It 'WinCompat process does not inherit PowerShell-Core-specific paths' { @@ -758,23 +740,7 @@ Remove-Module $desktopModuleToUse $originalModulePath = $env:PSModulePath try { $env:PSModulePath += ";$mypath" - - Write-Verbose -Verbose ("pwsh PSModulePath: " + $env:PSModulePath) - - "==============" | Write-Verbose -Verbose - "Check for pre-existing WinPSCompatSession" | Write-Verbose -Verbose - Get-PSSession -Name WinPSCompatSession | Out-String | Write-Verbose -Verbose - $s = Get-PSSession -Name WinPSCompatSession - if ($s) { - Invoke-Command -Session $s -ScriptBlock {$env:psmodulepath} | Out-String | Write-Verbose -Verbose - } - "==============" | Write-Verbose -Verbose - Import-Module $ModuleName2 -UseWindowsPowerShell -Force - - $m = Get-Module $ModuleName2 - Write-Verbose -Verbose ($m.ModuleBase) - $s = Get-PSSession -Name WinPSCompatSession $winpsPaths = Invoke-Command -Session $s -ScriptBlock {$env:psmodulepath} $winpsPaths | Should -BeLike "*$mypath*" From 425442434fc655f9c22ca71a6dad8f7515680da4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Feb 2022 18:43:51 -0800 Subject: [PATCH 07/11] Stabilizing some wincompat tests --- .../CompatiblePSEditions.Module.Tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 index 0fba3547b41..61f9f8e0f9f 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/CompatiblePSEditions.Module.Tests.ps1 @@ -604,7 +604,7 @@ Describe "Additional tests for Import-Module with WinCompat" -Tag "Feature" { Get-Module -Name Microsoft.PowerShell.Management | Remove-Module Import-Module -Name Microsoft.PowerShell.Management # import the one that comes with PSCore - Import-Module Microsoft.PowerShell.Management -UseWindowsPowerShell # import through proxy the one that comes with WindowsPS + Import-Module Microsoft.PowerShell.Management -UseWindowsPowerShell $modules = Get-Module -Name Microsoft.PowerShell.Management @@ -740,7 +740,7 @@ Remove-Module $desktopModuleToUse $originalModulePath = $env:PSModulePath try { $env:PSModulePath += ";$mypath" - Import-Module $ModuleName2 -UseWindowsPowerShell -Force + Import-Module $ModuleName2 -UseWindowsPowerShell -Force -WarningAction Ignore $s = Get-PSSession -Name WinPSCompatSession $winpsPaths = Invoke-Command -Session $s -ScriptBlock {$env:psmodulepath} $winpsPaths | Should -BeLike "*$mypath*" From af5f791928df56d52acbbb9ccb59a288914e8956 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Mon, 7 Feb 2022 13:19:13 -0800 Subject: [PATCH 08/11] Add verbose message to 'Enable-WSManCredSSP' test --- .../CredSSP.Tests.ps1 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/powershell/Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 b/test/powershell/Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 index e440c8093f8..25e39a03ff2 100644 --- a/test/powershell/Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 @@ -48,10 +48,29 @@ Describe "CredSSP cmdlet tests" -Tags 'Feature','RequireAdminOnWindows' { @{params=@{Role="Server"};description="server"} ) { param ($params) + + Write-Verbose -Verbose "=========== Enable-WSManCredSSP ===========" + $c = Enable-WSManCredSSP @params -Force + + Write-Verbose -Verbose ($c.GetType().FullName) + Write-Verbose -Verbose ($c | Format-List | Out-String) + Write-Verbose -Verbose ($Error[0]) + + Write-Verbose -Verbose "============ END ============" + $c.CredSSP | Should -BeTrue + Write-Verbose -Verbose "=========== Get-WSManCredSSP ===========" + $c = Get-WSManCredSSP + + Write-Verbose -Verbose ($c.GetType().FullName) + Write-Verbose -Verbose ($c | Format-List | Out-String) + Write-Verbose -Verbose ($Error[0]) + + Write-Verbose -Verbose "============ END ============" + if ($params.Role -eq "Client") { $c[0] | Should -Match "The machine is configured to allow delegating fresh credentials to the following target\(s\):wsman/\*" From 99b21ffd72b7f658bb729f46061190d25156d87a Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Mon, 7 Feb 2022 14:33:19 -0800 Subject: [PATCH 09/11] More debugging --- .../CredSSP.Tests.ps1 | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/test/powershell/Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 b/test/powershell/Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 index 25e39a03ff2..a3ec17bf8fe 100644 --- a/test/powershell/Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 @@ -49,28 +49,38 @@ Describe "CredSSP cmdlet tests" -Tags 'Feature','RequireAdminOnWindows' { ) { param ($params) - Write-Verbose -Verbose "=========== Enable-WSManCredSSP ===========" + Write-Verbose -Verbose "=========== $($params.Role) Enable-WSManCredSSP ===========" $c = Enable-WSManCredSSP @params -Force Write-Verbose -Verbose ($c.GetType().FullName) Write-Verbose -Verbose ($c | Format-List | Out-String) - Write-Verbose -Verbose ($Error[0]) Write-Verbose -Verbose "============ END ============" $c.CredSSP | Should -BeTrue - Write-Verbose -Verbose "=========== Get-WSManCredSSP ===========" + Write-Verbose -Verbose "=========== $($params.Role) Get-WSManCredSSP ===========" $c = Get-WSManCredSSP - Write-Verbose -Verbose ($c.GetType().FullName) - Write-Verbose -Verbose ($c | Format-List | Out-String) - Write-Verbose -Verbose ($Error[0]) + foreach ($i in $c) { + Write-Verbose -Verbose $i + } Write-Verbose -Verbose "============ END ============" + if ($params.Role -eq "Client") { + Start-Sleep -Seconds 2 + $c = Get-WSManCredSSP + + Write-Verbose -Verbose "============ Get again in 2 seconds ===========" + foreach ($i in $c) { + Write-Verbose -Verbose $i + } + Write-Verbose -Verbose "================== END ========================" + } + if ($params.Role -eq "Client") { $c[0] | Should -Match "The machine is configured to allow delegating fresh credentials to the following target\(s\):wsman/\*" From 97e05f66b46d7aad6ff641a5c822d3659c040b27 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Mon, 7 Feb 2022 15:39:50 -0800 Subject: [PATCH 10/11] Make the 'Enable-WSManCredSSP' test more stable --- .../CredSSP.Tests.ps1 | 46 +++++-------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/test/powershell/Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 b/test/powershell/Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 index a3ec17bf8fe..01dd138588c 100644 --- a/test/powershell/Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 @@ -1,5 +1,8 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. + +Import-Module HelpersCommon + Describe "CredSSP cmdlet tests" -Tags 'Feature','RequireAdminOnWindows' { BeforeAll { @@ -44,50 +47,25 @@ Describe "CredSSP cmdlet tests" -Tags 'Feature','RequireAdminOnWindows' { } It "Enable-WSManCredSSP works: " -Skip:($NotEnglish -or $IsToBeSkipped) -TestCases @( - @{params=@{Role="Client";DelegateComputer="*"};description="client"}, - @{params=@{Role="Server"};description="server"} + @{ params = @{ Role="Client"; DelegateComputer="*" }; description = "client"; expected = "The machine is configured to allow delegating fresh credentials to the following target\(s\):wsman/\*" }, + @{ params = @{ Role="Server" }; description = "server"; expected = "This computer is configured to receive credentials from a remote client computer" } ) { - param ($params) - - Write-Verbose -Verbose "=========== $($params.Role) Enable-WSManCredSSP ===========" + param ($params, $description, $expected) $c = Enable-WSManCredSSP @params -Force - - Write-Verbose -Verbose ($c.GetType().FullName) - Write-Verbose -Verbose ($c | Format-List | Out-String) - - Write-Verbose -Verbose "============ END ============" - $c.CredSSP | Should -BeTrue - Write-Verbose -Verbose "=========== $($params.Role) Get-WSManCredSSP ===========" - - $c = Get-WSManCredSSP - - foreach ($i in $c) { - Write-Verbose -Verbose $i - } - - Write-Verbose -Verbose "============ END ============" - - if ($params.Role -eq "Client") { - Start-Sleep -Seconds 2 - $c = Get-WSManCredSSP - - Write-Verbose -Verbose "============ Get again in 2 seconds ===========" - foreach ($i in $c) { - Write-Verbose -Verbose $i - } - Write-Verbose -Verbose "================== END ========================" - } - if ($params.Role -eq "Client") { - $c[0] | Should -Match "The machine is configured to allow delegating fresh credentials to the following target\(s\):wsman/\*" + Wait-UntilTrue -IntervalInMilliseconds 500 -sb { + $c = Get-WSManCredSSP + $c[0] -match $expected + } | Should -BeTrue -Because "WSManCredSSP should have been enabled to allow delegating fresh credentials to wsman/*, but it was not." } else { - $c[1] | Should -Match "This computer is configured to receive credentials from a remote client computer" + $c = Get-WSManCredSSP + $c[1] | Should -Match $expected } } From 2cfa94f69393a136c3c8917b6acfea520225b1a0 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Mon, 7 Feb 2022 16:27:12 -0800 Subject: [PATCH 11/11] Address feedback --- .../Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/powershell/Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 b/test/powershell/Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 index 01dd138588c..0f13e8e6aad 100644 --- a/test/powershell/Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.WSMan.Management/CredSSP.Tests.ps1 @@ -64,8 +64,10 @@ Describe "CredSSP cmdlet tests" -Tags 'Feature','RequireAdminOnWindows' { } else { - $c = Get-WSManCredSSP - $c[1] | Should -Match $expected + Wait-UntilTrue -IntervalInMilliseconds 500 -sb { + $c = Get-WSManCredSSP + $c[1] -match $expected + } | Should -BeTrue -Because "WSManCredSSP should have been enabled to allow receiving credentials from a remote client computer, but it was not." } }