aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-12-12 13:26:28 +0300
committerFrederick Muriuki Muriithi2022-12-12 13:28:14 +0300
commit6c077671e9afdb4921e72d0a3018e3d8dedada8b (patch)
treece10d9c701510eeaf805c0731c8bb63f81065351
parent8d728774bfc5371c61b483cb5470f45456de028b (diff)
downloadgenenetwork3-6c077671e9afdb4921e72d0a3018e3d8dedada8b.tar.gz
auth: Attach group to GroupRole, rather than group_id
-rw-r--r--gn3/auth/authorisation/groups.py3
-rw-r--r--tests/unit/auth/test_groups.py1
2 files changed, 3 insertions, 1 deletions
diff --git a/gn3/auth/authorisation/groups.py b/gn3/auth/authorisation/groups.py
index 743e812..cda11b3 100644
--- a/gn3/auth/authorisation/groups.py
+++ b/gn3/auth/authorisation/groups.py
@@ -22,6 +22,7 @@ class Group(NamedTuple):
class GroupRole(NamedTuple):
"""Class representing a role tied/belonging to a group."""
group_role_id: UUID
+ group: Group
role: Role
class MembershipError(AuthorisationError):
@@ -81,7 +82,7 @@ def create_group_role(
"VALUES(?, ?, ?)"),
(str(group_role_id), str(group.group_id), str(role.role_id)))
- return GroupRole(group_role_id, role)
+ return GroupRole(group_role_id, group, role)
@authenticated_p
def authenticated_user_group(conn) -> Maybe:
diff --git a/tests/unit/auth/test_groups.py b/tests/unit/auth/test_groups.py
index 9eef0e9..e1b44cc 100644
--- a/tests/unit/auth/test_groups.py
+++ b/tests/unit/auth/test_groups.py
@@ -58,6 +58,7 @@ create_role_failure = {
"user,expected", tuple(zip(conftest.TEST_USERS, (
GroupRole(
UUID("d32611e3-07fc-4564-b56c-786c6db6de2b"),
+ GROUP,
Role(UUID("d32611e3-07fc-4564-b56c-786c6db6de2b"),
"ResourceEditor", PRIVILEGES)),
create_role_failure, create_role_failure, create_role_failure,