Coverage for src / lexigram / contracts / admin / authorizer.py: 100%

5 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-08-15 18:58 +0800

1"""AdminAuthorizerProtocol — authorization for admin resource operations.""" 

2 

3from __future__ import annotations 

4 

5from typing import Any, Protocol, runtime_checkable 

6 

7 

8@runtime_checkable 

9class AdminAuthorizerProtocol(Protocol): 

10 """Canonical admin-internal authorization protocol. 

11 

12 Covers both CRUD-level checks (can_view, can_create, can_update, can_delete) 

13 and action-level checks (can_execute_action). 

14 """ 

15 

16 async def can_view(self, user: Any, resource: str, record: Any = None) -> bool: ... 

17 

18 async def can_create(self, user: Any, resource: str) -> bool: ... 

19 

20 async def can_update( 

21 self, user: Any, resource: str, record: Any = None 

22 ) -> bool: ... 

23 

24 async def can_delete( 

25 self, user: Any, resource: str, record: Any = None 

26 ) -> bool: ... 

27 

28 async def can_execute_action( 

29 self, user: Any, resource: str, action: str, record: Any | None = None 

30 ) -> bool: ... 

31 

32 

33__all__ = ["AdminAuthorizerProtocol"]