09393b354b
Completes the de-sidecar cleanup: no live code, test, current doc, script, or nix file mentions or is named "sidecar" any more. Only the dated PRD/research docs keep the term as historical record (agreed on the #385 thread). - Rename `sidecar_init.py`→`gateway_init.py` was done earlier; this pass sweeps the remaining descriptive uses: the egress / git-gate / supervise components are the gateway's *daemons*, the shared container is the *gateway*, the old per-bottle container was the *companion container*. - Rename `tests/integration/test_sidecar_bundle_image.py`→`test_gateway_image.py` and its class; update `docs/ci.md` + `tests/README.md` for the renamed/ removed integration tests. - `SIDECAR_PORTS` shell var in `scripts/firecracker-netpool.sh`→`GATEWAY_PORTS`. Full unit suite green (bar the pre-existing `/bin/sleep`-missing env errors in test_gateway_init); docker integration — gateway singleton, broker, real two-bottle multitenant isolation, and the gateway-image build — all pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WBMWTEtQdJ4W5UrWuLHCck
57 lines
2.1 KiB
Python
57 lines
2.1 KiB
Python
"""Unit: consolidated registration inputs — egress policy round-trip (PRD 0070)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from bot_bottle.egress import EgressPlan, EgressRoute
|
|
from bot_bottle.egress_addon_core import LOG_BLOCKS, load_config
|
|
from bot_bottle.orchestrator.registration import (
|
|
RegistrationInputs,
|
|
egress_policy,
|
|
registration_inputs,
|
|
)
|
|
|
|
|
|
def _plan(routes: tuple[EgressRoute, ...], *, slug: str = "demo", log: int = 0) -> EgressPlan:
|
|
return EgressPlan(
|
|
slug=slug,
|
|
routes_path=Path("/unused/routes.yaml"),
|
|
routes=routes,
|
|
token_env_map={},
|
|
log=log,
|
|
)
|
|
|
|
|
|
class TestEgressPolicy(unittest.TestCase):
|
|
def test_policy_round_trips_through_load_config(self) -> None:
|
|
# The policy the gateway serves must parse back to the same allow-list
|
|
# the per-bottle gateway applied — moving onto the shared gateway must
|
|
# not change a bottle's egress.
|
|
routes = (EgressRoute(host="api.example.com"), EgressRoute(host="pypi.org"))
|
|
cfg = load_config(egress_policy(_plan(routes)))
|
|
self.assertEqual(("api.example.com", "pypi.org"), tuple(r.host for r in cfg.routes))
|
|
|
|
def test_policy_preserves_log_level(self) -> None:
|
|
plan = _plan((EgressRoute(host="x.example.com"),), log=LOG_BLOCKS)
|
|
self.assertEqual(LOG_BLOCKS, load_config(egress_policy(plan)).log)
|
|
|
|
def test_empty_routes_yield_deny_all(self) -> None:
|
|
cfg = load_config(egress_policy(_plan(())))
|
|
self.assertEqual((), cfg.routes) # no routes → default-deny
|
|
|
|
|
|
class TestRegistrationInputs(unittest.TestCase):
|
|
def test_bundles_policy_and_slug_metadata(self) -> None:
|
|
plan = _plan((EgressRoute(host="api.example.com"),), slug="my-bot")
|
|
inputs = registration_inputs(plan)
|
|
self.assertIsInstance(inputs, RegistrationInputs)
|
|
self.assertEqual("my-bot", json.loads(inputs.metadata)["slug"])
|
|
self.assertEqual(egress_policy(plan), inputs.policy) # same blob egress_policy renders
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|