|
18 | 18 | get_permissions_for_active_roles_in_scope, |
19 | 19 | get_permissions_for_single_role, |
20 | 20 | get_role_definitions_in_scope, |
| 21 | + get_scopes_for_role_and_subject, |
21 | 22 | get_subject_role_assignments, |
22 | 23 | get_subject_role_assignments_for_role_in_scope, |
23 | 24 | get_subject_role_assignments_in_scope, |
@@ -505,6 +506,24 @@ def test_get_role_assignments_in_scope(self, role_name, scope_name, expected_cou |
505 | 506 |
|
506 | 507 | self.assertEqual(len(role_assignments), expected_count) |
507 | 508 |
|
| 509 | + def test_get_scopes_for_role_and_subject(self): |
| 510 | + """Test retrieving scopes for a given role and subject. |
| 511 | +
|
| 512 | + Expected result: |
| 513 | + - The scopes associated with the specified role and subject are correctly retrieved. |
| 514 | + """ |
| 515 | + role_name = "library_author" |
| 516 | + subject_name = "liam" |
| 517 | + expected_scopes = {"lib:Org4:art_101", "lib:Org4:art_201", "lib:Org4:art_301"} |
| 518 | + |
| 519 | + scopes = get_scopes_for_role_and_subject( |
| 520 | + RoleData(external_key=role_name), |
| 521 | + SubjectData(external_key=subject_name), |
| 522 | + ) |
| 523 | + |
| 524 | + scope_names = {scope.external_key for scope in scopes} |
| 525 | + self.assertEqual(scope_names, expected_scopes) |
| 526 | + |
508 | 527 |
|
509 | 528 | @ddt |
510 | 529 | class TestRoleAssignmentAPI(RolesTestSetupMixin): |
|
0 commit comments