mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Fix Install PackageProvider failure because we are not running on administrator
This commit is contained in:
1 parent
c978927947
commit
50c3e5bfc8
4 files changed
+11
-8
No files matched your search
@@ -27,9 +27,13 @@ namespace Microsoft.PackageManagement.Internal.Utility.Platform {
|
||||
/// </returns>
|
||||
public static bool IsElevated {
|
||||
get {
|
||||
#if LINUX
|
||||
return string.Equals(System.Environment.GetEnvironmentVariable("SUDO_UID"), "1000");
|
||||
#else
|
||||
var id = WindowsIdentity.GetCurrent();
|
||||
var principal = new WindowsPrincipal(id);
|
||||
return principal.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ Describe "Get-package" -Tags @('BVT', 'DRT'){
|
||||
|
||||
Describe "Get-package with version parameter - valid scenarios" -Tags @('BVT', 'DRT'){
|
||||
$destination = Join-Path $TestDrive GetPackageTests
|
||||
$destination > C:\test.txt
|
||||
|
||||
It "Get-package supports -AllVersions parameter" -Skip {
|
||||
$outputWithAllVersions = (Get-Package -providername Programs,Msi -AllVersions)
|
||||
|
||||
@@ -742,38 +742,38 @@ Describe "install-packageprovider Error Cases" -Tags @('BVT', 'DRT') {
|
||||
|
||||
It "EXPECTED: returns an error when asking for a provider that does not exist" {
|
||||
$Error.Clear()
|
||||
install-packageprovider -name NOT_EXISTS -warningaction:silentlycontinue -ea silentlycontinue
|
||||
install-packageprovider -name NOT_EXISTS -Scope CurrentUser -warningaction:silentlycontinue -ea silentlycontinue
|
||||
$ERROR[0].FullyQualifiedErrorId | should be "NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
|
||||
}
|
||||
|
||||
|
||||
It "EXPECTED: returns an error when asking for a provider with RequiredVersoin and MinimumVersion" {
|
||||
$Error.Clear()
|
||||
install-packageprovider -name NOT_EXISTS -RequiredVersion 1.0 -MinimumVersion 2.0 -warningaction:silentlycontinue -ea silentlycontinue
|
||||
install-packageprovider -name NOT_EXISTS -Scope CurrentUser -RequiredVersion 1.0 -MinimumVersion 2.0 -warningaction:silentlycontinue -ea silentlycontinue
|
||||
$ERROR[0].FullyQualifiedErrorId | should be "VersionRangeAndRequiredVersionCannotBeSpecifiedTogether,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
|
||||
}
|
||||
|
||||
It "EXPECTED: returns an error when asking for a provider with RequiredVersoin and MaximumVersion" {
|
||||
$Error.Clear()
|
||||
install-packageprovider -name NOT_EXISTS -RequiredVersion 1.0 -MaximumVersion 2.0 -warningaction:silentlycontinue -ea silentlycontinue
|
||||
install-packageprovider -name NOT_EXISTS -Scope CurrentUser -RequiredVersion 1.0 -MaximumVersion 2.0 -warningaction:silentlycontinue -ea silentlycontinue
|
||||
$ERROR[0].FullyQualifiedErrorId | should be "VersionRangeAndRequiredVersionCannotBeSpecifiedTogether,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
|
||||
}
|
||||
|
||||
It "EXPECTED: returns an error when asking for a provider with a MinimumVersion greater than MaximumVersion" {
|
||||
$Error.Clear()
|
||||
install-packageprovider -name nuget -MaximumVersion 1.0 -MinimumVersion 2.0 -warningaction:silentlycontinue -ea silentlycontinue
|
||||
install-packageprovider -name nuget -Scope CurrentUser -MaximumVersion 1.0 -MinimumVersion 2.0 -warningaction:silentlycontinue -ea silentlycontinue
|
||||
$ERROR[0].FullyQualifiedErrorId | should be "NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
|
||||
}
|
||||
|
||||
It "EXPECTED: returns an error when asking for a provider with MinimumVersion that does not exist" {
|
||||
$Error.Clear()
|
||||
install-packageprovider -name gistprovider -MinimumVersion 20.2 -warningaction:silentlycontinue -ea silentlycontinue
|
||||
install-packageprovider -name gistprovider -MinimumVersion 20.2 -warningaction:silentlycontinue -Scope CurrentUser -ea silentlycontinue
|
||||
$ERROR[0].FullyQualifiedErrorId | should be "NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
|
||||
}
|
||||
|
||||
It "EXPECTED: returns an error when asking for a provider with MaximumVersion that does not exist" {
|
||||
$Error.Clear()
|
||||
install-packageprovider -name gistprovider -MaximumVersion 0.1 -warningaction:silentlycontinue -ea silentlycontinue
|
||||
install-packageprovider -name gistprovider -Scope CurrentUser -MaximumVersion 0.1 -warningaction:silentlycontinue -ea silentlycontinue
|
||||
$ERROR[0].FullyQualifiedErrorId | should be "NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
|
||||
}
|
||||
}
|
||||
@@ -548,7 +548,7 @@ Describe Save-Package -Tags @('BVT', 'DRT'){
|
||||
it "EXPECTED: Saves 'Zlib' Package To Packages Directory" {
|
||||
$version = "1.2.8.8"
|
||||
$expectedPackages = @("zlib", "zlib.v120.windesktop.msvcstl.dyn.rt-dyn", "zlib.v140.windesktop.msvcstl.dyn.rt-dyn")
|
||||
$newDestination = "$env:tmp\nugetinstallation"
|
||||
$newDestination = Join-Path $TestDrive "nugetinstallation"
|
||||
|
||||
try {
|
||||
$packages = Save-Package -Name "zlib" -ProviderName $nuget -Source $source -RequiredVersion $version -ForceBootstrap -Path $destination
|
||||
|
||||
Reference in new issue
Block a user