The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: verify webhook receipt observation and composed HTTP startup
Tekniuma5a0da667c7d
diff --git a/tests/gateway/test_native_http_auth.py b/tests/gateway/test_native_http_auth.pyindex 7fdf58baf23..bf0fffba4b5 100644--- a/tests/gateway/test_native_http_auth.py+++ b/tests/gateway/test_native_http_auth.py@@ -184,6 +184,9 @@ async def test_native_http_preserves_gated_auth_and_actual_socket_boundary(tmp_prunner = GatewayRunner(GatewayConfig())try:await initialize_gateway_runtime(runner)+ from gateway.control_socket import GatewayControlServer+ runner.session_control_server = GatewayControlServer()+ assert await runner.session_control_server.start()runner.session_api = await start_gateway_api(runner, host='0.0.0.0')port = runner.session_api.socket.getsockname()[1]def mint():@@ -225,6 +228,7 @@ async def test_native_http_preserves_gated_auth_and_actual_socket_boundary(tmp_passert (await client.get('/api/config', headers=headers(mint()))).status_code == 503finally:await runner.stop()+ await runner.session_control_server.stop()process_ownership.close()clear_providers()print(json.dumps({'normal_oauth_bearer_cookie': 'passed',diff --git a/tests/gateway/test_webhook_durable_destination.py b/tests/gateway/test_webhook_durable_destination.pyindex 039dc79aad7..fec7c82f611 100644--- a/tests/gateway/test_webhook_durable_destination.py+++ b/tests/gateway/test_webhook_durable_destination.py@@ -108,3 +108,46 @@ async def test_exact_legacy_webhook_retry_keeps_receipt_without_inference():changed = json.dumps({'text': 'changed'}).encode()headers['X-Hub-Signature-256'] = 'sha256=' + hmac.new(b'owned-secret', changed, hashlib.sha256).hexdigest()assert (await client.post('/webhooks/fixture', data=changed, headers=headers)).status == 503++[email protected]('fence', ['draining', 'epoch'])+async def test_fenced_webhook_retry_only_observes_existing_receipt(fence):+ config = PlatformConfig(enabled=True, extra={'secret': 'owned-secret', 'routes': {+ 'fixture': {'prompt': '{text}', 'deliver': 'log'}}})+ adapter = WebhookAdapter(config)+ app = web.Application()+ mount_authority(app, adapter)+ app.router.add_post('/webhooks/{route_name}', adapter._handle_webhook)+ async with TestClient(TestServer(app)) as client:+ body = json.dumps({'text': 'already committed'}).encode()+ headers = {'X-GitHub-Delivery': 'observed-one', 'X-Hub-Signature-256':+ 'sha256=' + hmac.new(b'owned-secret', body, hashlib.sha256).hexdigest()}+ assert (await client.post('/webhooks/fixture', data=body, headers=headers)).status == 202+ authority = adapter._message_handler.__self__.session_authority+ if fence == 'draining':+ authority.runner._draining = True+ else:+ from hermes_state_runtime import begin_runtime_epoch+ begin_runtime_epoch(authority.db, instance_id='replacement-owner')+ schedules = []+ authority._schedule = schedules.append+ async def forbidden_admission(event):+ pytest.fail('observing a receipt must not admit new work')+ original_admit = authority.admit_native+ authority.admit_native = forbidden_admission+ with authority.db._read_ctx() as conn:+ before = tuple(conn.iterdump())+ adapter._seen_deliveries.clear()+ response = await client.post('/webhooks/fixture', data=body, headers=headers)+ assert response.status == 200, await response.text()+ with authority.db._read_ctx() as conn:+ assert tuple(conn.iterdump()) == before+ assert schedules == []+ row = authority.db._read_one('SELECT status FROM session_admissions')+ assert row['status'] == 'queued'+ authority.admit_native = original_admit+ headers['X-GitHub-Delivery'] = 'never-accepted'+ assert (await client.post('/webhooks/fixture', data=body, headers=headers)).status == 503+ assert len(authority.db._read_all('SELECT admission_id FROM session_admissions')) == 1+ assert schedules == []