tests: super admin auth tests
This commit is contained in:
parent
1b54918bb4
commit
3460cd76a5
Notes:
Chris Milne
2026-06-03 13:38:41 +00:00
Issue: #18
3 changed files with 91 additions and 0 deletions
|
|
@ -69,3 +69,17 @@ async def user_model_super_admin(user_model: user_model_claims_dependency):
|
|||
|
||||
|
||||
super_admin_dependency = Annotated[type[User], Depends(user_model_super_admin)]
|
||||
|
||||
|
||||
# Override for testing
|
||||
async def never_super_admin(user_model: user_model_claims_dependency):
|
||||
def _is_super_admin(_user_model) -> bool:
|
||||
super_admin_emails = []
|
||||
if _user_model.email not in super_admin_emails:
|
||||
raise UnauthorizedException(message="Must be super admin")
|
||||
return True
|
||||
|
||||
if _is_super_admin(user_model):
|
||||
return user_model
|
||||
|
||||
raise UnauthorizedException(message="Must be super admin")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue