45 lines
2.4 KiB
PHP
45 lines
2.4 KiB
PHP
<?php
|
|
|
|
use Illuminate\Contracts\Console\Kernel;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Vite;
|
|
|
|
// QA-only HTTP harness: fixed isolated restored database; never use artisan serve for this test.
|
|
$root = dirname(__DIR__);
|
|
foreach (['APP_ENV' => 'testing', 'APP_DEBUG' => 'true', 'DB_CONNECTION' => 'pgsql', 'DB_HOST' => '127.0.0.1', 'DB_PORT' => '55441',
|
|
'DB_DATABASE' => 'anchor_restore_20261007_test', 'DB_USERNAME' => 'postgres', 'DB_PASSWORD' => '', 'DB_URL' => '',
|
|
'QUEUE_CONNECTION' => 'sync', 'SESSION_DRIVER' => 'file', 'SESSION_COOKIE' => 'anchor_relationship_qa', 'CACHE_STORE' => 'array',
|
|
'PORTAL_MANAGER_EMAILS' => 'relationship-qa@example.invalid,partnership-qa-moderator@example.invalid', 'MAIL_MAILER' => 'array'] as $key => $value) {
|
|
putenv($key.'='.$value);
|
|
$_ENV[$key] = $value;
|
|
$_SERVER[$key] = $value;
|
|
}
|
|
$path = rawurldecode(parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/');
|
|
if ($path !== '/' && is_file($root.'/public'.$path)) {
|
|
return false;
|
|
}
|
|
require_once $root.'/vendor/autoload.php';
|
|
$app = require $root.'/bootstrap/app.php';
|
|
$app->make(Kernel::class)->bootstrap();
|
|
$connection = config('database.connections.'.config('database.default'));
|
|
if (($connection['database'] ?? null) !== 'anchor_restore_20261007_test' || (string) ($connection['port'] ?? '') !== '55441'
|
|
|| ($connection['host'] ?? null) !== '127.0.0.1' || ! in_array($connection['url'] ?? null, [null, ''], true)) {
|
|
http_response_code(503);
|
|
exit('QA target rejected');
|
|
}
|
|
$identity = DB::selectOne('select current_database() as database, inet_server_port() as port');
|
|
if ($identity->database !== 'anchor_restore_20261007_test' || (int) $identity->port !== 55441) {
|
|
http_response_code(503);
|
|
exit('QA connected identity rejected');
|
|
}
|
|
$planDirectory = getenv('RELATIONSHIP_QA_PLAN') === 'territorial' ? 'qa-territorial-preview' : 'qa-preview';
|
|
config(['inertia.ssr.enabled' => false, 'session.files' => $root.'/storage/framework/anchor-qa-sessions',
|
|
'investment.repair_directory' => $root.'/storage/app/private/anchor-project-reconciliation/'.$planDirectory]);
|
|
if (! is_dir(config('session.files'))) {
|
|
mkdir(config('session.files'), 0700, true);
|
|
}
|
|
Vite::useHotFile($root.'/storage/framework/anchor-qa-hot-file');
|
|
header('X-Investmoz-QA-Target: '.$identity->database.':'.$identity->port);
|
|
$app->handleRequest(Request::capture());
|