Compare commits

...

2 Commits

Author SHA1 Message Date
Dandaedre 110f09dac2 Remove legacy PDF Presenter registration
Config Central CI Config Central passed all CI integrity checks.
Beffroi/config-central/pipeline/head This commit looks good Details
2026-11-21 12:53:51 +01:00
Dandaedre e2e0cc3deb Remove Pympress through package policy 2026-11-21 12:52:14 +01:00
15 changed files with 259 additions and 15 deletions

View File

@ -105,7 +105,10 @@ user confirmation and Config Central preserves that choice across updates.
The first Deckstride update installs and verifies
[Deckstride 0.1.96](https://proxy.dandaedre.com/gitea/idle-org/Deckstride/releases/tag/v0.1.96)
before removing the managed PDF Presenter files, Start menu shortcut and old
handler registration.
handler registration. Cleanup also removes PDF Presenter's obsolete Default Apps
and **Open with** registry entries. The desktop policy declares Pympress absent,
so Config Central uninstalls it by its exact WinGet ID when found and treats an
already removed copy as unchanged.
Like `cc sync`, `update-software` refuses to fetch while the checkout contains
uncommitted or untracked files. It does not reset or overwrite those edits.

View File

@ -166,6 +166,7 @@ open until it is run on disposable machines with the required account setups.
- [x] Give PDF Presenter associations a dedicated branded PDF document icon that remains stable across portable updates (169 Linux Pester tests pass; 5 Windows-only skips).
- [x] Support explicit portable rename migrations that activate the successor before removing the verified old installation and handler registration, preserve local edits, and retry cleanup (189 Linux Pester tests pass; 5 Windows-only skips).
- [x] Replace the PDF Presenter declaration with verified Deckstride 0.1.96 from `idle-org/Deckstride`; keep the one-time Windows `.pdf` default selection in the Windows acceptance task (192 Linux Pester tests pass; 5 Windows-only skips).
- [x] Remove PDF Presenter's legacy self-registered Default Apps and Open With entries during the Deckstride migration.
## PowerShell prerequisite reliability
@ -176,6 +177,7 @@ open until it is run on disposable machines with the required account setups.
## Requested Beffroi tools
- [x] Add verified PPTX Reporter 0.2.0 portable installation and update PDF Presenter to the stable 0.1.91 release.
- [x] Declare Pympress absent and remove it idempotently through its exact WinGet package ID.
## Setup progress feedback

View File

@ -320,8 +320,9 @@ and repository hygiene checks; it does not pretend to execute Windows behavior.
failure. Successful independent work is recorded so the next run can resume.
- Config Central does not disable Defender, UAC, malware scanning, or installer
integrity checks.
- Package removal and deletion of formerly managed configs are deliberately
manual operations.
- Deletion of formerly managed configs remains manual. Removing a package entry
only stops management; an explicit WinGet `state: "absent"` policy uninstalls
that exact package.
Item results color status labels; script summaries use the same palette: red
errors, yellow warnings, green completion, gray unchanged items, and cyan planned
@ -359,6 +360,8 @@ Central code and policy. It then checks the Gitea releases API for opted-in
portable packages and asks WinGet to apply each declared package's policy by
exact ID. Deckstride follows the newest eligible stable release.
Unmanaged WinGet applications are left alone. Configs are not planned or changed.
The profile declares Pympress absent, so each software run silently leaves it
alone when missing and uninstalls it by exact WinGet ID when found.
Each release lookup resolves one exact ZIP, reads its exact entry from
`SHA256SUMS`, and verifies the downloaded archive before activation. Both tools
follow stable releases. A lookup or checksum failure is reported for that package
@ -405,7 +408,8 @@ rewriting the user's default-app preference.
Deckstride's declaration includes a `replaces` entry for
`idle-org/pdf-presenter`. On the first successful update, Config Central
activates Deckstride before removing PDF Presenter's managed files, shortcut and
old `.pdf` registration. If the old installation was locally modified or cannot
old `.pdf` registration, including PDF Presenter's own obsolete Default Apps and
Open With ProgID entries. If the old installation was locally modified or cannot
be removed, Deckstride stays installed and cleanup is retried later. Select
Deckstride once in Windows Default Apps because Windows does not allow software
to transfer the protected `.pdf` default choice to a renamed handler.

View File

@ -21,6 +21,11 @@ policies are:
offers it, and leave an already newer version alone with a warning.
- `install-only`: install when absent and never upgrade an installed package.
Package `state` defaults to `present`. A WinGet package with `state: "absent"`
is uninstalled by exact ID when present and otherwise reported unchanged. This
is an explicit removal policy; deleting a package entry still only stops
management. Portable rename removal continues to use `replaces`.
An unavailable requested version, unsupported installer scope, ambiguous
inventory, or unknown installed version becomes a failed package operation with
the WinGet diagnostics preserved. Configs requiring that package are skipped.
@ -120,6 +125,9 @@ in the package root instead of pointing Explorer at a versioned executable icon.
A renamed portable package may declare `replaces` with the old lowercase
`source` and `id`, plus any old `fileAssociations` that must be unregistered.
When the predecessor registered itself separately, `legacyRegistration` names
its Registered Applications value and ProgIDs so Config Central can also remove
those obsolete Default Apps and Open With entries.
This is an explicit removal request. Config Central activates and verifies the
new package first, then removes the old managed root, Start menu shortcut,
Default Apps registration and listed ProgIDs. Missing or locally modified files

View File

@ -26,7 +26,11 @@
{
"source": "idle-org",
"id": "pdf-presenter",
"fileAssociations": [".pdf"]
"fileAssociations": [".pdf"],
"legacyRegistration": {
"registeredApplication": "PDF Presenter",
"progIds": ["PDFPresenter.Document"]
}
}
]
},
@ -47,6 +51,7 @@
"checksumAsset": "SHA256SUMS",
"displayName": "PPTX Reporter"
},
{ "id": "Cimbali.pympress", "source": "winget", "state": "absent" },
{ "id": "clsid2.mpc-hc", "source": "winget", "scope": "machine", "update": "latest" },
{ "id": "XnSoft.XnViewMP", "source": "winget", "scope": "machine", "update": "latest" },
{ "id": "Zoom.Zoom", "source": "winget", "scope": "machine", "update": "latest" },

