remove version pinning except for latest supported version for Windows 10
removed checksums, rely only on direct MS download completeness
This commit is contained in:
@@ -36,6 +36,7 @@ try {
|
||||
}
|
||||
# Exercise the real bounded retry loops without delaying offline tests.
|
||||
function Start-Sleep { param([int]$Seconds) $script:testSleeps += $Seconds }
|
||||
function Get-FileHash { throw 'Office deployment must not scan file checksums.' }
|
||||
$script:testSleeps = @()
|
||||
& {
|
||||
$script:probeCalls=0; $script:testSleeps=@()
|
||||
@@ -221,7 +222,29 @@ try {
|
||||
Assert-OfficeTest ($null -ne $roundTrip.SelectSingleNode('/Configuration/RemoveMSI') -and $null -ne $roundTrip.SelectSingleNode('/Configuration/Add')) 'Legacy MSI removal must run with the replacement installation.'
|
||||
Assert-OfficeTest ($roundTrip.Configuration.Add.OfficeClientEdition -eq '32') '32-bit selection ignored.'
|
||||
Assert-OfficeTest ($roundTrip.SelectSingleNode('//Property[@Name="SharedComputerLicensing"]').Value -eq '1') 'Shared activation lost.'
|
||||
Assert-OfficeTest ($roundTrip.Configuration.Add.Version -eq '16.0.12345.67890') 'Downloaded version must be pinned.'
|
||||
Assert-OfficeTest ($roundTrip.Configuration.Add.Version -eq '16.0.12345.67890') 'An explicitly selected Windows 10 build must be retained.'
|
||||
$latestXml = New-OfficeConfiguration $options 'C:\Office'
|
||||
Assert-OfficeTest (!$latestXml.Configuration.Add.HasAttribute('Version')) 'Ordinary deployments must let ODT select the latest version.'
|
||||
Assert-OfficeTest (!$roundTrip.Configuration.Updates.HasAttribute('TargetVersion') -and $roundTrip.Configuration.Updates.Enabled -eq 'TRUE') 'Installation selection must not freeze future Office updates.'
|
||||
Assert-OfficeTest ((Get-OfficeFeatureRelease -Build 19045 -ProductType 1) -eq '2608') 'Windows 10 must select feature release 2608.'
|
||||
Assert-OfficeTest ((Get-OfficeFeatureRelease -Build 22631 -ProductType 1) -eq '') 'Windows 11 must remain unpinned.'
|
||||
Assert-OfficeTest ((Get-OfficeFeatureRelease -Build 20348 -ProductType 3) -eq '') 'Windows Server must not be mistaken for Windows 10.'
|
||||
$releaseHistory = @'
|
||||
<a href="current-channel#version-2608-september-18">Version 2608 (Build 20326.20158)</a>
|
||||
<a href="current-channel#version-2608-september-08">Version 2608 (Build 20326.20144)</a>
|
||||
<a href="monthly-enterprise-channel#version-2608-october-13">Version 2608 (Build 20326.20232)</a>
|
||||
<a href="semi-annual-enterprise-channel#version-2608-october-13">Version 2608 (Build 20326.20230)</a>
|
||||
<a href="current-channel#version-2610-october-21">Version 2610 (Build 20527.20088)</a>
|
||||
<a href="current-channel-preview#version-2608-fixture">Version 2608 (Build 20326.99999)</a>
|
||||
'@
|
||||
foreach ($channel in @('Current','MonthlyEnterprise','SemiAnnual')) {
|
||||
$expectedBuild = @{Current='16.0.20326.20158'; MonthlyEnterprise='16.0.20326.20232'; SemiAnnual='16.0.20326.20230'}[$channel]
|
||||
Assert-OfficeTest ((Get-OfficeBuildFromHistory $releaseHistory $channel '2608') -eq $expectedBuild) "Wrong Windows 10 build selected for $channel."
|
||||
}
|
||||
$numericHistory = '<a href="https://learn.microsoft.com/en-us/officeupdates/current-channel#version-2608-fixture">Version 2608 (Build 20326.9)</a><a href=''current-channel#version-2608-fixture''><span>Version 2608 (Build 20326.10)</span></a>'
|
||||
Assert-OfficeTest ((Get-OfficeBuildFromHistory $numericHistory Current '2608') -eq '16.0.20326.10') 'Build sorting must be numeric and tolerate HTML formatting.'
|
||||
Assert-OfficeThrows { Get-OfficeBuildFromHistory '<html>Changed Microsoft page</html>' Current '2608' } 'did not identify.*Existing Office has not been removed'
|
||||
Assert-OfficeThrows { Get-OfficeBuildFromHistory $releaseHistory Invalid '2608' } 'Invalid.*selection'
|
||||
foreach ($app in @('OneDrive','Groove','Teams','OutlookForWindows')) { Assert-OfficeTest ($app -in $roundTrip.Configuration.Add.Product.ExcludeApp.ID) "ODT must leave $app to the explicit companion installation stage." }
|
||||
Assert-OfficeCompanionPlatform -Build 22631 -ProductType 1 -Revision 0 -EditionId Professional
|
||||
Assert-OfficeCompanionPlatform -Build 20348 -ProductType 3 -Revision 2402 -EditionId ServerStandard
|
||||
@@ -253,6 +276,9 @@ try {
|
||||
if ([IO.Path]::GetFileName($Path) -eq 'odt-download-page.html') {
|
||||
Assert-OfficeTest ($TimeoutSeconds -eq (Get-OfficeDeploymentDefinitions).OdtPageTimeoutSeconds) 'ODT page must use the retried downloader with its configured timeout.'
|
||||
[IO.File]::WriteAllText($Path, 'https://download.microsoft.com/test/officedeploymenttool_test.exe')
|
||||
} elseif ([IO.Path]::GetFileName($Path) -eq 'office-release-history.html') {
|
||||
Assert-OfficeTest ($Uri -eq (Get-OfficeDeploymentDefinitions).OfficeReleaseHistory) 'Windows 10 release lookup must use Microsoft history.'
|
||||
[IO.File]::WriteAllText($Path, $script:mediaHistory)
|
||||
} elseif ([IO.Path]::GetFileName($Path) -eq 'Office-UserCleanup.ps1') {
|
||||
[IO.File]::WriteAllText($Path, '# ' + (Get-OfficeDeploymentDefinitions).HelperVersion)
|
||||
} else {
|
||||
@@ -272,21 +298,44 @@ try {
|
||||
} elseif ([IO.Path]::GetFileName($FilePath) -eq 'setup.exe' -and $Arguments -like '/download *') {
|
||||
$script:mediaDownloadCalls++
|
||||
if ($script:mediaDownloadCalls -eq 1) { return 12029 }
|
||||
$payload = Join-Path $mediaWorkspace 'ODT\Office\Data\16.0.12345.67890'
|
||||
$downloadXml = [xml](Get-Content -LiteralPath (Join-Path $mediaWorkspace 'install.xml') -Raw)
|
||||
Assert-OfficeTest ($downloadXml.Configuration.Add.GetAttribute('Version') -eq $options.TargetOfficeVersion) 'The OS-specific build must be selected before downloading.'
|
||||
$payload = Join-Path $mediaWorkspace ('ODT\Office\Data\' + $script:mediaPayloadVersion)
|
||||
$null = [IO.Directory]::CreateDirectory($payload)
|
||||
foreach ($name in @('stream.x64.x-none.dat', 'stream.x64.en-us.dat')) { [IO.File]::WriteAllText((Join-Path $payload $name), 'Inert Office payload.') }
|
||||
} else { throw "Unexpected executable requested during staging: $FilePath $Arguments" }
|
||||
return 0
|
||||
}
|
||||
$options = Get-OfficeDeploymentOptions @{OfficeSubscription='Microsoft/Office 365 E3/E5 (no Teams)'; OfficeArchitecture='64'}
|
||||
$script:mediaPayloadVersion = '16.0.12345.67890'
|
||||
$media = Initialize-OfficeMedia $options $mediaWorkspace
|
||||
Assert-OfficeTest ($media.Setup -in $script:mediaSignatures) 'Extracted ODT must still pass signature checks.'
|
||||
Assert-OfficeTest ($media.Version -eq '16.0.12345.67890' -and $media.Companions.Count -eq 3 -and !$media.Companions.ContainsKey('Teams')) 'Media staging lost its build or no-Teams selection.'
|
||||
Assert-OfficeTest (([xml](Get-Content -LiteralPath $media.Config -Raw)).Configuration.Add.Version -eq $media.Version) 'Staged configuration must pin the downloaded build.'
|
||||
Assert-OfficeTest (!([xml](Get-Content -LiteralPath $media.Config -Raw)).Configuration.Add.HasAttribute('Version')) 'Staging must not pin ordinary installations to the downloaded build.'
|
||||
Assert-OfficeTest (($script:mediaProcesses -join ',') -eq 'odt.exe,setup.exe,setup.exe') 'Staging must only extract ODT and download Office, with no removal or installation.'
|
||||
$removal = [xml](Get-Content -LiteralPath $media.RemovalConfig -Raw)
|
||||
Assert-OfficeTest ($removal.Configuration.Remove.All -eq 'TRUE' -and $removal.Configuration.Display.Level -eq 'None') 'Staging must save the silent removal configuration.'
|
||||
Assert-OfficeTest (!$media.Scrubber -and !($script:mediaSignatures -match 'GetHelp|SaRA')) 'Unattended deployments must not stage an interactive scrubber.'
|
||||
foreach ($mode in @('win10', 'incompatible-download', 'history-unavailable')) {
|
||||
$mediaWorkspace = Join-Path $testRoot $mode; $null = [IO.Directory]::CreateDirectory($mediaWorkspace)
|
||||
$options = Get-OfficeDeploymentOptions @{OfficeSubscription='Microsoft 365 Business Standard'; OfficeArchitecture='64'}
|
||||
$options.OfficeFeatureRelease = Get-OfficeFeatureRelease -Build 19045 -ProductType 1
|
||||
$script:mediaProcesses = @(); $script:mediaDownloadCalls = 0
|
||||
$script:mediaHistory = $releaseHistory
|
||||
$script:mediaPayloadVersion = '16.0.20326.20158'
|
||||
if ($mode -eq 'history-unavailable') {
|
||||
$script:mediaHistory = '<html>No eligible build</html>'
|
||||
Assert-OfficeThrows { Initialize-OfficeMedia $options $mediaWorkspace } 'did not identify'
|
||||
Assert-OfficeTest (!$script:mediaProcesses.Count) 'Missing Windows 10 release data must stop before launching installers.'
|
||||
} elseif ($mode -eq 'incompatible-download') {
|
||||
$script:mediaPayloadVersion = '16.0.20527.20088'
|
||||
Assert-OfficeThrows { Initialize-OfficeMedia $options $mediaWorkspace } 'Downloaded Office build does not match the Windows 10 target'
|
||||
} else {
|
||||
$media = Initialize-OfficeMedia $options $mediaWorkspace
|
||||
Assert-OfficeTest ($media.Version -eq '16.0.20326.20158' -and $options.TargetOfficeVersion -eq $media.Version) 'Windows 10 must stage its compatible build.'
|
||||
Assert-OfficeTest (([xml](Get-Content -LiteralPath $media.Config -Raw)).Configuration.Add.Version -eq $media.Version) 'Windows 10 installation must retain the compatible target.'
|
||||
}
|
||||
}
|
||||
}
|
||||
& {
|
||||
$script:staged = @(); $script:verified = @()
|
||||
@@ -627,6 +676,15 @@ try {
|
||||
Assert-OfficeThrows { Install-OfficeMedia $options $media $testRoot } 'did not match'
|
||||
$script:installed.Platform='x64'; $script:installed.VersionToReport='16.0.0.1'
|
||||
Assert-OfficeThrows { Install-OfficeMedia $options $media $testRoot } 'did not match'
|
||||
$script:installed.VersionToReport='16.0.2.3'
|
||||
Assert-OfficeTest ((Install-OfficeMedia $options $media $testRoot) -eq 0 -and $media.Version -eq '16.0.2.3') 'A newer unpinned build must pass and report the actual installed version.'
|
||||
$options.TargetOfficeVersion='16.0.1.2'
|
||||
Assert-OfficeThrows { Install-OfficeMedia $options $media $testRoot } 'did not match'
|
||||
$script:installed.VersionToReport='16.0.1.2'
|
||||
Assert-OfficeTest ((Install-OfficeMedia $options $media $testRoot) -eq 0 -and $media.Version -eq '16.0.1.2') 'Windows 10 must verify its explicitly selected build.'
|
||||
$options.TargetOfficeVersion=''
|
||||
$script:installed.VersionToReport='invalid'
|
||||
Assert-OfficeThrows { Install-OfficeMedia $options $media $testRoot } 'did not match'
|
||||
$script:installCode=42
|
||||
Assert-OfficeThrows { Install-OfficeMedia $options $media $testRoot } 'installation failed'
|
||||
$script:installCode=0; $script:installed.VersionToReport='16.0.1.2'; $script:officeChecks=0
|
||||
@@ -695,7 +753,7 @@ try {
|
||||
Assert-OfficeTest ((Get-Content -LiteralPath $Global:LogFile -Raw) -match 'Error: User cleanup task registration failed for unmapped \(C:\\Users\\defaultuser100000\)') 'Registration failures must reach the Tools diagnostic log.'
|
||||
}
|
||||
|
||||
# Real temporary files for cache reuse/tampering; no installer or network may run.
|
||||
# Real temporary files for cache reuse/completeness; no installer or network may run.
|
||||
& {
|
||||
$cacheRoot = Join-Path $testRoot 'cache-tests'; $null = [IO.Directory]::CreateDirectory($cacheRoot)
|
||||
$source = Join-Path $cacheRoot ('a' * 32); $null = [IO.Directory]::CreateDirectory($source)
|
||||
@@ -710,17 +768,27 @@ try {
|
||||
function Invoke-OfficeProcess { throw 'A cached deployment must not redownload Office.' }
|
||||
$manifestPath = Join-Path $source 'media-cache.json'
|
||||
$originalManifest = Get-Content -LiteralPath $manifestPath -Raw
|
||||
Assert-OfficeTest (!($originalManifest | ConvertFrom-Json).Files[0].PSObject.Properties['Hash']) 'Cache manifests must not store file checksums.'
|
||||
$different = Get-OfficeDeploymentOptions @{OfficeSubscription='Microsoft/Office 365 E3/E5'; OfficeArchitecture='64'}
|
||||
Assert-OfficeTest (!(Restore-OfficeMediaCache $different $target)) 'Teams selection mismatch reused the wrong cache.'
|
||||
$different = Get-OfficeDeploymentOptions @{OfficeSubscription='Microsoft/Office 365 E3/E5 (no Teams)'; OfficeArchitecture='64'; UpdateChannel='MonthlyEnterprise'}
|
||||
Assert-OfficeTest (!(Restore-OfficeMediaCache $different $target)) 'Channel mismatch reused the wrong cache.'
|
||||
$different = Get-OfficeDeploymentOptions @{OfficeSubscription='Microsoft/Office 365 E3/E5 (no Teams)'; OfficeArchitecture='64'}
|
||||
$different.TargetOfficeVersion='16.0.20326.20158'
|
||||
Assert-OfficeTest (!(Restore-OfficeMediaCache $different $target)) 'A Windows 10 target reused incompatible unpinned media.'
|
||||
$manifest = $originalManifest | ConvertFrom-Json; $manifest.Key = Get-OfficeMediaCacheKey $different
|
||||
$manifest | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath $manifestPath
|
||||
Assert-OfficeTest (!(Restore-OfficeMediaCache $different $target)) 'A matching cache key hid an incompatible Windows 10 payload version.'
|
||||
$manifest = $originalManifest | ConvertFrom-Json; $manifest.Schema = 1
|
||||
$manifest | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath $manifestPath
|
||||
Assert-OfficeTest (!(Restore-OfficeMediaCache $options $target)) 'Old cache manifests must be refreshed under the new version-selection contract.'
|
||||
$manifest = $originalManifest | ConvertFrom-Json; $manifest.CreatedUtc = [DateTime]::UtcNow.AddDays(-8).ToString('o')
|
||||
$manifest | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath $manifestPath
|
||||
Assert-OfficeTest (!(Restore-OfficeMediaCache $options $target)) 'Expired cache was reused.'
|
||||
Set-Content -LiteralPath $manifestPath -Value $originalManifest
|
||||
$stream = Join-Path $source 'ODT\Office\Data\16.0.12345.67890\stream.x64.x-none.dat'
|
||||
$originalBytes = [IO.File]::ReadAllBytes($stream); $changedBytes = $originalBytes.Clone(); $changedBytes[0] = $changedBytes[0] -bxor 1; [IO.File]::WriteAllBytes($stream, $changedBytes)
|
||||
Assert-OfficeTest (!(Restore-OfficeMediaCache $options $target)) 'Same-size payload corruption passed hash verification.'
|
||||
$originalBytes = [IO.File]::ReadAllBytes($stream); [IO.File]::WriteAllText($stream, '')
|
||||
Assert-OfficeTest (!(Restore-OfficeMediaCache $options $target)) 'Truncated cached media passed the basic size check.'
|
||||
[IO.File]::WriteAllBytes($stream, $originalBytes)
|
||||
$extra = Join-Path $source 'ODT\unexpected.dll'; Set-Content -LiteralPath $extra -Value 'unexpected dependency'
|
||||
Assert-OfficeTest (!(Restore-OfficeMediaCache $options $target)) 'Unrecorded executable dependencies passed cache verification.'
|
||||
@@ -732,14 +800,35 @@ try {
|
||||
$script:rejectCacheSignature = $true
|
||||
Assert-OfficeTest (!(Restore-OfficeMediaCache $options $target)) 'Invalid Microsoft signature was reused.'
|
||||
$script:rejectCacheSignature = $false
|
||||
# Same-size contents are deliberately not hashed; ODT services the payload.
|
||||
$changedBytes = $originalBytes.Clone(); $changedBytes[0] = $changedBytes[0] -bxor 1; [IO.File]::WriteAllBytes($stream, $changedBytes)
|
||||
$media = Initialize-OfficeMedia $options $target
|
||||
Assert-OfficeTest ($media.CachedMediaReused -and $media.Version -eq '16.0.12345.67890' -and $script:helperDownloads -eq 1) 'Deployment did not reuse the validated media and refresh the helper.'
|
||||
Assert-OfficeTest (!(Test-Path -LiteralPath (Join-Path $source 'ODT')) -and (Test-Path -LiteralPath $media.Setup)) 'Cache transfer duplicated large files or lost setup.'
|
||||
$config = [xml](Get-Content -LiteralPath $media.Config -Raw)
|
||||
Assert-OfficeTest ($config.Configuration.AppSettings.Setup.Value -eq 'New Company' -and $config.Configuration.Add.SourcePath -eq (Join-Path $target 'ODT')) 'Reused media retained stale company/configuration paths.'
|
||||
Assert-OfficeTest (!$config.Configuration.Add.HasAttribute('Version')) 'Reusing ordinary media must not pin the installation version.'
|
||||
Assert-OfficeTest ((Get-Content -LiteralPath (Join-Path $target 'media-cache.json') -Raw | ConvertFrom-Json).CreatedUtc -eq ($originalManifest | ConvertFrom-Json).CreatedUtc) 'Reuse extended cache expiry.'
|
||||
Assert-OfficeThrows { Remove-OfficeManagedItem $cacheRoot $testRoot } 'outside the Office deployment root'
|
||||
Assert-OfficeThrows { Remove-OfficeManagedItem $cacheRoot $cacheRoot } 'outside the Office deployment root'
|
||||
|
||||
# Windows 10 refreshes only the small release history and helper on a compatible hit.
|
||||
$win10Source = Join-Path $cacheRoot ('c' * 32); $null = [IO.Directory]::CreateDirectory($win10Source)
|
||||
foreach ($file in Get-ChildItem -LiteralPath (Join-Path $testRoot 'win10')) { Copy-Item -LiteralPath $file.FullName -Destination $win10Source -Recurse }
|
||||
$win10Target = Join-Path $cacheRoot ('d' * 32); $null = [IO.Directory]::CreateDirectory($win10Target)
|
||||
$options = Get-OfficeDeploymentOptions @{OfficeSubscription='Microsoft 365 Business Standard'; OfficeArchitecture='64'}
|
||||
$options.OfficeFeatureRelease = Get-OfficeFeatureRelease -Build 19045 -ProductType 1
|
||||
function Save-OfficeDownload {
|
||||
param($Uri,$Path)
|
||||
switch ([IO.Path]::GetFileName($Path)) {
|
||||
'office-release-history.html' { [IO.File]::WriteAllText($Path, $releaseHistory) }
|
||||
'Office-UserCleanup.ps1' { [IO.File]::WriteAllText($Path, '# ' + (Get-OfficeDeploymentDefinitions).HelperVersion) }
|
||||
default { throw 'Unexpected installer download on Windows 10 cache hit' }
|
||||
}
|
||||
}
|
||||
$media = Initialize-OfficeMedia $options $win10Target
|
||||
Assert-OfficeTest ($media.CachedMediaReused -and $media.Version -eq '16.0.20326.20158') 'Windows 10 did not reuse compatible validated media.'
|
||||
Assert-OfficeTest (([xml](Get-Content -LiteralPath $media.Config -Raw)).Configuration.Add.Version -eq $media.Version) 'Reused Windows 10 media lost its compatible version constraint.'
|
||||
}
|
||||
# Cleanup runs synchronously on success. Downloads are temporary; pending-user
|
||||
# helpers have a separate durable folder and are never part of the media cache.
|
||||
|
||||
Reference in New Issue
Block a user