-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #365 from UW-GAC/bugfix/issue-362
Fix AnVIL audit when service account is not directly a group admin
- Loading branch information
Showing
4 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.16.1dev1" | ||
__version__ = "0.16.1dev2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2825,6 +2825,40 @@ def test_different_group_member_email_case_insensitive(self): | |
self.assertEqual(audit_results.get_errors(), {}) | ||
self.assertEqual(audit_results.get_not_in_app(), set()) | ||
|
||
def test_service_account_is_not_directly_admin(self): | ||
"""Audit works when the service account is not directly an admin of a group (but is via a group admin).""" | ||
group = factories.ManagedGroupFactory.create() | ||
membership = factories.GroupGroupMembershipFactory.create( | ||
parent_group=group, | ||
child_group__email="[email protected]", | ||
role=models.GroupGroupMembership.ADMIN, | ||
) | ||
api_url_members = self.get_api_url_members(group.name) | ||
self.anvil_response_mock.add( | ||
responses.GET, | ||
api_url_members, | ||
status=200, | ||
json=api_factories.GetGroupMembershipResponseFactory().response, | ||
) | ||
api_url_admins = self.get_api_url_admins(group.name) | ||
self.anvil_response_mock.add( | ||
responses.GET, | ||
api_url_admins, | ||
status=200, | ||
# Use the Membership factory because it doesn't add the service account as a direct admin. | ||
json=api_factories.GetGroupMembershipResponseFactory( | ||
response=["[email protected]"] | ||
).response, | ||
) | ||
audit_results = group.anvil_audit_membership() | ||
self.assertIsInstance( | ||
audit_results, anvil_audit.ManagedGroupMembershipAuditResults | ||
) | ||
self.assertTrue(audit_results.ok()) | ||
self.assertEqual(audit_results.get_verified(), set([membership])) | ||
self.assertEqual(audit_results.get_errors(), {}) | ||
self.assertEqual(audit_results.get_not_in_app(), set()) | ||
|
||
|
||
class WorkspaceAnVILAPIMockTest(AnVILAPIMockTestMixin, TestCase): | ||
def setUp(self, *args, **kwargs): | ||
|