This commit is contained in:
2026-11-02 20:27:11 +02:00
parent b44378b899
commit badaada043
300 changed files with 17458 additions and 1056 deletions
+45
View File
@@ -0,0 +1,45 @@
<?php
use Tempo\Integration\WarehouseHttpSource;
use Tempo\Integration\WarehouseInbox;
use Tempo\Integration\WarehousePull;
use Tempo\Integration\WarehouseTransportFailure;
require __DIR__.'/../packages/integration/bootstrap.php';
// Read-only QA origin; receiver tables live only in this disposable memory store.
try {
$input = json_decode(stream_get_contents(STDIN), true, 16, JSON_THROW_ON_ERROR);
if (! is_array($input) || ! is_string($input['cookie'] ?? null) || ! is_int($input['tenant_id'] ?? null) || $input['tenant_id'] <= 0) {
throw new RuntimeException('Entrada de avaliação inválida.');
}
$db = new PDO('sqlite::memory:');
foreach (WarehouseInbox::schema() as $sql) {
$db->exec($sql);
}
$source = new WarehouseHttpSource('http://127.0.0.1:8005', $input['tenant_id'], fn () => $input['cookie'], allowLoopbackHttp: true);
$inbox = new WarehouseInbox($db, 'synthetic-qa-8005', $input['tenant_id'], 99, 'disposable-evaluation');
$result = (new WarehousePull($inbox))->run($source, maxPages: 1, pageSize: 1);
$checkpoint = $inbox->checkpoint();
$next = $source($checkpoint['cursor'], 1);
if ($next['schema'] !== 'sgc.warehouse.fulfilment-feed.v1') {
throw new RuntimeException('Contrato de avaliação inesperado.');
}
$anonymousDenied = false;
try {
$anonymous = new WarehouseHttpSource('http://127.0.0.1:8005', $input['tenant_id'], fn () => 'SGC_TEST_SESSION=not-authenticated', allowLoopbackHttp: true);
$anonymous(null, 1);
} catch (WarehouseTransportFailure $e) {
$anonymousDenied = $e->category === 'authentication';
}
if (! $anonymousDenied) {
throw new RuntimeException('Acesso anónimo não recusado como esperado.');
}
echo json_encode(['result' => 'passed', 'transport' => 'native PHP cURL to existing QA session', 'pages' => $result['pages'],
'received_facts' => $result['inserted'], 'receiver_checkpoint_version' => $checkpoint['version'],
'cursor_roundtrip' => true, 'unauthenticated_read_denied' => true, 'receiver' => 'disposable SQLite memory',
'persistent_business_commands' => false, 'persistent_accounts_or_grants_changed' => false, 'sgf_installation_changed' => false], JSON_THROW_ON_ERROR);
} catch (Throwable) {
fwrite(STDERR, 'A avaliação HTTP do conector não foi aprovada. Nenhuma credencial é apresentada.'.PHP_EOL);
exit(1);
}