fix(iwooos): scope control plane database read
This commit is contained in:
@@ -230,6 +230,32 @@ def test_service_redacts_database_exception_details(monkeypatch) -> None:
|
||||
assert "private-host" not in text
|
||||
|
||||
|
||||
def test_service_uses_canonical_awoooi_project_scope(monkeypatch) -> None:
|
||||
service = IwoooSSecurityAssetControlPlaneService()
|
||||
requested_projects: list[str] = []
|
||||
|
||||
class FailingContext:
|
||||
async def __aenter__(self):
|
||||
raise RuntimeError("stop after project scope capture")
|
||||
|
||||
async def __aexit__(self, exc_type, exc, traceback):
|
||||
return False
|
||||
|
||||
def fake_db_context(project_id: str):
|
||||
requested_projects.append(project_id)
|
||||
return FailingContext()
|
||||
|
||||
monkeypatch.setattr(
|
||||
"src.services.iwooos_security_asset_control_plane.get_db_context",
|
||||
fake_db_context,
|
||||
)
|
||||
payload = asyncio.run(service.get_snapshot())
|
||||
|
||||
assert requested_projects == ["awoooi"]
|
||||
assert payload["status"] == "degraded"
|
||||
assert payload["reason_code"] == "database_query_failed"
|
||||
|
||||
|
||||
def test_public_api_returns_live_aggregate(monkeypatch) -> None:
|
||||
payload = _ready_payload()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user