From 91c52185411431204e91f5887f10c50cb2447d8c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Oct 2025 18:29:44 +0000 Subject: [PATCH 1/5] Initial plan From 2d2c4787c93afd73dd77d4beaeca1986129ae43b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Oct 2025 18:37:08 +0000 Subject: [PATCH 2/5] Add warning for AuthenticodeCheck on non-Windows platforms Co-authored-by: alerickson <25858831+alerickson@users.noreply.github.com> --- src/code/Utils.cs | 1 + .../InstallPSResourceV2Server.Tests.ps1 | 8 ++++++++ 2 files changed, 9 insertions(+) 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..b8c9e5012 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 | 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. From ed2ce91b6f421550311b10fcd9a6f516d5b7b921 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Oct 2025 18:40:12 +0000 Subject: [PATCH 3/5] Add tests for AuthenticodeCheck warning in Save and Update cmdlets Co-authored-by: alerickson <25858831+alerickson@users.noreply.github.com> --- test/SavePSResourceTests/SavePSResourceV2.Tests.ps1 | 7 +++++++ test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/test/SavePSResourceTests/SavePSResourceV2.Tests.ps1 b/test/SavePSResourceTests/SavePSResourceV2.Tests.ps1 index 609c73e3d..281b142dd 100644 --- a/test/SavePSResourceTests/SavePSResourceV2.Tests.ps1 +++ b/test/SavePSResourceTests/SavePSResourceV2.Tests.ps1 @@ -202,6 +202,13 @@ Describe 'Test HTTP Save-PSResource for V2 Server Protocol' -tags 'CI' { $err[1].FullyQualifiedErrorId | Should -Contain "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource" } + # Test that AuthenticodeCheck parameter displays warning on non-Windows + It "Save with AuthenticodeCheck on non-Windows should display warning" -Skip:(Get-IsWindows) { + Save-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -Path $SaveDir -AuthenticodeCheck -WarningVariable warn -WarningAction SilentlyContinue + $warn | Should -Contain "Authenticode check cannot be performed on Linux or MacOS." + Test-Path "$SaveDir/$testModuleName" | Should -Be $true + } + # Save resource that requires license It "Save resource that requires accept license with -AcceptLicense flag" { $pkg = Save-PSResource -Repository $PSGalleryName -TrustRepository -Path $SaveDir -Name $testModuleNameWithLicense -AcceptLicense -PassThru diff --git a/test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 b/test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 index 07db15035..3d30c3ec2 100644 --- a/test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 +++ b/test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 @@ -432,4 +432,11 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { $err[0].FullyQualifiedErrorId | Should -Contain "GetAuthenticodeSignatureError,Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource" $err[1].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource" } + + # Test that AuthenticodeCheck parameter displays warning on non-Windows + It "Update with AuthenticodeCheck on non-Windows should display warning" -Skip:(Get-IsWindows) { + Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository + Update-PSResource -Name $testModuleName -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -WarningVariable warn -WarningAction SilentlyContinue + $warn | Should -Contain "Authenticode check cannot be performed on Linux or MacOS." + } } From a542b97d6ec745ec51f8add0fd58a7b5928c483c Mon Sep 17 00:00:00 2001 From: alerickson <25858831+alerickson@users.noreply.github.com> Date: Wed, 8 Oct 2025 18:43:38 +0000 Subject: [PATCH 4/5] Remove redundant tests --- test/SavePSResourceTests/SavePSResourceV2.Tests.ps1 | 7 ------- test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 | 7 ------- 2 files changed, 14 deletions(-) diff --git a/test/SavePSResourceTests/SavePSResourceV2.Tests.ps1 b/test/SavePSResourceTests/SavePSResourceV2.Tests.ps1 index 281b142dd..609c73e3d 100644 --- a/test/SavePSResourceTests/SavePSResourceV2.Tests.ps1 +++ b/test/SavePSResourceTests/SavePSResourceV2.Tests.ps1 @@ -202,13 +202,6 @@ Describe 'Test HTTP Save-PSResource for V2 Server Protocol' -tags 'CI' { $err[1].FullyQualifiedErrorId | Should -Contain "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource" } - # Test that AuthenticodeCheck parameter displays warning on non-Windows - It "Save with AuthenticodeCheck on non-Windows should display warning" -Skip:(Get-IsWindows) { - Save-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -Path $SaveDir -AuthenticodeCheck -WarningVariable warn -WarningAction SilentlyContinue - $warn | Should -Contain "Authenticode check cannot be performed on Linux or MacOS." - Test-Path "$SaveDir/$testModuleName" | Should -Be $true - } - # Save resource that requires license It "Save resource that requires accept license with -AcceptLicense flag" { $pkg = Save-PSResource -Repository $PSGalleryName -TrustRepository -Path $SaveDir -Name $testModuleNameWithLicense -AcceptLicense -PassThru diff --git a/test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 b/test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 index 3d30c3ec2..07db15035 100644 --- a/test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 +++ b/test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 @@ -432,11 +432,4 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { $err[0].FullyQualifiedErrorId | Should -Contain "GetAuthenticodeSignatureError,Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource" $err[1].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource" } - - # Test that AuthenticodeCheck parameter displays warning on non-Windows - It "Update with AuthenticodeCheck on non-Windows should display warning" -Skip:(Get-IsWindows) { - Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository - Update-PSResource -Name $testModuleName -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -WarningVariable warn -WarningAction SilentlyContinue - $warn | Should -Contain "Authenticode check cannot be performed on Linux or MacOS." - } } From 4a06e5242271e30354cfe6682fb32c7ac7bed136 Mon Sep 17 00:00:00 2001 From: alerickson <25858831+alerickson@users.noreply.github.com> Date: Wed, 8 Oct 2025 19:24:08 +0000 Subject: [PATCH 5/5] Update test --- test/InstallPSResourceTests/InstallPSResourceV2Server.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/InstallPSResourceTests/InstallPSResourceV2Server.Tests.ps1 b/test/InstallPSResourceTests/InstallPSResourceV2Server.Tests.ps1 index b8c9e5012..eea47eb71 100644 --- a/test/InstallPSResourceTests/InstallPSResourceV2Server.Tests.ps1 +++ b/test/InstallPSResourceTests/InstallPSResourceV2Server.Tests.ps1 @@ -557,7 +557,7 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { # 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 | Should -Contain "Authenticode check cannot be performed on Linux or MacOS." + $warn[0] | Should -Contain "Authenticode check cannot be performed on Linux or MacOS" $res = Get-InstalledPSResource $testModuleName $res.Name | Should -Be $testModuleName }