26 lines
653 B
Python
26 lines
653 B
Python
from dataclasses import dataclass
|
|
|
|
from app.core import rbac
|
|
|
|
|
|
@dataclass
|
|
class UserStub:
|
|
is_admin: bool = False
|
|
|
|
|
|
@dataclass
|
|
class MemberStub:
|
|
role_in_study: str
|
|
|
|
|
|
def test_non_admin_global_role_does_not_grant_project_document_permission():
|
|
assert not rbac.is_allowed("delete_document", UserStub(), MemberStub(role_in_study="CRA"))
|
|
|
|
|
|
def test_project_role_grants_project_document_permission():
|
|
assert rbac.is_allowed("delete_document", UserStub(), MemberStub(role_in_study="PM"))
|
|
|
|
|
|
def test_global_admin_keeps_system_document_permission_without_membership():
|
|
assert rbac.is_allowed("delete_document", UserStub(is_admin=True), None)
|