release: bump version to 0.75.2
This commit is contained in:
1 parent
003b316d42
commit
a2025dbfe0
11 files changed
+105
-12
No files matched your search
@@ -78,3 +78,50 @@ try {
|
||||
[IO.Path]::GetFileName($resolved) -notlike 'planet-launcher-tests-*') { throw 'Unsafe cleanup path' }
|
||||
Remove-Item -LiteralPath $resolved -Recurse -Force
|
||||
}
|
||||
|
||||
function Get-Command {
|
||||
param([string]$Name, [string]$CommandType, [string]$ErrorAction)
|
||||
if ($script:AvailableLaunchCommands.ContainsKey($Name)) {
|
||||
return [pscustomobject]@{ Source = $script:AvailableLaunchCommands[$Name] }
|
||||
}
|
||||
}
|
||||
$pwshPath = 'C:\Program Files\PowerShell\7\pwsh.exe'
|
||||
$terminalPath = 'C:\Users\Test\AppData\Local\Microsoft\WindowsApps\wt.exe'
|
||||
$legacyPath = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'
|
||||
foreach ($hasTerminal in @($true, $false)) {
|
||||
foreach ($hasPwsh in @($true, $false)) {
|
||||
$script:AvailableLaunchCommands = @{ 'powershell.exe' = $legacyPath }
|
||||
if ($hasTerminal) { $script:AvailableLaunchCommands['wt.exe'] = $terminalPath }
|
||||
if ($hasPwsh) { $script:AvailableLaunchCommands['pwsh.exe'] = $pwshPath }
|
||||
$launch = Get-PlanetTerminalLaunch 'TESTPAYLOAD'
|
||||
$expectedShell = if ($hasPwsh) { $pwshPath } else { $legacyPath }
|
||||
$expectedExecutable = if ($hasTerminal) { $terminalPath } else { $expectedShell }
|
||||
Assert-Equal $expectedExecutable $launch.FilePath 'Terminal/shell priority'
|
||||
if ($hasTerminal -and -not $launch.ArgumentList.Contains('"' + $expectedShell + '"')) {
|
||||
throw 'Terminal shell path must be quoted, including Program Files paths'
|
||||
}
|
||||
if ($launch.ArgumentList -notmatch '-EncodedCommand TESTPAYLOAD$') {
|
||||
throw 'Encoded bootstrap was not preserved'
|
||||
}
|
||||
}
|
||||
}
|
||||
function Test-PlanetAdministrator { return $script:IsTestAdministrator }
|
||||
function Start-Process {
|
||||
param($FilePath, $ArgumentList, $WindowStyle, $Verb)
|
||||
$script:CapturedLaunch = @{ FilePath = $FilePath; ArgumentList = $ArgumentList; Verb = $Verb }
|
||||
$script:LaunchCount++
|
||||
}
|
||||
$script:AvailableLaunchCommands = @{ 'pwsh.exe' = $pwshPath; 'wt.exe' = $terminalPath }
|
||||
$script:LaunchCount = 0
|
||||
foreach ($isAdmin in @($false, $true)) {
|
||||
$script:IsTestAdministrator = $isAdmin
|
||||
Start-PlanetRestart $target
|
||||
Assert-Equal $terminalPath $script:CapturedLaunch.FilePath 'Admin and ordinary entry both use Terminal'
|
||||
if ($isAdmin -and $script:CapturedLaunch.Verb) { throw 'Already elevated entry must not request UAC again' }
|
||||
if (-not $isAdmin) { Assert-Equal 'RunAs' $script:CapturedLaunch.Verb 'Ordinary entry requires elevation' }
|
||||
}
|
||||
$script:IsTestAdministrator = $false
|
||||
try { Start-PlanetRestart $target -AlreadyElevated; throw 'Unelevated child accepted' }
|
||||
catch { if ($_.Exception.Message -ne 'Administrator elevation was not granted.') { throw } }
|
||||
Assert-Equal 2 $script:LaunchCount 'Child must not recursively launch more windows'
|
||||
Write-Host 'PASS: Terminal/PowerShell priority, quoted paths, elevation and no recursive dispatch'
|
||||
Reference in new issue
Block a user