Files
Investidor-V2/tools/portal-functional-document-revocation-actor-qa.php
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

21 lines
2.1 KiB
PHP

<?php
// New disposable synthetic QA reviewer; existing actor grants and identities remain untouched.
$root=dirname(__DIR__);$dir=$root.'/storage/app/private/investmoz-v2/portal-audit';$plan=json_decode(file_get_contents($dir.'/portal-stability-latest.json'),true,512,JSON_THROW_ON_ERROR);
putenv('STABILITY_QA_MODE=consumers');$app=(static fn($p)=>require $p)($plan['source'].'/tools/portal-stability-runtime.php');
$identity=Illuminate\Support\Facades\DB::selectOne('SELECT current_database() AS database,inet_server_port() AS port');
throw_unless(app()->environment('testing')&&$identity->database==='stability_consumers_20261011_084534_test'&&(int)$identity->port===55441,RuntimeException::class,'Exact QA guard required before any write');
$path=$dir.'/functional-document-revocation-actor-private.json';
if(is_file($path)){$private=json_decode(file_get_contents($path),true,512,JSON_THROW_ON_ERROR);$u=App\Models\User::findOrFail($private['id']);}
else{
$private=['email'=>'document-revocation-qa@example.invalid','password'=>'QA-'.bin2hex(random_bytes(24))];
throw_unless(!App\Models\User::where('email',$private['email'])->exists(),RuntimeException::class,'Untracked existing account refused');
$u=App\Models\User::create(['name'=>'Synthetic documentary revocation QA','email'=>$private['email'],'password'=>$private['password'],'email_verified_at'=>now()]);
$u->forceFill(['email_verified_at'=>now()])->save();
app(Laravel\Fortify\Actions\EnableTwoFactorAuthentication::class)($u);
$secret=Laravel\Fortify\Fortify::currentEncrypter()->decrypt($u->fresh()->two_factor_secret);
$otp=(new PragmaRX\Google2FA\Google2FA)->getCurrentOtp($secret);
app(Laravel\Fortify\Actions\ConfirmTwoFactorAuthentication::class)($u,$otp);
$private+=['id'=>$u->id,'totp_secret'=>$secret];file_put_contents($path,json_encode($private,JSON_THROW_ON_ERROR));unset($secret,$otp);
}
echo json_encode(['result'=>'prepared','target'=>$identity,'synthetic_actor_id'=>$u->id,'mfa_confirmed'=>$u->fresh()->two_factor_confirmed_at!==null,'grant_not_assigned'=>true,'active_writes'=>0],JSON_THROW_ON_ERROR).PHP_EOL;