12 lines
2.3 KiB
PHP
12 lines
2.3 KiB
PHP
<?php
|
|
ini_set('zend.exception_ignore_args','1');require __DIR__.'/boot-QA.php';
|
|
use Illuminate\Support\Facades\DB;
|
|
$prior=json_decode(file_get_contents(__DIR__.'/PROVA-TRIO-QA.json'),true);$checks=[];
|
|
DB::beginTransaction();DB::statement('SET TRANSACTION READ ONLY');try{
|
|
foreach($prior['QA_dossiers']as$c){$owner=App\Models\User::findOrFail($c['owner_id']);$view=app(App\Services\InvestorPath::class)->view($owner,$c['id']);$ref=$view['content_sources'];if(count($ref)!==1||$ref[0]['resource_id']!==$c['resource_id']||$ref[0]['sha256']!==$c['sha256']||$ref[0]['return_href']!==$c['return_href'])throw new RuntimeException('Recovered reference mismatch');$checks['fresh_recovery_'.$c['slug']]=true;}
|
|
$phpRoot=dirname(__DIR__,2);$env=Dotenv\Dotenv::parse(file_get_contents($phpRoot.'/.env'));$active=new PDO('pgsql:host=127.0.0.1;port=5432;dbname=investemoz',$env['DB_USERNAME'],$env['DB_PASSWORD']??'',[PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION]);$active->exec('BEGIN READ ONLY');try{$sql='select row_to_json(t)::text as v from opportunities t order by row_to_json(t)::text';$original=$active->query($sql)->fetchAll(PDO::FETCH_COLUMN);$qa=array_column(DB::select($sql),'v');if($original!==$qa)throw new RuntimeException('Editorial created or changed opportunities');$checks['opportunity_rows_identical_to_active_source']=true;}finally{$active->exec('ROLLBACK');}
|
|
foreach(json_decode(file_get_contents(__DIR__.'/FONTES-E-HASHES.json'),true)['sources']as$s)if(hash_file('sha256',$phpRoot.'/'.$s['path'])!==$s['before_sha256'])throw new RuntimeException('Active source changed');$checks['active_sources_unchanged']=true;
|
|
$service=DB::table('desk_service_versions')->where('code','project-preparation')->where('status','published')->orderByDesc('version')->first(['id','code','version']);if(!$service)throw new RuntimeException('Support unresolved');$checks['destination_published_support_resolved_by_code']=true;
|
|
$v=['at'=>gmdate('c'),'target'=>$target,'SQL_read_only'=>true,'result'=>'passed','checks'=>$checks,'support'=>$service,'authentication_scope'=>'Fresh PHP process, not a new browser login/MFA acceptance','active_writes'=>0];file_put_contents(__DIR__.'/RECUPERACAO-PROCESSO-NOVO-QA.json',json_encode($v,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR));echo json_encode($v);
|
|
}finally{DB::rollBack();}
|