Files
Investidor-V2/outputs/investmoz-parques-L1-QA-20261016/prove-storage.php
T
nala cef6e201c7
tests / ci (push) Canceled after 0s
versao nrgocios 2
2026-10-16 20:11:05 +02:00

19 lines
2.8 KiB
PHP

<?php
require __DIR__.'/boot-QA.php';
use Illuminate\Support\Facades\DB;
use App\Services\InvestmentZoneOperationalDetails;
$fixture=json_decode(file_get_contents(__DIR__.'/FIXTURE-L1.json'),true);$state=json_decode(file_get_contents(__DIR__.'/L1-STATE.json'),true);$zone=App\Models\InvestmentZone::findOrFail($state['zone']);$service=app(InvestmentZoneOperationalDetails::class);
$stored=$zone->getRawOriginal('operational_details');$details=$service->recover($zone);$checks=[];
$checks['organization_count_unchanged']=DB::table('organizations')->count()===$fixture['organization_count'];
$checks['private_fragment_encrypted_at_rest']=!str_contains($stored,'L1-CONTACTO-PESSOAL-PRIVADO')&&!str_contains($stored,'L1-NOTA-PRIVADA')&&!str_contains($stored,'L1-REVISAO-PRIVADA');
$checks['raw_hidden_by_model']=!array_key_exists('operational_details',$zone->toArray());
$snapshot=DB::table('investment_zone_revisions')->where('zone_id',$zone->id)->where('version_no',$zone->version_no)->first();$clear=Illuminate\Support\Facades\Crypt::decryptString($snapshot->snapshot);$payload=json_decode($clear,true);
$checks['published_snapshot_contains_durable_block']=isset($payload['operational_details']['private_ciphertext']) && hash('sha256',$clear)===trim($snapshot->sha256);
$internal=DB::table('organizations')->where('data_classification','internal')->whereNull('deleted_at')->value('id');$bad=$details;$bad['responsibilities'][0]['organization_id']=$internal;
try{$service->pack($bad);$checks['nonpublic_organization_disclosure_refused']=false;}catch(Symfony\Component\HttpKernel\Exception\HttpException $e){$checks['nonpublic_organization_disclosure_refused']=$e->getStatusCode()===422;}
$test=$details['conditions'][0];$test['valid_from']=null;$test['valid_until']='2026-12-31';$merged=$service->merge($zone,$details,['conditions'=>[$test]],$fixture['organization_id']);$checks['unknown_start_date_allowed']=$merged['conditions'][0]['valid_from']===null;
$test['support_document_ids']=[(string)Illuminate\Support\Str::uuid()];try{$service->merge($zone,$details,['conditions'=>[$test]],$fixture['organization_id']);$checks['unrelated_support_refused']=false;}catch(Symfony\Component\HttpKernel\Exception\HttpException $e){$checks['unrelated_support_refused']=$e->getStatusCode()===422;}
$removed=$service->merge($zone,$details,['remove_ids'=>['risks'=>[$details['risks'][0]['id']]]],$fixture['organization_id']);$checks['explicit_removal_only_selected_group']=count($removed['risks'])===0&&$removed['responsibilities']===$details['responsibilities']&&$removed['conditions']===$details['conditions'];
if(in_array(false,$checks,true)){throw new RuntimeException(json_encode($checks));}
file_put_contents(__DIR__.'/STORAGE-QA.json',json_encode(['checks'=>$checks,'target'=>$target,'new_mutations'=>0],JSON_PRETTY_PRINT));echo json_encode($checks);