@@ -15,14 +15,45 @@ $sourcePath = 'C:/laragon/data/sgf-tempo/secrets/payables-demo-compras.json';
|
||||
$source = json_decode(file_get_contents($sourcePath), true, 32, JSON_THROW_ON_ERROR);
|
||||
$expectedSettings = $plan['active_settings_sha256'];
|
||||
$expectedManifest = $plan['frontend']['previous_manifest_sha256'];
|
||||
$frontend = $plan['frontend'];
|
||||
if ($installed) {
|
||||
$activation = json_decode(file_get_contents($root.'/docs/proofs/compras-standalone-pilot-activation.json'), true, 32, JSON_THROW_ON_ERROR);
|
||||
$previous = json_decode(file_get_contents($activation['backup_directory'].'/settings.before.private.json'), true, 32, JSON_THROW_ON_ERROR);
|
||||
if ($activation['state'] !== 'passed' || $source !== [...$previous, ...$plan['proposed_runtime_settings']]) {
|
||||
$component = [];
|
||||
foreach (['inventory-conversion', 'order-cancellation'] as $componentName) {
|
||||
if (! is_file($root.'/docs/proofs/'.$componentName.'-pilot-installation.json')) {
|
||||
continue;
|
||||
}
|
||||
$inventory = json_decode(file_get_contents($root.'/docs/proofs/'.$componentName.'-pilot-installation.json'), true, 32, JSON_THROW_ON_ERROR);
|
||||
$inventoryPlanPath = $root.'/docs/proofs/'.$componentName.'-pilot-proposal.json';
|
||||
$inventoryPlan = json_decode(file_get_contents($inventoryPlanPath), true, 32, JSON_THROW_ON_ERROR);
|
||||
$inventoryApproval = json_decode(file_get_contents($root.'/docs/proofs/'.$componentName.'-pilot-authorization.json'), true, 32, JSON_THROW_ON_ERROR);
|
||||
if ($inventory['state'] !== 'passed' || $inventoryApproval['state'] !== 'approved'
|
||||
|| ! hash_equals($inventoryApproval['proposal_sha256'], hash_file('sha256', $inventoryPlanPath))) {
|
||||
throw new LogicException('ACTIVATION_POSTCHECK_COMPONENT_AUTHORIZATION');
|
||||
}
|
||||
$component = [...$component, ...$inventoryPlan['proposed_settings_only']];
|
||||
}
|
||||
if ($activation['state'] !== 'passed' || $source !== [...$previous, ...$plan['proposed_runtime_settings'], ...$component]) {
|
||||
throw new LogicException('ACTIVATION_POSTCHECK_SETTINGS_DIFFER');
|
||||
}
|
||||
$expectedSettings = hash_file('sha256', $sourcePath);
|
||||
$expectedManifest = $plan['frontend']['manifest_sha256'];
|
||||
$interfacePlanPath = $root.'/docs/proofs/analytics-print-publication-proposal.json';
|
||||
if (is_file($root.'/docs/proofs/analytics-print-publication.json')) {
|
||||
$interfacePlan = json_decode(file_get_contents($interfacePlanPath), true, 512, JSON_THROW_ON_ERROR);
|
||||
$interfaceApproval = json_decode(file_get_contents($root.'/docs/proofs/analytics-print-publication-authorization.json'), true, 32, JSON_THROW_ON_ERROR);
|
||||
$interfaceResult = json_decode(file_get_contents($root.'/docs/proofs/analytics-print-publication.json'), true, 32, JSON_THROW_ON_ERROR);
|
||||
if ($interfaceApproval['state'] !== 'approved' || ($interfaceResult['pilot_state'] ?? $interfaceResult['state']) !== 'passed'
|
||||
|| $interfaceApproval['scope'] !== 'analytics_print_and_attribution_menu_shared_frontend_delta'
|
||||
|| ! hash_equals($interfaceApproval['proposal_sha256'], hash_file('sha256', $interfacePlanPath))
|
||||
|| $interfacePlan['previous_manifest_sha256'] !== $expectedManifest
|
||||
|| $interfaceResult['manifest_sha256'] !== $interfacePlan['manifest_sha256']) {
|
||||
throw new LogicException('ACTIVATION_POSTCHECK_INTERFACE_AUTHORIZATION');
|
||||
}
|
||||
$frontend = $interfacePlan;
|
||||
$expectedManifest = $interfacePlan['manifest_sha256'];
|
||||
}
|
||||
}
|
||||
if (! hash_equals($expectedSettings, hash_file('sha256', $sourcePath))
|
||||
|| $source['APP_ENV'] !== 'payable-testing' || $source['DB_HOST'] !== '127.0.0.1'
|
||||
@@ -32,12 +63,12 @@ if (! hash_equals($expectedSettings, hash_file('sha256', $sourcePath))
|
||||
|| trim($source['PAYABLE_SOURCE_INSTANCE'] ?? '') === '') {
|
||||
throw new LogicException('ACTIVATION_PREFLIGHT_SOURCE_CHANGED');
|
||||
}
|
||||
$assets = $root.'/'.$plan['frontend']['candidate_root'];
|
||||
if (! hash_equals($plan['frontend']['manifest_sha256'], hash_file('sha256', $assets.'/manifest.json'))
|
||||
$assets = $root.'/'.$frontend['candidate_root'];
|
||||
if (! hash_equals($frontend['manifest_sha256'], hash_file('sha256', $assets.'/manifest.json'))
|
||||
|| ! hash_equals($expectedManifest, hash_file('sha256', $root.'/public/build/manifest.json'))) {
|
||||
throw new LogicException('ACTIVATION_PREFLIGHT_MANIFEST_CHANGED');
|
||||
}
|
||||
foreach ($plan['frontend']['files'] as $file => $hash) {
|
||||
foreach ($frontend['files'] as $file => $hash) {
|
||||
if (! str_starts_with($file, 'assets/') || str_contains($file, '..') || ! hash_equals($hash, hash_file('sha256', $assets.'/'.$file))
|
||||
|| (is_file($root.'/public/build/'.$file) && ! hash_equals($hash, hash_file('sha256', $root.'/public/build/'.$file)))) {
|
||||
throw new LogicException('ACTIVATION_PREFLIGHT_ASSET_MISMATCH');
|
||||
@@ -68,7 +99,7 @@ if (! hash_equals($expectedSettings, hash_file('sha256', $sourcePath))) {
|
||||
}
|
||||
$result = ['date' => gmdate('c'), 'state' => 'passed', 'database_enforced_read_only' => true,
|
||||
'all_24_capabilities_start_with_pinned_installed_packages' => true, 'source_instance_preserved' => true,
|
||||
'frontend_assets_verified' => count($plan['frontend']['files']), 'active_settings_changed' => false,
|
||||
'frontend_assets_verified' => count($frontend['files']), 'active_settings_changed' => false,
|
||||
'mode' => $installed ? 'installed_configuration_read_only_postcheck' : 'prospective_read_only_preflight',
|
||||
'assets_published' => $installed, 'new_grants_or_business_commands' => false];
|
||||
file_put_contents($root.'/docs/proofs/'.($installed ? 'compras-standalone-pilot-activation-check.json' : 'compras-standalone-pilot-activation-preflight.json'), json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR).PHP_EOL);
|
||||
|
||||
Reference in New Issue
Block a user