24 lines
1.4 KiB
PHP
24 lines
1.4 KiB
PHP
<?php
|
|
// Test-only subprocess, never a route. Its private input contains no credentials.
|
|
putenv('APP_ENV=testing');
|
|
require dirname(__DIR__, 2).'/vendor/autoload.php';
|
|
$app = require dirname(__DIR__, 2).'/bootstrap/app.php';
|
|
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
|
App\Shared\Testing\TestingDatabaseGuard::assertSafe();
|
|
$p = json_decode(file_get_contents($argv[1]), true, 512, JSON_THROW_ON_ERROR);
|
|
$db = Illuminate\Support\Facades\DB::connection();
|
|
$cluster = $db->selectOne("SELECT current_setting('cluster_name') AS name")->name;
|
|
if ($cluster !== 'sgf_modular_regression_'.getenv('SGF_ISOLATED_REGRESSION_RUN')) throw new RuntimeException('Wrong test cluster');
|
|
$db->statement("SET application_name = 'sgf_association_worker'");
|
|
$context = app(App\Shared\Context\CompanyContext::class);
|
|
$context->selectFor($p['actor'], $p['tenant'], $p['company'], $p['unit']);
|
|
$r = Illuminate\Http\Request::create('/api/module-records', 'POST', ['review_token' => $p['review_token']]);
|
|
$r->headers->set('X-SGF-Context', $p['context']);
|
|
file_put_contents($argv[1].'.ready', 'ready');
|
|
try {
|
|
$result = app(App\Modules\Identity\Services\ModuleAssociationReview::class)->confirm($r);
|
|
echo json_encode(['status' => 200, ...$result], JSON_THROW_ON_ERROR);
|
|
} catch (Symfony\Component\HttpKernel\Exception\HttpExceptionInterface $e) {
|
|
echo json_encode(['status' => $e->getStatusCode()], JSON_THROW_ON_ERROR);
|
|
}
|