Updated
On this page
InMemoryAuthBackend: dict-backed test double for AuthBackend, mirroring its pool-free async API for consumers and credentials, plus test-only helpers for direct scope-grant injection.
#auth.src.orxtra.auth._inmemory
#auth.src.orxtra.auth._inmemory
#InMemoryAuthBackend
Dict-backed auth storage for tests.
Pool-free: all methods operate on internal dicts directly, matching the pool-free API of the PG AuthBackend.
#create_consumer
python
async def create_consumer(self, name: str, trust_tier: TrustTier, scope_grants: list[str], *, consumer_id: UUID, principal_id: UUID) -> UUIDPersist a consumer with a caller-supplied id and principal.
Mirrors the PG backend: the caller mints the consumer's own principal (kind=consumer, external_ref=consumer_id) first and passes both ids in. In-memory has no FK, so the ids are stored without enforcement.
#get_consumer
python
async def get_consumer(self, consumer_id: UUID) -> ConsumerRecord | None#disable_consumer
python
async def disable_consumer(self, consumer_id: UUID) -> None#create_credential
python
async def create_credential(self, consumer_id: UUID, credential_type: str, raw_value: str, *, secret_ref: str | None=None) -> UUID#get_credential_by_id
python
async def get_credential_by_id(self, credential_id: UUID) -> CredentialRecord | None#get_credential_by_hash
python
async def get_credential_by_hash(self, credential_hash: str) -> CredentialRecord | None#get_credentials_by_consumer
python
async def get_credentials_by_consumer(self, consumer_id: UUID, *, credential_type: str | None=None) -> list[CredentialRecord]#_inject_scope_grants
python
def _inject_scope_grants(self, consumer_id: UUID, scopes: list[str]) -> NoneDirectly set scope_grants for test convenience (avoids JSON round-trip).