Skip to content

Commit ed2ce91

Browse files
Copilotalerickson
andcommitted
Add tests for AuthenticodeCheck warning in Save and Update cmdlets
Co-authored-by: alerickson <25858831+alerickson@users.noreply.github.com>
1 parent 2d2c478 commit ed2ce91

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

test/SavePSResourceTests/SavePSResourceV2.Tests.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,13 @@ Describe 'Test HTTP Save-PSResource for V2 Server Protocol' -tags 'CI' {
202202
$err[1].FullyQualifiedErrorId | Should -Contain "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource"
203203
}
204204

205+
# Test that AuthenticodeCheck parameter displays warning on non-Windows
206+
It "Save with AuthenticodeCheck on non-Windows should display warning" -Skip:(Get-IsWindows) {
207+
Save-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -Path $SaveDir -AuthenticodeCheck -WarningVariable warn -WarningAction SilentlyContinue
208+
$warn | Should -Contain "Authenticode check cannot be performed on Linux or MacOS."
209+
Test-Path "$SaveDir/$testModuleName" | Should -Be $true
210+
}
211+
205212
# Save resource that requires license
206213
It "Save resource that requires accept license with -AcceptLicense flag" {
207214
$pkg = Save-PSResource -Repository $PSGalleryName -TrustRepository -Path $SaveDir -Name $testModuleNameWithLicense -AcceptLicense -PassThru

test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,4 +432,11 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' {
432432
$err[0].FullyQualifiedErrorId | Should -Contain "GetAuthenticodeSignatureError,Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource"
433433
$err[1].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource"
434434
}
435+
436+
# Test that AuthenticodeCheck parameter displays warning on non-Windows
437+
It "Update with AuthenticodeCheck on non-Windows should display warning" -Skip:(Get-IsWindows) {
438+
Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository
439+
Update-PSResource -Name $testModuleName -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -WarningVariable warn -WarningAction SilentlyContinue
440+
$warn | Should -Contain "Authenticode check cannot be performed on Linux or MacOS."
441+
}
435442
}

0 commit comments

Comments
 (0)