Accept signed integer values in registry declarations
This commit is contained in:
parent
557440b4ea
commit
f4448c5662
1
TASKS.md
1
TASKS.md
|
|
@ -131,3 +131,4 @@ open until it is run on disposable machines with the required account setups.
|
|||
- [x] Replace bootstrap exit-code exceptions with friendly partial-success, reboot, and busy summaries while preserving automation status.
|
||||
- [x] Avoid null temporary-file cleanup after registry deployment or config adoption; preserve original per-item errors.
|
||||
- [x] Report CLI exceptions concisely on stderr without throwing from the error handler; preserve exit code 2 and JSON errors.
|
||||
- [x] Accept signed registry DWORD/QWORD exports and validate the complete MPC-HC declaration with mocked registry writes.
|
||||
|
|
|
|||
|
|
@ -196,8 +196,8 @@ function Set-RegistryDeclaration {
|
|||
$path = if ([string]::IsNullOrWhiteSpace([string]$entry.path)) { $Root } else { Join-Path $Root $entry.path }
|
||||
[void](New-Item -Path $path -Force)
|
||||
$value = switch ($entry.type) {
|
||||
'DWord' { [uint32]$entry.value }
|
||||
'QWord' { [uint64]$entry.value }
|
||||
'DWord' { if ($entry.value -lt 0) { [int32]$entry.value } else { [uint32]$entry.value } }
|
||||
'QWord' { if ($entry.value -lt 0) { [int64]$entry.value } else { [uint64]$entry.value } }
|
||||
'Binary' { [byte[]]@($entry.value) }
|
||||
'MultiString' { [string[]]@($entry.value) }
|
||||
default { [string]$entry.value }
|
||||
|
|
|
|||
|
|
@ -50,3 +50,42 @@ Describe 'Application configuration adapters' {
|
|||
{ Read-RegistryDeclaration -Path $invalid } | Should -Throw '*Unsafe registry subpath*'
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Registry integer deployment' {
|
||||
It 'accepts signed exported DWORD and QWORD values without changing their bits' {
|
||||
InModuleScope Adapters {
|
||||
Mock New-Item {}
|
||||
Mock New-ItemProperty {}
|
||||
$declaration = [pscustomobject]@{ values = @(
|
||||
[pscustomobject]@{ path = ''; name = 'Dword'; type = 'DWord'; value = -1 },
|
||||
[pscustomobject]@{ path = ''; name = 'Qword'; type = 'QWord'; value = [long]::MinValue }
|
||||
) }
|
||||
Set-RegistryDeclaration -Root 'TestRoot' -Declaration $declaration
|
||||
Should -Invoke New-ItemProperty -Times 1 -ParameterFilter { $Name -eq 'Dword' -and $Value -eq -1 -and $Value -is [int32] }
|
||||
Should -Invoke New-ItemProperty -Times 1 -ParameterFilter { $Name -eq 'Qword' -and $Value -eq [long]::MinValue -and $Value -is [int64] }
|
||||
}
|
||||
}
|
||||
|
||||
It 'deploys every checked-in MPC-HC value through mocked registry operations' {
|
||||
$declaration = Read-RegistryDeclaration -Path "$PSScriptRoot/../configs/mpc-hc/settings.json"
|
||||
InModuleScope Adapters -Parameters @{ Declaration = $declaration; Root = $TestDrive } {
|
||||
param($Declaration, $Root)
|
||||
Mock New-Item {}
|
||||
Mock New-ItemProperty {}
|
||||
{ Set-RegistryDeclaration -Root $Root -Declaration $Declaration } | Should -Not -Throw
|
||||
Should -Invoke New-ItemProperty -Times $Declaration.values.Count -Exactly
|
||||
}
|
||||
}
|
||||
|
||||
It 'rejects negative values outside the DWORD range' {
|
||||
InModuleScope Adapters {
|
||||
Mock New-Item {}
|
||||
Mock New-ItemProperty {}
|
||||
$declaration = [pscustomobject]@{ values = @(
|
||||
[pscustomobject]@{ path = ''; name = 'Invalid'; type = 'DWord'; value = -2147483649 }
|
||||
) }
|
||||
{ Set-RegistryDeclaration -Root 'TestRoot' -Declaration $declaration } | Should -Throw
|
||||
Should -Invoke New-ItemProperty -Times 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue