Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/code/InstallHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Microsoft.PowerShell.PowerShellGet.Cmdlets
/// <summary>
/// Install helper class
/// </summary>
internal class InstallHelper : PSCmdlet
internal class InstallHelper
{
#region Members

Expand Down Expand Up @@ -507,7 +507,7 @@ private List<PSResourceInfo> InstallPackage(
_cmdletPassedIn,
out ErrorRecord errorRecord))
{
ThrowTerminatingError(errorRecord);
_cmdletPassedIn.ThrowTerminatingError(errorRecord);
}

if (isModule)
Expand All @@ -529,7 +529,7 @@ private List<PSResourceInfo> InstallPackage(
manifestInfo: out Hashtable parsedMetadataHashtable,
error: out Exception manifestReadError))
{
WriteError(
_cmdletPassedIn.WriteError(
new ErrorRecord(
exception: manifestReadError,
errorId: "ManifestFileReadParseError",
Expand Down
10 changes: 4 additions & 6 deletions test/InstallPSResource.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,13 @@ Describe 'Test Install-PSResource for Module' {
# Install module that is not authenticode signed
# Should FAIL to install the module
It "Install module that is not authenticode signed" -Skip:(!(Get-IsWindows)) {
Install-PSResource -Name $testModuleName -Version "5.0.0" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue
$Error[0].FullyQualifiedErrorId | Should -be "InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"
{ Install-PSResource -Name $testModuleName -Version "5.0.0" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository } | Should -Throw -ErrorId "GetAuthenticodeSignatureError,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"
}

# Install 1.4.4.1 (with incorrect catalog file)
# Should FAIL to install the module
It "Install module with incorrect catalog file" -Skip:(!(Get-IsWindows)) {
Install-PSResource -Name $PackageManagement -Version "1.4.4.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue
$Error[0].FullyQualifiedErrorId | Should -be "InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"
{ Install-PSResource -Name $PackageManagement -Version "1.4.4.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository } | Should -Throw -ErrorId "TestFileCatalogError,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"
}

# Install script that is signed
Expand All @@ -484,8 +483,7 @@ Describe 'Test Install-PSResource for Module' {
# Install script that is not signed
# Should throw
It "Install script that is not signed" -Skip:(!(Get-IsWindows)) {
Install-PSResource -Name "TestTestScript" -Version "1.3.1.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue
$Error[0].FullyQualifiedErrorId | Should -be "InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"
{ Install-PSResource -Name "TestTestScript" -Version "1.3.1.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository } | Should -Throw -ErrorId "GetAuthenticodeSignatureError,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"
}
}

Expand Down
9 changes: 3 additions & 6 deletions test/SavePSResource.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,13 @@ Describe 'Test Save-PSResource for PSResources' {
# Save module that is not authenticode signed
# Should FAIL to save the module
It "Save module that is not authenticode signed" -Skip:(!(Get-IsWindows)) {
Save-PSResource -Name $testModuleName -Version "5.0.0" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -Path $SaveDir -ErrorAction SilentlyContinue
$Error[0].FullyQualifiedErrorId | Should -be "InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource"
{ Save-PSResource -Name $testModuleName -Version "5.0.0" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -Path $SaveDir } | Should -Throw -ErrorId "GetAuthenticodeSignatureError,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource"
}

# Save 1.4.4.1 (with incorrect catalog file)
# Should FAIL to save the module
It "Save module with incorrect catalog file" -Skip:(!(Get-IsWindows)) {
Save-PSResource -Name $PackageManagement -Version "1.4.4.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -Path $SaveDir -ErrorAction SilentlyContinue
$Error[0].FullyQualifiedErrorId | Should -be "InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource"
{ Save-PSResource -Name $PackageManagement -Version "1.4.4.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -Path $SaveDir } | Should -Throw -ErrorId "TestFileCatalogError,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource"
}

# Save script that is signed
Expand All @@ -282,8 +280,7 @@ Describe 'Test Save-PSResource for PSResources' {
# Save script that is not signed
# Should throw
It "Save script that is not signed" -Skip:(!(Get-IsWindows)) {
Save-PSResource -Name "TestTestScript" -Version "1.3.1.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue
$Error[0].FullyQualifiedErrorId | Should -be "InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource"
{ Save-PSResource -Name "TestTestScript" -Version "1.3.1.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository } | Should -Throw -ErrorId "GetAuthenticodeSignatureError,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource"
}

<#
Expand Down
6 changes: 2 additions & 4 deletions test/UpdatePSResource.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,7 @@ Describe 'Test Update-PSResource' {
# Should FAIL to update the module
It "Update module with incorrect catalog file" -Skip:(!(Get-IsWindows)) {
Install-PSResource -Name $PackageManagement -Version "1.4.2" -Repository $PSGalleryName -TrustRepository
Update-PSResource -Name $PackageManagement -Version "1.4.4.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue
$Error[0].FullyQualifiedErrorId | Should -be "InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.UpdatePSResource"
{ Update-PSResource -Name $PackageManagement -Version "1.4.4.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository } | Should -Throw -ErrorId "TestFileCatalogError,Microsoft.PowerShell.PowerShellGet.Cmdlets.UpdatePSResource"
}

# Update script that is signed
Expand All @@ -371,7 +370,6 @@ Describe 'Test Update-PSResource' {
# Should throw
It "Update script that is not signed" -Skip:(!(Get-IsWindows)) {
Install-PSResource -Name "TestTestScript" -Version "1.0" -Repository $PSGalleryName -TrustRepository
Update-PSResource -Name "TestTestScript" -Version "1.3.1.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue
$Error[0].FullyQualifiedErrorId | Should -be "InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.UpdatePSResource"
{ Update-PSResource -Name "TestTestScript" -Version "1.3.1.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository } | Should -Throw -ErrorId "GetAuthenticodeSignatureError,Microsoft.PowerShell.PowerShellGet.Cmdlets.UpdatePSResource"
}
}