62 lines
4.4 KiB
PowerShell
62 lines
4.4 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
$taskRoot = Split-Path -Parent $PSScriptRoot
|
|
$auditRoot = Join-Path $taskRoot 'storage/app/private/investmoz-v2/portal-audit'
|
|
$plan = Get-Content -LiteralPath (Join-Path $auditRoot 'internal-designation-plan.json') -Encoding UTF8 -Raw | ConvertFrom-Json
|
|
$qaRoot = [IO.Path]::GetFullPath($plan.source)
|
|
$expectedRoot = [IO.Path]::GetFullPath((Join-Path $auditRoot 'onboarding-qa-internal-20261011_191450'))
|
|
if ($qaRoot -ne $expectedRoot -or $plan.target.port -ne 55441 -or $plan.target.database -ne 'onboarding_internal_20261011_191450_test') { throw 'Unexpected QA source/database.' }
|
|
$listener = Get-NetTCPConnection -LocalPort 18118 -State Listen -ErrorAction SilentlyContinue
|
|
if ($listener) { throw 'QA port already occupied; no process was stopped.' }
|
|
$manifestPath = Join-Path $taskRoot 'outputs/investmoz-internal-designation-20261011/manifesto.json'
|
|
$manifest = Get-Content -LiteralPath $manifestPath -Encoding UTF8 -Raw | ConvertFrom-Json
|
|
foreach ($entry in $manifest.files) {
|
|
$candidateFile = Join-Path $qaRoot $entry.path
|
|
if ((Get-FileHash -LiteralPath $candidateFile -Algorithm SHA256).Hash.ToLowerInvariant() -ne $entry.after_sha256) { throw ('Candidate differs: '+$entry.path) }
|
|
}
|
|
$php = 'C:/laragon/bin/php/php-8.5.11-Win32-vs17-x64/php.exe'
|
|
$fixture = Join-Path $qaRoot 'tools/internal-fixture.php'
|
|
$beforeRaw = & $php $fixture verify
|
|
if ($LASTEXITCODE -ne 0) { throw 'QA isolation verification failed.' }
|
|
$before = $beforeRaw | ConvertFrom-Json
|
|
if ($before.port -ne 55441 -or $before.database -ne $plan.target.database) { throw 'Effective database refused.' }
|
|
$envPath = Join-Path $qaRoot '.env'
|
|
$envText = [IO.File]::ReadAllText($envPath)
|
|
$privateSnapshot = Join-Path $qaRoot 'storage/app/private/owner-inspection-environment-before.env'
|
|
if (Test-Path -LiteralPath $privateSnapshot) { throw 'Prior QA inspection snapshot exists; preserve it.' }
|
|
[IO.File]::WriteAllText($privateSnapshot,$envText,[Text.UTF8Encoding]::new($false))
|
|
foreach ($flag in @('PORTAL_PROFILE_ACCESS_ENABLED','PORTAL_OPPORTUNITY_DASHBOARD_ACCESS_ENABLED','PORTAL_OPPORTUNITY_SPECIALIZED_DRAFTS_ENABLED')) {
|
|
$from = $flag+'=false'
|
|
if (-not $envText.Contains($from)) { throw ('Expected disabled QA flag: '+$flag) }
|
|
$envText = $envText.Replace($from,$flag+'=true')
|
|
}
|
|
[IO.File]::WriteAllText($envPath,$envText,[Text.UTF8Encoding]::new($false))
|
|
try {
|
|
$afterRaw = & $php $fixture verify
|
|
if ($LASTEXITCODE -ne 0) { throw 'Updated QA isolation check failed.' }
|
|
$after = $afterRaw | ConvertFrom-Json
|
|
if ($after.port -ne 55441 -or $after.database -ne $plan.target.database -or -not $after.operational_enabled -or -not $after.administration_enabled) { throw 'QA state refused.' }
|
|
$server = Start-Process -FilePath $php -ArgumentList @('-S','127.0.0.1:18118','-t',(Join-Path $qaRoot 'public'),(Join-Path $qaRoot 'tools/internal-router.php')) -WorkingDirectory $qaRoot -WindowStyle Hidden -RedirectStandardOutput (Join-Path $qaRoot 'storage/logs/owner-inspection-http.out.log') -RedirectStandardError (Join-Path $qaRoot 'storage/logs/owner-inspection-http.err.log') -PassThru
|
|
$ready = $false
|
|
for ($attempt = 0; $attempt -lt 20; $attempt++) {
|
|
try {
|
|
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:18118/up' -UseBasicParsing -TimeoutSec 2
|
|
if ($response.StatusCode -eq 200) { $ready = $true; break }
|
|
} catch { Start-Sleep -Milliseconds 200 }
|
|
}
|
|
if (-not $ready) { throw 'Own QA server did not become ready.' }
|
|
$proof = [ordered]@{
|
|
at=(Get-Date).ToUniversalTime().ToString('o'); revision='2876cdfa900a'; QA_only=$true
|
|
target='http://127.0.0.1:18118'; database=$after.database; database_port=55441
|
|
qa_source=$qaRoot; own_server_pid=$server.Id; source_writes=0
|
|
synthetic_roles=@('Superutilizador 43','Promotor 45','Validador 46','Publicador 47')
|
|
administration_enabled=$true; only_six_base_operational_demo_enabled=$true
|
|
extra_packages_enabled=$false; existing_proofs_reused=$true; demonstration_not_active=$true
|
|
credentials='Only the preexisting local private synthetic accounts file; no values recorded'
|
|
}
|
|
$proof | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath (Join-Path $taskRoot 'outputs/investmoz-internal-designation-20261011/acesso-demonstrativo-qa.json') -Encoding UTF8
|
|
$proof | ConvertTo-Json -Depth 5
|
|
} catch {
|
|
[IO.File]::WriteAllText($envPath,[IO.File]::ReadAllText($privateSnapshot),[Text.UTF8Encoding]::new($false))
|
|
throw
|
|
}
|