C-6: ConnectorRuntime enforces capability_mask per operation.
READ-only ACs cannot invoke MUTATE operations (wipe, lock, retire).
C-7: AC validated against database (exists, active, not expired)
before connector invocation.
C-9: Delegated AC capability bounded by delegator's capability.
C-10: Command counter uses atomic SQL increment with limit check.
M-23: expire_stale() uses same atomic SQL pattern.
H-1: Sensitive credential fields hidden from repr/logs via repr=False.
H-2: Stub backend requires ALLOW_STUB_CREDENTIALS=true to activate.
H-3: Kerberos backend raises CredentialResolutionError instead of
returning stub ticket.
H-4: Chronicle INTENT emitted before execution, RESULT after.
H-5: device_id validated as UUID before Graph API URL interpolation.
H-8: ConnectorRuntime enforces governance for all connector invocations.
Signed-off-by: Tyler King <tking@guildhouse.dev>
65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
import types
|
|
from abc import ABCMeta, abstractmethod
|
|
from collections.abc import AsyncGenerator, Callable, Coroutine, Iterable
|
|
from typing import Any, TypeVar
|
|
|
|
_T = TypeVar("_T")
|
|
|
|
|
|
class TestRunner(metaclass=ABCMeta):
|
|
"""
|
|
Encapsulates a running event loop. Every call made through this object will use the
|
|
same event loop.
|
|
"""
|
|
|
|
def __enter__(self) -> TestRunner:
|
|
return self
|
|
|
|
@abstractmethod
|
|
def __exit__(
|
|
self,
|
|
exc_type: type[BaseException] | None,
|
|
exc_val: BaseException | None,
|
|
exc_tb: types.TracebackType | None,
|
|
) -> bool | None: ...
|
|
|
|
@abstractmethod
|
|
def run_asyncgen_fixture(
|
|
self,
|
|
fixture_func: Callable[..., AsyncGenerator[_T, Any]],
|
|
kwargs: dict[str, Any],
|
|
) -> Iterable[_T]:
|
|
"""
|
|
Run an async generator fixture.
|
|
|
|
:param fixture_func: the fixture function
|
|
:param kwargs: keyword arguments to call the fixture function with
|
|
:return: an iterator yielding the value yielded from the async generator
|
|
"""
|
|
|
|
@abstractmethod
|
|
def run_fixture(
|
|
self,
|
|
fixture_func: Callable[..., Coroutine[Any, Any, _T]],
|
|
kwargs: dict[str, Any],
|
|
) -> _T:
|
|
"""
|
|
Run an async fixture.
|
|
|
|
:param fixture_func: the fixture function
|
|
:param kwargs: keyword arguments to call the fixture function with
|
|
:return: the return value of the fixture function
|
|
"""
|
|
|
|
@abstractmethod
|
|
def run_test(
|
|
self, test_func: Callable[..., Coroutine[Any, Any, Any]], kwargs: dict[str, Any]
|
|
) -> None:
|
|
"""
|
|
Run an async test function.
|
|
|
|
:param test_func: the test function
|
|
:param kwargs: keyword arguments to call the test function with
|
|
"""
|