View File

@ -70,6 +70,13 @@
],
"default": "latest"
},
"state": {
"enum": [
"present",
"absent"
],
"default": "present"
},
"enabled": {
"type": "boolean",
"default": true
@ -160,6 +167,28 @@
"type": "string",
"pattern": "^\\.[a-z0-9]{1,16}$"
}
},
"legacyRegistration": {
"type": "object",
"additionalProperties": false,
"required": ["registeredApplication", "progIds"],
"properties": {
"registeredApplication": {
"type": "string",
"minLength": 1,
"maxLength": 64,
"pattern": "^[^\\x00-\\x1f\\\\/]+$"
},
"progIds": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$"
}
}
}
}
}
}
@ -187,6 +216,9 @@
},
"scope": {
"const": "user"
},
"state": {
"const": "present"
}
},
"allOf": [

View File

@ -84,7 +84,7 @@ function Assert-PortableDeclaration {
if ($replacementProperty.Value -isnot [Array] -or $replacementProperty.Value.Count -eq 0) { throw 'Portable replaces must be a non-empty array.' }
$seenReplacements = [Collections.Generic.HashSet[string]]::new([StringComparer]::OrdinalIgnoreCase)
foreach ($replacement in @($replacementProperty.Value)) {
Assert-AllowedProperties $replacement @('source', 'id', 'fileAssociations') 'portable replacement'
Assert-AllowedProperties $replacement @('source', 'id', 'fileAssociations', 'legacyRegistration') 'portable replacement'
$replacementSource = [string](Get-OptionalProperty $replacement 'source')
$replacementId = [string](Get-OptionalProperty $replacement 'id')
if ($replacementSource -cnotmatch '^[a-z0-9][a-z0-9-]{0,63}$' -or $replacementId -cnotmatch '^[a-z0-9][a-z0-9-]{0,63}$') { throw 'Portable replacement source and id must be lowercase slugs.' }
@ -98,6 +98,18 @@ function Assert-PortableDeclaration {
foreach ($extension in @($replacementAssociations)) {
if ($extension -cnotmatch '^\.[a-z0-9]{1,16}$' -or -not $seenExtensions.Add($extension)) { throw "Invalid or duplicate portable replacement file association '$extension'." }
}
$legacyRegistration = $replacement.PSObject.Properties['legacyRegistration']
if ($null -ne $legacyRegistration) {
Assert-AllowedProperties $legacyRegistration.Value @('registeredApplication', 'progIds') 'portable replacement legacyRegistration'
$registeredApplication = [string](Get-OptionalProperty $legacyRegistration.Value 'registeredApplication')
if ([string]::IsNullOrWhiteSpace($registeredApplication) -or $registeredApplication.Length -gt 64 -or $registeredApplication -match '[\x00-\x1f\\/]') { throw 'Portable replacement registeredApplication is unsafe.' }
$progIdProperty = $legacyRegistration.Value.PSObject.Properties['progIds']
if ($null -eq $progIdProperty -or $progIdProperty.Value -isnot [Array] -or $progIdProperty.Value.Count -eq 0) { throw 'Portable replacement legacyRegistration progIds must be a non-empty array.' }
$seenProgIds = [Collections.Generic.HashSet[string]]::new([StringComparer]::OrdinalIgnoreCase)
foreach ($progId in @($progIdProperty.Value)) {
if ($progId -cnotmatch '^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$' -or -not $seenProgIds.Add($progId)) { throw "Invalid or duplicate portable replacement ProgID '$progId'." }
}
}
}
}
@ -137,15 +149,18 @@ function Assert-ItemList {
foreach ($item in $Items) {
if ($Kind -eq 'package') {
Assert-AllowedProperties $item @(
'id', 'source', 'scope', 'version', 'update', 'enabled', 'provider', 'url', 'sha256', 'executable',
'id', 'source', 'scope', 'version', 'update', 'state', 'enabled', 'provider', 'url', 'sha256', 'executable',
'releaseApi', 'releaseChannel', 'assetTemplate', 'executableTemplate', 'checksumAsset', 'displayName', 'fileAssociations', 'fileAssociationIcon', 'replaces'
) "$Location[$index]"
if ([string]::IsNullOrWhiteSpace([string](Get-OptionalProperty $item 'id'))) { throw "$Location[$index].id is required." }
$source = [string](Get-OptionalProperty $item 'source' 'winget')
$key = "$source/$($item.id)"
$provider = Get-OptionalProperty $item 'provider' 'winget'
$desiredState = [string](Get-OptionalProperty $item 'state' 'present')
if ($desiredState -notin @('present', 'absent')) { throw 'Package state must be present or absent.' }
if ($provider -notin @('winget', 'portable')) { throw 'Unknown package provider.' }
if ($provider -eq 'portable') {
if ($desiredState -ne 'present') { throw 'Portable packages use replaces for explicit removal.' }
$key = "portable/$key"
Assert-PortableDeclaration $item $source
}
@ -217,7 +232,7 @@ function Add-ManifestItems {
if (-not $enabled) { $Target.Remove($key); continue }
if ($Kind -eq 'package') {
$normalized = [ordered]@{ id = [string]$item.id; source = $source; update = [string](Get-OptionalProperty $item 'update' 'latest') }
$normalized = [ordered]@{ id = [string]$item.id; source = $source; update = [string](Get-OptionalProperty $item 'update' 'latest'); state = [string](Get-OptionalProperty $item 'state' 'present') }
foreach ($field in @(
'scope', 'version', 'provider', 'url', 'sha256', 'executable',
'releaseApi', 'releaseChannel', 'assetTemplate', 'executableTemplate', 'checksumAsset', 'displayName', 'fileAssociations', 'fileAssociationIcon', 'replaces'

View File

@ -69,6 +69,15 @@ function Get-PackagePlan {
continue
}
$installed = if ($Inventory.Contains($key)) { $Inventory[$key] } else { $null }
if ($package.PSObject.Properties['state'] -and $package.state -eq 'absent') {
if ($null -eq $installed) {
$plan.Add([pscustomobject]@{ kind = 'package'; name = $package.id; action = 'None'; reason = 'Already absent'; package = $package })
}
else {
$plan.Add([pscustomobject]@{ kind = 'package'; name = $package.id; action = 'Uninstall'; reason = "Remove installed version $($installed.version)"; package = $package })
}
continue
}
$versionProperty = $package.PSObject.Properties['version']
$requestedVersion = if ($null -ne $versionProperty) { [string]$versionProperty.Value } else { $null }
if ($null -eq $installed) {
@ -119,11 +128,24 @@ function Invoke-PackageOperation {
if ($package.id -in @('Microsoft.PowerShell', 'Microsoft.PowerShell.Preview')) {
return [pscustomobject]@{ name = $Operation.name; status = 'Warning'; exitCode = 0; rebootRequired = $false; message = 'PowerShell is the Config Central runtime; update it separately with Config Central closed, using the original installation method.' }
}
$verb = if ($Operation.action -eq 'Upgrade') { 'upgrade' } else { 'install' }
$arguments = @($verb, '--id', $package.id, '--exact', '--source', $package.source, '--silent', '--disable-interactivity', '--accept-package-agreements', '--accept-source-agreements')
$verb = if ($Operation.action -eq 'Upgrade') { 'upgrade' } elseif ($Operation.action -eq 'Uninstall') { 'uninstall' } else { 'install' }
$arguments = @($verb, '--id', $package.id, '--exact', '--source', $package.source, '--silent', '--disable-interactivity', '--accept-source-agreements')
if ($verb -ne 'uninstall') { $arguments += '--accept-package-agreements' }
if ($package.PSObject.Properties['scope']) { $arguments += @('--scope', $package.scope) }
if ($package.PSObject.Properties['version']) { $arguments += @('--version', $package.version) }
$result = Invoke-WingetCapture -Arguments $arguments -LogPath $LogPath
if ($verb -eq 'uninstall') {
if ($result.unsignedExitCode -eq $script:WingetNoApplicationsFound) {
return [pscustomobject]@{ name = $Operation.name; status = 'Unchanged'; exitCode = 0; rebootRequired = $false; message = 'Already absent' }
}
if ($result.exitCode -in @(3010, 1641)) {
return [pscustomobject]@{ name = $Operation.name; status = 'Succeeded'; exitCode = $result.exitCode; rebootRequired = $true; message = 'Uninstalled; reboot required' }
}
if ($result.exitCode -ne 0) {
return [pscustomobject]@{ name = $Operation.name; status = 'Failed'; exitCode = $result.unsignedExitCode; rebootRequired = $false; message = $result.output }
}
return [pscustomobject]@{ name = $Operation.name; status = 'Succeeded'; exitCode = 0; rebootRequired = $false; message = 'Uninstalled' }
}
# Inventory is collected before execution and does not identify installer scope.
# A package can disappear or be absent in the elevated worker's scope.
$installedAfterMissingUpgrade = $false

View File

@ -114,6 +114,14 @@ function Remove-PortableRegistryTree {
[Microsoft.Win32.Registry]::CurrentUser.DeleteSubKeyTree($Path, $false)
}
function Test-PortableRegistryTree {
param([Parameter(Mandatory)][string]$Path)
$key = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey($Path, $false)
if ($null -eq $key) { return $false }
$key.Dispose()
return $true
}
function Test-PortableFileAssociations {
param($Package, [Parameter(Mandatory)][string]$Executable, [string]$Icon)
$specs = @(Get-PortableAssociationSpec -Package $Package -Executable $Executable -Icon $Icon)
@ -159,6 +167,40 @@ function Remove-PortableFileAssociations {
Remove-PortableRegistryTree -Path "Software\Classes\$progId"
}
Remove-PortableRegistryTree -Path $capabilitiesPath
if ($Replacement.PSObject.Properties['legacyRegistration']) {
Remove-PortableLegacyRegistration -Replacement $Replacement
}
}
function Remove-PortableLegacyRegistration {
param($Replacement)
$legacy = $Replacement.legacyRegistration
$registeredApplication = [string]$legacy.registeredApplication
$extensions = if ($Replacement.PSObject.Properties['fileAssociations']) { @($Replacement.fileAssociations) } else { @() }
Remove-PortableRegistryValue -Path 'Software\RegisteredApplications' -Name $registeredApplication
foreach ($progId in @($legacy.progIds)) {
foreach ($extension in $extensions) {
Remove-PortableRegistryValue -Path "Software\Classes\$($extension.ToLowerInvariant())\OpenWithProgids" -Name $progId
}
Remove-PortableRegistryTree -Path "Software\Classes\$progId"
}
Remove-PortableRegistryTree -Path "Software\$registeredApplication\Capabilities"
}
function Test-PortableLegacyRegistrationPresent {
param($Replacement)
if (-not $Replacement.PSObject.Properties['legacyRegistration']) { return $false }
$legacy = $Replacement.legacyRegistration
if ($null -ne (Get-PortableRegistryValue -Path 'Software\RegisteredApplications' -Name ([string]$legacy.registeredApplication))) { return $true }
if (Test-PortableRegistryTree -Path "Software\$($legacy.registeredApplication)\Capabilities") { return $true }
$extensions = if ($Replacement.PSObject.Properties['fileAssociations']) { @($Replacement.fileAssociations) } else { @() }
foreach ($progId in @($legacy.progIds)) {
if (Test-PortableRegistryTree -Path "Software\Classes\$progId") { return $true }
foreach ($extension in $extensions) {
if ($null -ne (Get-PortableRegistryValue -Path "Software\Classes\$($extension.ToLowerInvariant())\OpenWithProgids" -Name $progId)) { return $true }
}
}
return $false
}
function Test-PortableReplacementPresent {
@ -167,7 +209,8 @@ function Test-PortableReplacementPresent {
if ((Test-Path -LiteralPath $paths.Root) -or ($paths.Shortcut -and (Test-Path -LiteralPath $paths.Shortcut))) { return $true }
if (-not $IsWindows) { return $false }
$registeredName = "ConfigCentral.$($Replacement.source).$($Replacement.id)"
return $null -ne (Get-PortableRegistryValue -Path 'Software\RegisteredApplications' -Name $registeredName)
return $null -ne (Get-PortableRegistryValue -Path 'Software\RegisteredApplications' -Name $registeredName) -or
(Test-PortableLegacyRegistrationPresent -Replacement $Replacement)
}
function Assert-PortableManagedReplacement {

View File

@ -27,7 +27,7 @@ try {
if ($request.requestType -eq 'packages') {
foreach ($operation in @($request.operations)) {
if ($operation.package.PSObject.Properties['provider'] -and $operation.package.provider -ne 'winget') { throw 'Only WinGet packages may use the elevated worker.' }
if ($operation.kind -ne 'package' -or $operation.action -notin @('Install', 'Upgrade', 'None', 'Warning')) { throw 'Elevation request contains an unsupported operation.' }
if ($operation.kind -ne 'package' -or $operation.action -notin @('Install', 'Upgrade', 'Uninstall', 'None', 'Warning')) { throw 'Elevation request contains an unsupported operation.' }
if ($operation.package.id -notmatch '^[A-Za-z0-9._+-]+$' -or $operation.package.source -notmatch '^[A-Za-z0-9._+-]+$') { throw 'Elevation request contains an unsafe package identifier.' }
if ($operation.package.PSObject.Properties['scope'] -and $operation.package.scope -ne 'machine') { throw 'Elevated operations must use machine scope.' }
}

View File

@ -5,7 +5,7 @@ BeforeAll {
Describe 'Manifest resolution' {
It 'resolves the checked-in example in profile order' {
$result = Resolve-MachineManifest -RepositoryRoot "$PSScriptRoot/.." -Machine 'beffroi-laptop'
$result.packages.Count | Should -Be 15
$result.packages.Count | Should -Be 16
$result.packages.id | Should -Not -Contain 'Microsoft.PowerShell'
$result.configs.Count | Should -Be 9
$result.packages[0].id | Should -Be 'Git.Git'
@ -36,6 +36,8 @@ Describe 'Manifest resolution' {
$reporter.source | Should -Be 'beffroi'
$reporter.version | Should -Be '0.2.0'
$reporter.executable | Should -Match 'pptx-reporter-gui\.exe$'
$pympress = $result.packages | Where-Object id -eq 'Cimbali.pympress'
$pympress.state | Should -Be 'absent'
$result.packages.id | Should -Not -Contain 'cpvalente.ontime'
}

View File

@ -23,6 +23,15 @@ Describe 'Package planning' {
(Get-PackagePlan -Packages @($package) -Inventory $inventory)[0].action | Should -Be 'Warning'
}
It 'plans explicit package absence idempotently' {
$package = [pscustomobject]@{ id = 'Cimbali.pympress'; source = 'winget'; state = 'absent'; update = 'latest' }
(Get-PackagePlan -Packages @($package) -Inventory @{})[0].action | Should -Be 'None'
$inventory = @{ 'winget/cimbali.pympress' = [pscustomobject]@{ version = '1.8.3' } }
$operation = (Get-PackagePlan -Packages @($package) -Inventory $inventory)[0]
$operation.action | Should -Be 'Uninstall'
$operation.reason | Should -Match '1\.8\.3'
}
It 'continues after an individual package failure' {
InModuleScope Packages {
Mock Invoke-PackageOperation {
@ -35,6 +44,41 @@ Describe 'Package planning' {
}
}
Describe 'WinGet package removal' {
It 'uninstalls by exact ID and treats a missing package as unchanged' {
InModuleScope Packages {
Mock Invoke-WingetCapture {
[pscustomobject]@{ exitCode = -1978335212; unsignedExitCode = 2316632084; output = 'No installed package found' }
}
$operation = [pscustomobject]@{
action = 'Uninstall'; name = 'Cimbali.pympress'
package = [pscustomobject]@{ id = 'Cimbali.pympress'; source = 'winget'; state = 'absent' }
}
$result = Invoke-PackageOperation -Operation $operation
$result.status | Should -Be 'Unchanged'
$result.message | Should -Be 'Already absent'
Should -Invoke Invoke-WingetCapture -Times 1 -Exactly -ParameterFilter {
$Arguments[0] -eq 'uninstall' -and $Arguments -contains '--id' -and
$Arguments -contains 'Cimbali.pympress' -and $Arguments -contains '--exact' -and
$Arguments -contains '--silent' -and $Arguments -notcontains '--accept-package-agreements'
}
}
}
It 'preserves uninstall failure diagnostics' {
InModuleScope Packages {
Mock Invoke-WingetCapture { [pscustomobject]@{ exitCode = 1; unsignedExitCode = 1; output = 'Uninstall failed' } }
$operation = [pscustomobject]@{
action = 'Uninstall'; name = 'Cimbali.pympress'
package = [pscustomobject]@{ id = 'Cimbali.pympress'; source = 'winget'; state = 'absent' }
}
$result = Invoke-PackageOperation -Operation $operation
$result.status | Should -Be 'Failed'
$result.message | Should -Be 'Uninstall failed'
}
}
}
Describe 'Release lookup failures' {
It 'returns a structured failure without invoking either package provider' {
InModuleScope Packages {

View File

@ -58,7 +58,10 @@ Describe 'Portable declarations' {
It 'accepts and preserves an explicit portable replacement declaration' {
$item | Add-Member -NotePropertyName replaces -NotePropertyValue ([object[]]@(
[pscustomobject]@{ source = 'idle-org'; id = 'pdf-presenter'; fileAssociations = [object[]]@('.pdf') }
[pscustomobject]@{
source = 'idle-org'; id = 'pdf-presenter'; fileAssociations = [object[]]@('.pdf')
legacyRegistration = [pscustomobject]@{ registeredApplication = 'PDF Presenter'; progIds = [object[]]@('PDFPresenter.Document') }
}
))
Assert-ItemList @($item) package test
$items = [ordered]@{}
@ -67,6 +70,18 @@ Describe 'Portable declarations' {
$replacement.source | Should -Be 'idle-org'
$replacement.id | Should -Be 'pdf-presenter'
$replacement.fileAssociations | Should -Be @('.pdf')
$replacement.legacyRegistration.registeredApplication | Should -Be 'PDF Presenter'
$replacement.legacyRegistration.progIds | Should -Be @('PDFPresenter.Document')
}
It 'accepts explicit WinGet absence and rejects it for portable packages' {
$winget = [pscustomobject]@{ id = 'Cimbali.pympress'; source = 'winget'; state = 'absent' }
{ Assert-ItemList @($winget) package test } | Should -Not -Throw
$items = [ordered]@{}
Add-ManifestItems $items @($winget) package
$items['winget/Cimbali.pympress'].state | Should -Be 'absent'
$item | Add-Member state absent
{ Assert-ItemList @($item) package test } | Should -Throw '*use replaces*'
}
It 'rejects unsafe, duplicate, or self-referential portable replacements' -ForEach @(
@ -75,6 +90,8 @@ Describe 'Portable declarations' {
@{ Replacements = @([pscustomobject]@{ source = 'gitea'; id = 'presenter' }) }
@{ Replacements = @([pscustomobject]@{ source = 'old'; id = 'app' }, [pscustomobject]@{ source = 'OLD'; id = 'app' }) }
@{ Replacements = @([pscustomobject]@{ source = 'old'; id = 'app'; fileAssociations = @('pdf') }) }
@{ Replacements = @([pscustomobject]@{ source = 'old'; id = 'app'; legacyRegistration = [pscustomobject]@{ registeredApplication = 'Old/App'; progIds = @('Old.App') } }) }
@{ Replacements = @([pscustomobject]@{ source = 'old'; id = 'app'; legacyRegistration = [pscustomobject]@{ registeredApplication = 'Old App'; progIds = @('bad progid') } }) }
@{ Replacements = @([pscustomobject]@{ source = 'old'; id = 'app'; unknown = 'value' }) }
) {
$item | Add-Member replaces $Replacements

View File

@ -321,6 +321,39 @@ Describe 'Portable file association registration' {
$Path -like '*\DefaultIcon' -and $Name -eq '' -and $Value -eq ($icon + ',0')
}
}
It 'removes a predecessor application own PDF registration' {
$replacement = [pscustomobject]@{
source = 'idle-org'; id = 'pdf-presenter'; fileAssociations = @('.pdf')
legacyRegistration = [pscustomobject]@{ registeredApplication = 'PDF Presenter'; progIds = @('PDFPresenter.Document') }
}
Mock Remove-PortableRegistryValue {}
Mock Remove-PortableRegistryTree {}
Remove-PortableLegacyRegistration -Replacement $replacement
Should -Invoke Remove-PortableRegistryValue -Times 1 -Exactly -ParameterFilter {
$Path -eq 'Software\RegisteredApplications' -and $Name -eq 'PDF Presenter'
}
Should -Invoke Remove-PortableRegistryValue -Times 1 -Exactly -ParameterFilter {
$Path -eq 'Software\Classes\.pdf\OpenWithProgids' -and $Name -eq 'PDFPresenter.Document'
}
Should -Invoke Remove-PortableRegistryTree -Times 1 -Exactly -ParameterFilter {
$Path -eq 'Software\Classes\PDFPresenter.Document'
}
Should -Invoke Remove-PortableRegistryTree -Times 1 -Exactly -ParameterFilter {
$Path -eq 'Software\PDF Presenter\Capabilities'
}
}
It 'detects a predecessor registration after managed files are gone' {
$replacement = [pscustomobject]@{
source = 'idle-org'; id = 'pdf-presenter'; fileAssociations = @('.pdf')
legacyRegistration = [pscustomobject]@{ registeredApplication = 'PDF Presenter'; progIds = @('PDFPresenter.Document') }
}
Mock Get-PortableRegistryValue {
if ($Path -eq 'Software\Classes\.pdf\OpenWithProgids' -and $Name -eq 'PDFPresenter.Document') { return '' }
return $null
}
Mock Test-PortableRegistryTree { $false }
Test-PortableLegacyRegistrationPresent -Replacement $replacement | Should -BeTrue
}
}
}

View File

@ -35,14 +35,28 @@ Describe 'Published manifest schemas' {
$package = [ordered]@{
id = 'deckstride'; provider = 'portable'; source = 'idle-org'; version = '1.0'; update = 'pinned'
url = 'https://example.org/deckstride.zip'; executable = 'deckstride.exe'; sha256 = 'a' * 64
replaces = @([ordered]@{ source = 'idle-org'; id = 'pdf-presenter'; fileAssociations = @('.pdf') })
replaces = @([ordered]@{
source = 'idle-org'; id = 'pdf-presenter'; fileAssociations = @('.pdf')
legacyRegistration = [ordered]@{ registeredApplication = 'PDF Presenter'; progIds = @('PDFPresenter.Document') }
})
}
$profile = [ordered]@{ schemaVersion = 1; name = 'test'; packages = @($package) }
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema | Should -BeTrue
$package.replaces[0].fileAssociations = @('pdf')
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
$package.replaces[0].fileAssociations = @('.pdf')
$package.replaces[0].legacyRegistration.progIds = @('bad progid')
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
$package.replaces[0].legacyRegistration.progIds = @('PDFPresenter.Document')
$package.replaces[0].unknown = 'value'
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
}
It 'allows absent WinGet packages but not absent portable packages' {
$schema = "$PSScriptRoot/../schemas/profile.schema.json"
$package = [ordered]@{ id = 'Cimbali.pympress'; source = 'winget'; state = 'absent' }
$profile = [ordered]@{ schemaVersion = 1; name = 'test'; packages = @($package) }
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema | Should -BeTrue
$package.provider = 'portable'
$profile | ConvertTo-Json -Depth 8 | Test-Json -SchemaFile $schema -ErrorAction SilentlyContinue | Should -BeFalse
}
}