forked from mtusi2026/mtusi2026lab6
Bring the application, own tests, Dockerfile, toolchain, compose stack, HAProxy, k6, RustFS and RabbitMQ configuration, migrations, hooks, scenario scripts and the CI job from the lab 5 solution commit 64d5c67, keep the lab 5 Makefile targets on top of the unchanged skeleton targets, and append the lab 5 solution variables to the skeleton .env.example. The package and the application follow the contract version 1.6.0, and the image, the throwaway test containers and the broker vhost description are tagged lab6 so they do not collide with a lab 5 stand on the same host. This is the starting point of the lab 6 cycle: lint, own tests and the offline skeleton check pass before any lab 6 change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
from datetime import datetime
|
|
from typing import Protocol, runtime_checkable
|
|
from uuid import UUID
|
|
|
|
from messenger.identity.domain.models import Session, User
|
|
from messenger.shared.application.ports import UnitOfWork
|
|
|
|
|
|
@runtime_checkable
|
|
class UserRepository(Protocol):
|
|
async def add(self, user: User) -> None: ...
|
|
|
|
|
|
@runtime_checkable
|
|
class SessionRepository(Protocol):
|
|
async def add(self, session: Session) -> None: ...
|
|
|
|
async def remove(self, token_hash: bytes) -> None: ...
|
|
|
|
|
|
@runtime_checkable
|
|
class IdentityUnitOfWork(UnitOfWork, Protocol):
|
|
@property
|
|
def users(self) -> UserRepository: ...
|
|
|
|
@property
|
|
def sessions(self) -> SessionRepository: ...
|
|
|
|
|
|
@runtime_checkable
|
|
class UserDirectory(Protocol):
|
|
async def find(self, user_id: UUID) -> User | None: ...
|
|
|
|
async def find_by_username(self, username: str) -> User | None: ...
|
|
|
|
|
|
@runtime_checkable
|
|
class SessionDirectory(Protocol):
|
|
async def find(self, token_hash: bytes, now: datetime) -> Session | None: ...
|
|
|
|
async def invalidate(self, session: Session) -> None: ...
|
|
|
|
|
|
@runtime_checkable
|
|
class PasswordHasher(Protocol):
|
|
async def hash(self, password: str) -> str: ...
|
|
|
|
async def verify(self, password_hash: str | None, password: str) -> bool: ...
|