|
31 | 31 | get_role_definitions_in_scope, |
32 | 32 | get_scopes_for_subject_and_permission, |
33 | 33 | get_subject_role_assignments, |
| 34 | + get_subject_role_assignments_for_role, |
34 | 35 | get_subject_role_assignments_for_role_in_scope, |
35 | 36 | get_subject_role_assignments_in_scope, |
36 | 37 | get_subjects_for_role_in_scope, |
@@ -603,6 +604,23 @@ def test_get_all_role_assignments_scopes(self, subject_name, expected_roles): |
603 | 604 | found = any(expected_role in assignment.roles for assignment in role_assignments) |
604 | 605 | self.assertTrue(found, f"Expected role {expected_role} not found in assignments") |
605 | 606 |
|
| 607 | + @ddt_data( |
| 608 | + ("liam", roles.LIBRARY_AUTHOR.external_key, 3), |
| 609 | + ("eve", roles.LIBRARY_ADMIN.external_key, 1), |
| 610 | + ("eve", roles.LIBRARY_AUTHOR.external_key, 1), |
| 611 | + ("eve", roles.LIBRARY_USER.external_key, 1), |
| 612 | + ("alice", roles.LIBRARY_AUTHOR.external_key, 0), |
| 613 | + ("non_existent_user", roles.LIBRARY_ADMIN.external_key, 0), |
| 614 | + ) |
| 615 | + @unpack |
| 616 | + def test_get_subject_role_assignments_for_role(self, subject_name, role_name, expected_count): |
| 617 | + """Test retrieving role assignments for a subject filtered by role across all scopes.""" |
| 618 | + role_assignments = get_subject_role_assignments_for_role( |
| 619 | + SubjectData(external_key=subject_name), |
| 620 | + RoleData(external_key=role_name), |
| 621 | + ) |
| 622 | + self.assertEqual(len(role_assignments), expected_count) |
| 623 | + |
606 | 624 | @ddt_data( |
607 | 625 | (roles.LIBRARY_ADMIN.external_key, "lib:Org1:math_101", 1), |
608 | 626 | (roles.LIBRARY_AUTHOR.external_key, "lib:Org1:history_201", 1), |
|
0 commit comments