29 lines
2.6 KiB
PHP
29 lines
2.6 KiB
PHP
<?php
|
|
ini_set('zend.exception_ignore_args','1');
|
|
try {
|
|
$root=dirname(__DIR__,2);
|
|
require $root.'/vendor/autoload.php'; $app=require $root.'/bootstrap/app.php';
|
|
(new Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables)->bootstrap($app);
|
|
(new Illuminate\Foundation\Bootstrap\LoadConfiguration)->bootstrap($app);
|
|
$c=config('database.connections.'.config('database.default'));
|
|
if($c['driver']!=='pgsql'||(int)$c['port']!==5432||$c['database']!=='investemoz'||!empty($c['url']))throw new RuntimeException('Target refused');
|
|
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
|
$db=Illuminate\Support\Facades\DB::connection();$db->beginTransaction();$db->statement('SET TRANSACTION READ ONLY');
|
|
$access=app(App\Services\PortalProfileAccess::class);
|
|
if(!$access->available())throw new RuntimeException('Workflow not available');
|
|
$base=App\Services\OpportunityCanonicalContract::BASE_CATEGORIES;
|
|
$rows=[];
|
|
foreach([14=>'promoter',15=>'validator',16=>'publisher'] as $id=>$role){
|
|
$actor=App\Models\User::findOrFail($id);$nav=$access->navigation($actor);
|
|
if(!$access->has($actor,$role))throw new RuntimeException('Assigned role unavailable');
|
|
if($id===14){
|
|
$types=array_unique(array_column($nav['contexts'],'type'));sort($types);$expected=$base;sort($expected);
|
|
if($types!==$expected||$nav['create']!=='/minhas-oportunidades/create'||$nav['mine']!=='/minhas-oportunidades')throw new RuntimeException('Promoter navigation mismatch');
|
|
}elseif($nav['review']!=='/minhas-oportunidades'||$nav['create']!==null)throw new RuntimeException('Reviewer/publisher navigation mismatch');
|
|
$rows[]=['user_id'=>$id,'role'=>$role,'navigation'=>$nav,'has_other_operational_role'=>array_values(array_filter(['promoter','validator','publisher'],fn($other)=>$other!==$role&&$access->has($actor,$other)))];
|
|
}
|
|
$route=[];foreach($app['router']->getRoutes() as $r)if(in_array($r->uri(),['minhas-oportunidades','minhas-oportunidades/create','minhas-oportunidades/{id}/contacts','minhas-oportunidades/{id}/workflow']))$route[]=['uri'=>$r->uri(),'methods'=>$r->methods(),'middleware'=>$r->gatherMiddleware()];
|
|
$db->rollBack();
|
|
echo json_encode(['result'=>'passed','at'=>gmdate('c'),'target'=>'investemoz:5432','read_only'=>true,'human_authentication_impersonated'=>false,'browser_observed'=>false,'base_categories'=>$base,'accounts'=>$rows,'routes'=>$route,'first_legitimate_process_demonstrated'=>false],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR);
|
|
}catch(Throwable $e){echo json_encode(['result'=>'stopped','type'=>$e::class,'line'=>$e->getLine()]);exit(1);}
|