13 lines
2.1 KiB
PHP
13 lines
2.1 KiB
PHP
<?php
|
|
require __DIR__.'/boot-QA.php';
|
|
use Illuminate\Support\Facades\DB;use Illuminate\Support\Facades\Crypt;use Illuminate\Support\Str;
|
|
$old='025cce5b-73c1-43a3-b969-dc6e592bc28d';$zone='0ae14c9a-1adb-4ee7-8094-d5d54d4e75f1';$d=DB::table('documents')->where('id',$old)->firstOrFail();
|
|
$stored=file_get_contents($source.'/storage/app/private/'.$d->storage_key);$bytes=$d->storage_encryption==='laravel'?Crypt::decryptString($stored):$stored;
|
|
if(hash('sha256',$bytes)!==trim($d->sha256)||$d->malware_scanned_sha256!==trim($d->sha256))throw new RuntimeException('Accepted synthetic bytes required');
|
|
// Test fixture only: the existing zone-download contract confines bytes to its own directory.
|
|
// Preserve the original business document and its storage key; use an explicitly synthetic byte-identical copy.
|
|
$id=(string)Str::uuid();$key='investment-zones/'.$zone.'/'.$id;$dir=$source.'/storage/app/private/'.dirname($key);if(!is_dir($dir))mkdir($dir,0700,true);file_put_contents($source.'/storage/app/private/'.$key,$bytes);
|
|
$copy=(array)$d;foreach(['created_at','updated_at','deleted_at'] as $keyDate)unset($copy[$keyDate]);$copy['id']=$id;$copy['storage_key']=$key;$copy['file_name']='synthetic-qa-parks-support.png';$copy['storage_encryption']='none';$copy['uploaded_by']=2;$copy['source_system']='parks-qa-fixture';$copy['external_id']=null;$copy['created_at']=now();$copy['updated_at']=now();
|
|
DB::transaction(function()use($copy,$id,$old){DB::table('documents')->insert($copy);DB::table('investment_zone_attachments')->where('document_id',$old)->update(['document_id'=>$id,'updated_at'=>now()]);});
|
|
$proof=['document_id'=>$id,'source_document_id'=>$old,'sha256'=>trim($d->sha256),'byte_identical_synthetic_fixture'=>true,'existing_clean_scan_reused_by_exact_hash'=>true,'new_scan_claimed'=>false,'original_document_unchanged'=>true,'publicly_selected'=>false,'uploads'=>0,'reason'=>'Existing zone attachment contract requires zone-confined plaintext bytes; this fixture does not extend that contract.'];file_put_contents(__DIR__.'/SUPORTE-QA-CORRIGIDO.json',json_encode($proof,JSON_PRETTY_PRINT));echo json_encode(['fixture_document'=>$id,'source_unchanged'=>true]);
|