From 451b411dcd23ed0bc8a0230c97b17c38c03c6efd Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Thu, 11 May 2023 15:07:47 -0700 Subject: [PATCH] Skip file signature tests on 2012R2 where PKI cmdlets do not work --- .../engine/Security/FileSignature.Tests.ps1 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/powershell/engine/Security/FileSignature.Tests.ps1 b/test/powershell/engine/Security/FileSignature.Tests.ps1 index 948ff4d1a8b..7a67d4ac513 100644 --- a/test/powershell/engine/Security/FileSignature.Tests.ps1 +++ b/test/powershell/engine/Security/FileSignature.Tests.ps1 @@ -22,9 +22,15 @@ Describe "Windows platform file signatures" -Tags 'Feature' { } Describe "Windows file content signatures" -Tags @('Feature', 'RequireAdminOnWindows') { - $PSDefaultParameterValues = @{ "It:Skip" = (-not $IsWindows) } + $shouldSkip = (-not $IsWindows) -or (Test-IsWinServer2012R2) + + $PSDefaultParameterValues = @{ "It:Skip" = $shouldSkip } BeforeAll { + if ($shouldSkip) { + return + } + $session = New-PSSession -UseWindowsPowerShell try { # New-SelfSignedCertificate runs in implicit remoting so do all the @@ -83,6 +89,11 @@ Describe "Windows file content signatures" -Tags @('Feature', 'RequireAdminOnWin } AfterAll { + + if ($shouldSkip) { + return + } + Remove-Item -Path Cert:\LocalMachine\Root\$caRootThumbprint -Force Remove-Item -Path Cert:\LocalMachine\TrustedPublisher\$signingThumbprint -Force Remove-Item -Path Cert:\CurrentUser\My\$signingThumbprint -Force