diff --git a/src/code/Utils.cs b/src/code/Utils.cs index 61b9e6b04..ae540f9e4 100644 --- a/src/code/Utils.cs +++ b/src/code/Utils.cs @@ -2160,6 +2160,7 @@ internal static bool CheckAuthenticodeSignature( // Because authenticode and catalog verifications are only applicable on Windows, we allow all packages by default to be installed on unix systems. if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { + cmdletPassedIn.WriteWarning("Authenticode check cannot be performed on Linux or MacOS."); return true; } diff --git a/test/InstallPSResourceTests/InstallPSResourceV2Server.Tests.ps1 b/test/InstallPSResourceTests/InstallPSResourceV2Server.Tests.ps1 index 6023355b7..eea47eb71 100644 --- a/test/InstallPSResourceTests/InstallPSResourceV2Server.Tests.ps1 +++ b/test/InstallPSResourceTests/InstallPSResourceV2Server.Tests.ps1 @@ -554,6 +554,14 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { $err[0].FullyQualifiedErrorId | Should -BeExactly "GetAuthenticodeSignatureError,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource" } + # Test that AuthenticodeCheck parameter displays warning on non-Windows + It "Install with AuthenticodeCheck on non-Windows should display warning" -Skip:(Get-IsWindows) { + Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -AuthenticodeCheck -WarningVariable warn -WarningAction SilentlyContinue + $warn[0] | Should -Contain "Authenticode check cannot be performed on Linux or MacOS" + $res = Get-InstalledPSResource $testModuleName + $res.Name | Should -Be $testModuleName + } + # Unix test for installing scripts It "Install script resource - Unix only" -Skip:(Get-IsWindows) { # previously installing pester on Unix was throwing an error due to how the environment PATH variable was being gotten.