Prepare ms-private 0.0.1 release candidate

This commit is contained in:
0x000 committed 2026-09-22 21:21:41 -04:00
1 parent 7aacc0b63f
commit a515538438
75 files changed
+3957 -3484

No files matched your search

+29 -10
View File
@@ -13,7 +13,8 @@ function New-Harness {
Read = {
param($policy)
if ($state.ReadFail) { throw 'Injected read error' }
$key=$policy.Path+'|'+$policy.Name
$hive=if($policy.PSObject.Properties['Hive']){[string]$policy.Hive}else{'LocalMachine'}
$key=$hive+'|'+$policy.Path+'|'+$policy.Name
if ($state.Values.ContainsKey($key)) {
$v=$state.Values[$key]
return [pscustomobject]@{ Exists=$true; Kind=$v.Kind; Value=$v.Value }
@@ -25,7 +26,8 @@ function New-Harness {
$state.Writes++
$fail=$state.FailName -eq $policy.Name
if ($fail -and -not $state.FailAfterWrite) { $state.FailName=''; throw 'Injected write error' }
$key=$policy.Path+'|'+$policy.Name
$hive=if($policy.PSObject.Properties['Hive']){[string]$policy.Hive}else{'LocalMachine'}
$key=$hive+'|'+$policy.Path+'|'+$policy.Name
if ($value.Exists) { $state.Values[$key]=[pscustomobject]@{ Kind=$value.Kind; Value=$value.Value } }
else { $state.Values.Remove($key) }
if ($fail) { $state.FailName=''; throw 'Injected error after write' }
@@ -60,6 +62,13 @@ Run-Test 'Edition-aware diagnostic level' {
$h.Context.Edition='Enterprise'
Assert-True ((New-Plan $h @('diagnostics'))[0].Desired -eq 0) 'Enterprise should use supported minimum.'
}
Run-Test 'User-scoped and edition-scoped policies are planned honestly' {
$h=New-Harness
Assert-True ((New-Plan $h @('tailored-experiences'))[0].Desired -eq 1) 'Current-user tailored-experience policy missing.'
Assert-True (@(New-Plan $h @('windows-spotlight')).Count -eq 0) 'Pro must not claim the Enterprise-only Spotlight policy.'
$h.Context.Edition='Enterprise'
Assert-True ((New-Plan $h @('windows-spotlight'))[0].Desired -eq 1) 'Enterprise Spotlight policy was not selected.'
}
Run-Test 'Update choices are explicit and preserve update services' {
$h=New-Harness
$keep=@(Get-WindPlan -Context $h.Context -Store $h.Store)
@@ -74,13 +83,13 @@ Run-Test 'Unknown ID fails instead of silently ignoring a typo' {
}
Run-Test 'Non-DWORD pre-existing value is never overwritten' {
$h=New-Harness; $p=Get-WindCatalog | Where-Object Id -EQ 'advertising-id'
$h.State.Values[$p.Path+'|'+$p.Name]=[pscustomobject]@{ Kind='String'; Value='custom' }
$h.State.Values['LocalMachine|'+$p.Path+'|'+$p.Name]=[pscustomobject]@{ Kind='String'; Value='custom' }
Assert-Throws { Apply-Test $h (New-Plan $h) }
Assert-True ($h.State.Writes -eq 0) 'Conflicting type was overwritten.'
}
Run-Test 'Microphone per-app overrides block misleading default-deny claim' {
$h=New-Harness; $p=Get-WindCatalog | Where-Object Id -EQ 'microphone-apps'
$h.State.Values[$p.Path+'|LetAppsAccessMicrophone_ForceAllowTheseApps']=[pscustomobject]@{ Kind='MultiString'; Value=@('example.app') }
$h.State.Values['LocalMachine|'+$p.Path+'|LetAppsAccessMicrophone_ForceAllowTheseApps']=[pscustomobject]@{ Kind='MultiString'; Value=@('example.app') }
Assert-True ((New-Plan $h @('microphone-apps'))[0].Status -eq 'Conflict') 'Exception was missed.'
}
Run-Test 'Unreadable registry is a read error, not missing or configured' {
@@ -89,12 +98,12 @@ Run-Test 'Unreadable registry is a read error, not missing or configured' {
}
Run-Test 'Apply and restore preserve absence and arbitrary original DWORD' {
$h=New-Harness; $p=Get-WindCatalog | Where-Object Id -EQ 'advertising-id'
$h.State.Values[$p.Path+'|'+$p.Name]=[pscustomobject]@{ Kind='DWord'; Value=7 }
$h.State.Values['LocalMachine|'+$p.Path+'|'+$p.Name]=[pscustomobject]@{ Kind='DWord'; Value=7 }
$j=Apply-Test $h (New-Plan $h)
Assert-True ($j.Status -eq 'Applied' -and $h.State.Values.Count -eq 2) 'Apply incomplete.'
$r=Restore-Test $h ($j | ConvertTo-Json -Depth 12 | ConvertFrom-Json)
Assert-True ($r.Status -eq 'Restored' -and $h.State.Values.Count -eq 1) 'Restore did not preserve absence.'
Assert-True ($h.State.Values[$p.Path+'|'+$p.Name].Value -eq 7) 'Original value lost.'
Assert-True ($h.State.Values['LocalMachine|'+$p.Path+'|'+$p.Name].Value -eq 7) 'Original value lost.'
}
Run-Test 'Reapplying configured policies makes zero registry writes' {
$h=New-Harness; Apply-Test $h (New-Plan $h) | Out-Null; $count=$h.State.Writes
@@ -119,10 +128,10 @@ Run-Test 'Failure after mutation also rolls back the current setting' {
Run-Test 'External edits cause restore conflict and are preserved' {
$h=New-Harness; $j=Apply-Test $h (New-Plan $h)
$p=Get-WindCatalog | Where-Object Id -EQ 'advertising-id'
$h.State.Values[$p.Path+'|'+$p.Name].Value=9
$h.State.Values['LocalMachine|'+$p.Path+'|'+$p.Name].Value=9
$r=Restore-Test $h $j
Assert-True ($r.Status -eq 'RestoreIncomplete') 'Conflict not reported.'
Assert-True ($h.State.Values[$p.Path+'|'+$p.Name].Value -eq 9) 'External edit overwritten.'
Assert-True ($h.State.Values['LocalMachine|'+$p.Path+'|'+$p.Name].Value -eq 9) 'External edit overwritten.'
}
Run-Test 'Crash with Writing journal status remains recoverable' {
$h=New-Harness; $j=Apply-Test $h (New-Plan $h); $j.Entries[0].Status='Writing'
@@ -153,9 +162,9 @@ Run-Test 'Journal rejects wrong installation and invalid target' {
}
Run-Test 'State change between planning and apply is not overwritten' {
$h=New-Harness; $plan=New-Plan $h; $p=Get-WindCatalog | Where-Object Id -EQ 'advertising-id'
$h.State.Values[$p.Path+'|'+$p.Name]=[pscustomobject]@{ Kind='DWord'; Value=88 }
$h.State.Values['LocalMachine|'+$p.Path+'|'+$p.Name]=[pscustomobject]@{ Kind='DWord'; Value=88 }
Assert-Throws { Apply-Test $h $plan }
Assert-True ($h.State.Writes -eq 0 -and $h.State.Values[$p.Path+'|'+$p.Name].Value -eq 88) 'Stale plan wrote registry.'
Assert-True ($h.State.Writes -eq 0 -and $h.State.Values['LocalMachine|'+$p.Path+'|'+$p.Name].Value -eq 88) 'Stale plan wrote registry.'
}
Run-Test 'Journal failure after a successful write triggers recovery' {
$h=New-Harness; $h.State.FailSaveAt=3
@@ -184,4 +193,14 @@ Run-Test 'Durable journal creation and replacement round-trip' {
}
}
Run-Test 'Switching Strict to Standard releases strict-only restrictions' {
$h=New-Harness
$strict=@(Get-WindPlan -Context $h.Context -Store $h.Store -Profile Strict)
Apply-Test $h $strict | Out-Null
$standard=@(Get-WindPlan -Context $h.Context -Store $h.Store -Profile Standard)
Assert-True (($standard | Where-Object Id -eq 'clipboard-history').Desired -eq 1) 'Standard left history disabled.'
Assert-True (($standard | Where-Object Id -eq 'delivery-optimization').Desired -eq 0) 'Standard retained strict DO mode.'
Apply-Test $h $standard | Out-Null
Assert-True (@(Get-WindPlan -Context $h.Context -Store $h.Store -Profile Standard | Where-Object Status -ne 'Configured').Count -eq 0) 'Mode change incomplete.'
}
Write-Output "$script:passed tests passed. No Windows policy settings were modified."