$ErrorActionPreference = 'Stop' . (Join-Path $PSScriptRoot '..\deps.ps1') $originalManifest = $script:depsManifest $originalDownloadDir = $script:depsDownloadDir $originalInstallDir = $script:depsInstallDir $testRoot = Join-Path $script:depsProjectRoot ('.runtime\bootstrap-test-' + [guid]::NewGuid().ToString('n')) try { $script:depsDownloadDir = Join-Path $testRoot 'downloads' $script:depsInstallDir = Join-Path $testRoot 'deps' $source = Join-Path $testRoot 'source' New-Item -ItemType Directory -Force -Path $source, $script:depsDownloadDir | Out-Null Set-Content -LiteralPath (Join-Path $source 'jacktrip.exe') -Value 'test fixture' $zip = Join-Path $script:depsDownloadDir 'fixture.zip' Compress-Archive -LiteralPath (Join-Path $source 'jacktrip.exe') -DestinationPath $zip $script:depsManifest = [pscustomobject]@{ jacktrip = [pscustomobject]@{ version = 'test' file = 'fixture.zip' url = 'https://invalid.example/fixture.zip' sha256 = (Get-FileHash -LiteralPath $zip -Algorithm SHA256).Hash.ToLowerInvariant() } } $resolved = Install-ManagedJackTrip if (-not (Test-Path -LiteralPath $resolved -PathType Leaf)) { throw 'JackTrip extraction failed' } if (-not $resolved.StartsWith($script:depsInstallDir, [StringComparison]::OrdinalIgnoreCase)) { throw 'JackTrip path escaped dependency directory' } Write-Host 'Bootstrap cache verification and extraction OK' } finally { $script:depsManifest = $originalManifest $script:depsDownloadDir = $originalDownloadDir $script:depsInstallDir = $originalInstallDir $runtimeRoot = [System.IO.Path]::GetFullPath((Join-Path $script:depsProjectRoot '.runtime')).TrimEnd('\') + '\' $testPath = [System.IO.Path]::GetFullPath($testRoot) if (-not $testPath.StartsWith($runtimeRoot, [StringComparison]::OrdinalIgnoreCase)) { throw 'Refusing to remove test files outside .runtime' } if (Test-Path -LiteralPath $testPath) { Remove-Item -LiteralPath $testPath -Recurse -Force } }