15 lines
1.7 KiB
PHP
15 lines
1.7 KiB
PHP
<?php
|
|
// Read-only credential correspondence check; never prints or changes credentials.
|
|
require __DIR__.'/../vendor/autoload.php';$app=require __DIR__.'/../bootstrap/app.php';$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
|
\App\Modules\Industry\IndustrialBudgets::guard();
|
|
$identity=\Illuminate\Support\Facades\DB::selectOne('SELECT current_database() AS db,current_user AS role,inet_server_port() AS port');
|
|
if($identity->db!=='sgf_tempo_test'||$identity->role!=='sgf_test_runner'||(int)$identity->port!==55432)throw new RuntimeException('Unexpected database; no accounts changed.');
|
|
$path='C:/laragon/data/sgf-tempo/secrets/industrial-budget-manual-entry.txt';
|
|
if(!is_file($path))throw new RuntimeException('Entry file missing; no credentials reset.');
|
|
$content=file_get_contents($path);
|
|
if(!str_contains($content,'http://127.0.0.1:8002')||!preg_match_all('/(?:Osmane|Samira) synthetic: ([^\r\n]+)\r?\nPassword: ([^\r\n]+)/',$content,$matches,PREG_SET_ORDER)||count($matches)!==2)throw new RuntimeException('Unexpected entry file structure; no accounts changed.');
|
|
$checks=[];
|
|
foreach($matches as $match){$email=$match[1];if(!in_array($email,['gestor@example.test','consulta@example.test'],true))throw new RuntimeException('Non-synthetic account refused.');$user=\App\Models\User::where('email',$email)->first();$checks[]=['account'=>$email,'matches_current_test_account'=>$user&&\Illuminate\Support\Facades\Hash::check($match[2],$user->password)];}
|
|
unset($content,$matches,$match);
|
|
echo json_encode(['path'=>realpath($path),'database'=>$identity->db,'role'=>$identity->role,'accounts'=>$checks,'read_only'=>true,'credentials_changed'=>false],JSON_THROW_ON_ERROR).PHP_EOL;
|