Prepare GovOPlaN self-hosted release workflow
This commit is contained in:
@@ -20,12 +20,22 @@ from govoplan_core.core.events import (
|
||||
event_context,
|
||||
normalize_trace_id,
|
||||
)
|
||||
from govoplan_core.core.modules import ModuleContext
|
||||
from govoplan_core.core.registry import PlatformRegistry
|
||||
from govoplan_core.core.runtime import clear_runtime, configure_runtime
|
||||
from govoplan_core.db.base import Base
|
||||
from govoplan_core.server.fastapi import create_govoplan_app
|
||||
from govoplan_core.server.registry import build_platform_registry
|
||||
from tests.db_isolation import temporary_database
|
||||
|
||||
|
||||
def _configure_audit_runtime() -> None:
|
||||
registry = build_platform_registry(("audit",))
|
||||
context = ModuleContext(registry=registry, settings=object())
|
||||
registry.configure_capability_context(context)
|
||||
configure_runtime(context)
|
||||
|
||||
|
||||
class CoreEventTests(unittest.TestCase):
|
||||
def test_event_bus_adds_trace_ids_and_propagates_causation_to_nested_events(self) -> None:
|
||||
bus = EventBus()
|
||||
@@ -127,6 +137,7 @@ class CoreEventTests(unittest.TestCase):
|
||||
root = Path(tempfile.mkdtemp(prefix="govoplan-audit-trace-"))
|
||||
try:
|
||||
with temporary_database(f"sqlite:///{root / 'audit.db'}") as database:
|
||||
_configure_audit_runtime()
|
||||
from govoplan_access.backend.db import models as access_models # noqa: F401
|
||||
from govoplan_admin.backend.db import models as admin_models # noqa: F401
|
||||
from govoplan_audit.backend.db import models as audit_models # noqa: F401
|
||||
@@ -148,12 +159,14 @@ class CoreEventTests(unittest.TestCase):
|
||||
self.assertEqual({"correlation_id": "corr-1", "causation_id": "cause-1"}, item.details["_trace"])
|
||||
self.assertEqual("<redacted>", item.details["password"])
|
||||
finally:
|
||||
clear_runtime()
|
||||
shutil.rmtree(root, ignore_errors=True)
|
||||
|
||||
def test_audit_event_publishes_governed_platform_event(self) -> None:
|
||||
root = Path(tempfile.mkdtemp(prefix="govoplan-audit-event-"))
|
||||
try:
|
||||
with temporary_database(f"sqlite:///{root / 'audit.db'}") as database:
|
||||
_configure_audit_runtime()
|
||||
from govoplan_access.backend.db import models as access_models # noqa: F401
|
||||
from govoplan_admin.backend.db import models as admin_models # noqa: F401
|
||||
from govoplan_audit.backend.db import models as audit_models # noqa: F401
|
||||
@@ -187,12 +200,14 @@ class CoreEventTests(unittest.TestCase):
|
||||
self.assertEqual(item.id, event.payload["audit_log_id"])
|
||||
self.assertEqual("<redacted>", event.payload["details"]["password"])
|
||||
finally:
|
||||
clear_runtime()
|
||||
shutil.rmtree(root, ignore_errors=True)
|
||||
|
||||
def test_audit_events_map_existing_module_action_prefixes(self) -> None:
|
||||
root = Path(tempfile.mkdtemp(prefix="govoplan-audit-module-events-"))
|
||||
try:
|
||||
with temporary_database(f"sqlite:///{root / 'audit.db'}") as database:
|
||||
_configure_audit_runtime()
|
||||
from govoplan_access.backend.db import models as access_models # noqa: F401
|
||||
from govoplan_admin.backend.db import models as admin_models # noqa: F401
|
||||
from govoplan_audit.backend.db import models as audit_models # noqa: F401
|
||||
@@ -225,6 +240,7 @@ class CoreEventTests(unittest.TestCase):
|
||||
by_type = {event.type: event.module_id for event in seen if event.type in cases}
|
||||
self.assertEqual(cases, by_type)
|
||||
finally:
|
||||
clear_runtime()
|
||||
shutil.rmtree(root, ignore_errors=True)
|
||||
|
||||
def test_audit_operation_context_keeps_lifecycle_ids_and_sanitizes_details(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user