61 lines
3.4 KiB
PHP
61 lines
3.4 KiB
PHP
<?php
|
|
|
|
use Carbon\CarbonImmutable;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
$root = realpath(getenv('SGC_REQUISITION_QA_ROOT') ?: '');
|
|
$database = getenv('DB_DATABASE') ?: '';
|
|
$boundary = realpath(__DIR__.'/../../storage/framework/testing');
|
|
if (getenv('APP_ENV') !== 'testing' || getenv('DB_HOST') !== '127.0.0.1' || getenv('DB_PORT') !== '55439'
|
|
|| ! preg_match('/^compras_receipts_test_([a-f0-9]{12})$/D', $database, $matches)
|
|
|| ($_SERVER['REMOTE_ADDR'] ?? '') !== '127.0.0.1' || ($_SERVER['SERVER_PORT'] ?? '') != getenv('SGC_REQUISITION_QA_PORT')
|
|
|| $root === false || $boundary === false || str_replace('\\', '/', $root) !== str_replace('\\', '/', $boundary).'/rq01-ledger-qa-'.$matches[1]) {
|
|
http_response_code(503);
|
|
exit;
|
|
}
|
|
require __DIR__.'/../../vendor/autoload.php';
|
|
$public = $root.'/public';
|
|
$requestPath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
|
$asset = realpath($public.'/'.ltrim(rawurldecode($requestPath), '/'));
|
|
$types = ['js' => 'text/javascript', 'css' => 'text/css', 'svg' => 'image/svg+xml', 'png' => 'image/png', 'ico' => 'image/x-icon', 'woff' => 'font/woff', 'woff2' => 'font/woff2'];
|
|
if ($asset !== false && is_file($asset) && str_starts_with(str_replace('\\', '/', $asset), str_replace('\\', '/', $public).'/')
|
|
&& isset($types[pathinfo($asset, PATHINFO_EXTENSION)])) {
|
|
header('Content-Type: '.$types[pathinfo($asset, PATHINFO_EXTENSION)]);
|
|
readfile($asset);
|
|
exit;
|
|
}
|
|
$app = require __DIR__.'/../../bootstrap/app.php';
|
|
$app->useStoragePath($root.'/storage');
|
|
$app->usePublicPath($root.'/public');
|
|
$app->booted(function () use ($root, $database) {
|
|
abort_unless(config('database.default') === 'pgsql' && config('database.connections.pgsql.database') === $database, 503);
|
|
$fixture = json_decode(file_get_contents($root.'/native-review.json'), true, 32, JSON_THROW_ON_ERROR);
|
|
Carbon::setTestNow($fixture['clock']);
|
|
CarbonImmutable::setTestNow($fixture['clock']);
|
|
config(['requisition-expiry.qa_enabled' => true, 'requisition-accounts.qa_enabled' => true, 'urgent-reviews.qa_enabled' => true,
|
|
'order_cancellation.enabled' => true,
|
|
'operational-orders.qa_enabled' => true, 'urgent-quotations.qa_enabled' => true, 'private-audit.qa_enabled' => true,
|
|
'agreement_order_limits.qa_enabled' => true, 'procurement_search.supply_metadata_enabled' => true,
|
|
'procurement_search.warehouse_requests_metadata_enabled' => true,
|
|
'session.driver' => 'file', 'session.files' => $root.'/storage/framework/sessions', 'session.domain' => null,
|
|
'session.secure' => false, 'cache.default' => 'array']);
|
|
if (getenv('RQ01_NATIVE_OFFICE_JOURNEY') === '1') {
|
|
config(['common-payables.enabled' => true, 'common-payables.source_instance' => 'native-http-office-qa',
|
|
'expense-allocations.qa_enabled' => true]);
|
|
}
|
|
if (getenv('RQ01_QA_LEGAL_REFERENCE') === '1') {
|
|
config(['import-legal.qa_enabled' => true, 'import-tariffs.qa_enabled' => true]);
|
|
}
|
|
if (getenv('RQ01_QA_CAPITAL_SEARCH') === '1') {
|
|
config(['capital-register.qa_enabled' => true]);
|
|
}
|
|
if (getenv('RQ01_QA_IMPORT_DOCUMENTARY') === '1') {
|
|
config(['import-dossier.qa_enabled' => true, 'import-bank-support.qa_enabled' => true]);
|
|
}
|
|
if (getenv('RQ01_QA_CONFLICT_RELEASE') === '1') {
|
|
config(['conflict-releases.qa_enabled' => true]);
|
|
}
|
|
});
|
|
$app->handleRequest(Request::capture());
|