18 lines
1.8 KiB
PHP
18 lines
1.8 KiB
PHP
<?php
|
|
putenv('APP_ENV=testing');
|
|
$s=json_decode(file_get_contents('C:/laragon/data/sgf-tempo/run/modular-regression-current.json'),true,512,JSON_THROW_ON_ERROR);
|
|
if(!preg_match('/^[a-f0-9]{12}$/D',$s['id'])||$s['port']!==55439)throw new RuntimeException('Wrong QA host');
|
|
require $s['app'].'/vendor/autoload.php';$app=require $s['app'].'/bootstrap/app.php';$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
|
App\Shared\Testing\TestingDatabaseGuard::assertSafe();
|
|
$db=Illuminate\Support\Facades\DB::connection();$db->beginTransaction();
|
|
try {
|
|
$db->statement('SET TRANSACTION READ ONLY');
|
|
$i=$db->selectOne("SELECT current_database() AS db,current_user AS role,inet_server_port() AS port,current_setting('cluster_name') AS cluster");
|
|
if($i->db!=='sgf_tempo_test'||$i->role!=='sgf_test_runner'||(int)$i->port!==55439||$i->cluster!=='sgf_modular_regression_'.$s['id'])throw new RuntimeException('Wrong effective QA host');
|
|
$grants=$db->table('permission_grants')->where(fn($q)=>$q->where('permission','stock.view')->orWhere('permission','like','workshop_stock.%'))->count();
|
|
$constraint=$db->selectOne("SELECT pg_get_constraintdef(oid) AS d FROM pg_constraint WHERE conrelid='permission_grants'::regclass AND conname='permission_grants_scope_check'")->d;
|
|
if($grants!==0||hash('sha256',$constraint)!=='40046092cba51f1b46d26d5f0da8af47e8336e90a8d50b8de3a8c390758f1783')throw new RuntimeException('Temporary rights not restored');
|
|
$bindings=count(config('workshop_stock.synthetic_sources',[]));if($bindings!==0)throw new RuntimeException('Operational source unexpectedly configured');
|
|
echo json_encode(['qa_identity'=>$i,'temporary_grants_remaining'=>$grants,'constraint_sha256'=>hash('sha256',$constraint),'operational_workshop_stock_bindings'=>$bindings,'read_only'=>true],JSON_PRETTY_PRINT).PHP_EOL;
|
|
} finally {$db->rollBack();}
|