From 7d48b0ca52588bd4de5f92dacaa558dcdca892c7 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Tue, 3 Sep 2024 10:39:21 -0700 Subject: [PATCH 01/10] Add text to title when auditing all upload workspaces Instead of having the page title just have a colon followed by nothing when auditing all upload workspaces, instead check if there is an object and if not, display "all upload workspaces". Otherwise, display the object str as before. --- .../gregor_anvil/tests/test_views.py | 46 +++++++++++++++++++ .../upload_workspace_auth_domain_audit.html | 2 +- .../upload_workspace_sharing_audit.html | 2 +- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/gregor_django/gregor_anvil/tests/test_views.py b/gregor_django/gregor_anvil/tests/test_views.py index fa752a8a..32806ab0 100644 --- a/gregor_django/gregor_anvil/tests/test_views.py +++ b/gregor_django/gregor_anvil/tests/test_views.py @@ -2693,6 +2693,12 @@ def test_context_error_table_stop_sharing(self): ) self.assertNotEqual(table.rows[0].get_cell_value("action"), "—") + def test_title(self): + self.client.force_login(self.user) + response = self.client.get(self.get_url()) + # self.assertContains(response, str(self.upload_workspace)) + self.assertIn("all upload workspaces", response.content.decode().lower()) + class UploadWorkspaceSharingAuditByWorkspaceTest(AnVILAPIMockTestMixin, TestCase): """Tests for the UploadWorkspaceSharingAuditByWorkspace view.""" @@ -3059,6 +3065,17 @@ def test_context_error_table_stop_sharing(self): ) self.assertNotEqual(table.rows[0].get_cell_value("action"), "—") + def test_title(self): + self.client.force_login(self.user) + response = self.client.get( + self.get_url( + self.upload_workspace.workspace.billing_project.name, + self.upload_workspace.workspace.name, + ) + ) + self.assertContains(response, str(self.upload_workspace)) + # self.assertNotIn("all upload workspaces", response.content.decode().lower()) + class UploadWorkspaceSharingAuditByUploadCycleTest(AnVILAPIMockTestMixin, TestCase): """Tests for the UploadWorkspaceSharingAuditByUploadCycle view.""" @@ -3393,6 +3410,12 @@ def test_context_error_table_stop_sharing(self): ) self.assertNotEqual(table.rows[0].get_cell_value("action"), "—") + def test_title(self): + self.client.force_login(self.user) + response = self.client.get(self.get_url(self.upload_cycle.cycle)) + self.assertContains(response, str(self.upload_cycle)) + self.assertNotIn("all upload workspaces", response.content.decode().lower()) + class UploadWorkspaceSharingAuditResolveTest(AnVILAPIMockTestMixin, TestCase): def setUp(self): @@ -4847,6 +4870,12 @@ def test_context_needs_action_table_change_to_admin(self): ) self.assertNotEqual(table.rows[0].get_cell_value("action"), "—") + def test_title(self): + self.client.force_login(self.user) + response = self.client.get(self.get_url()) + # self.assertContains(response, str(self.upload_workspace)) + self.assertIn("all upload workspaces", response.content.decode().lower()) + class UploadWorkspaceAuthDomainAuditByWorkspaceTest(AnVILAPIMockTestMixin, TestCase): """Tests for the UploadWorkspaceAuthDomainAuditByWorkspace view.""" @@ -5225,6 +5254,17 @@ def test_context_needs_action_table_change_to_admin(self): ) self.assertNotEqual(table.rows[0].get_cell_value("action"), "—") + def test_title(self): + self.client.force_login(self.user) + response = self.client.get( + self.get_url( + self.upload_workspace.workspace.billing_project.name, + self.upload_workspace.workspace.name, + ) + ) + self.assertContains(response, str(self.upload_workspace)) + self.assertNotIn("all upload workspaces", response.content.decode().lower()) + class UploadWorkspaceAuthDomainAuditByUploadCycleTest(AnVILAPIMockTestMixin, TestCase): """Tests for the UploadWorkspaceSharingAuditByUploadCycle view.""" @@ -5566,6 +5606,12 @@ def test_context_needs_action_table_change_to_admin(self): ) self.assertNotEqual(table.rows[0].get_cell_value("action"), "—") + def test_title(self): + self.client.force_login(self.user) + response = self.client.get(self.get_url(self.upload_cycle.cycle)) + self.assertContains(response, str(self.upload_cycle)) + self.assertNotIn("all upload workspaces", response.content.decode().lower()) + class UploadWorkspaceAuthDomainAuditResolveTest(AnVILAPIMockTestMixin, TestCase): """Tests for the UploadWorkspaceAuthDomainAuditResolve view.""" diff --git a/gregor_django/templates/gregor_anvil/upload_workspace_auth_domain_audit.html b/gregor_django/templates/gregor_anvil/upload_workspace_auth_domain_audit.html index 1588d613..bfc33c32 100644 --- a/gregor_django/templates/gregor_anvil/upload_workspace_auth_domain_audit.html +++ b/gregor_django/templates/gregor_anvil/upload_workspace_auth_domain_audit.html @@ -6,7 +6,7 @@ {% block content %} -

Upload workspace auth domain audit: {{ object }}

+

Upload workspace auth domain audit: {% if object %} {{ object }} {% else %} all Upload Workspaces{% endif %}

diff --git a/gregor_django/templates/gregor_anvil/upload_workspace_sharing_audit.html b/gregor_django/templates/gregor_anvil/upload_workspace_sharing_audit.html index dc4b1a0c..80c50a37 100644 --- a/gregor_django/templates/gregor_anvil/upload_workspace_sharing_audit.html +++ b/gregor_django/templates/gregor_anvil/upload_workspace_sharing_audit.html @@ -6,7 +6,7 @@ {% block content %} -

Upload workspace sharing audit: {{ object }}

+

Upload workspace sharing audit: {% if object %}{{ object }}{% else %} all Upload Workspaces{% endif %}

From 96f73ea77b904736d28d8ea3fc9ef3f13076d523 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Tue, 3 Sep 2024 10:51:19 -0700 Subject: [PATCH 02/10] Color can_compute=False black in audit table This makes more sense; red typically indicates an error while black indicates "no but not a problem". --- .../gregor_anvil/audit/upload_workspace_sharing_audit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gregor_django/gregor_anvil/audit/upload_workspace_sharing_audit.py b/gregor_django/gregor_anvil/audit/upload_workspace_sharing_audit.py index 249c7a24..3ef33806 100644 --- a/gregor_django/gregor_anvil/audit/upload_workspace_sharing_audit.py +++ b/gregor_django/gregor_anvil/audit/upload_workspace_sharing_audit.py @@ -135,7 +135,7 @@ class UploadWorkspaceSharingAuditTable(tables.Table): managed_group = tables.Column(linkify=True) # is_shared = tables.Column() access = tables.Column(verbose_name="Current access") - can_compute = BooleanIconColumn(show_false_icon=True, null=True) + can_compute = BooleanIconColumn(show_false_icon=True, null=True, true_color="green", false_color="black") note = tables.Column() # action = tables.Column() action = tables.TemplateColumn( From 13134c15d1579b28f9085c4375687b37eca7ac84 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Tue, 3 Sep 2024 11:03:09 -0700 Subject: [PATCH 03/10] Add (basic) tests for audit tables --- .../gregor_anvil/tests/test_audit.py | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/gregor_django/gregor_anvil/tests/test_audit.py b/gregor_django/gregor_anvil/tests/test_audit.py index 83dc8ff5..ac30b6ac 100644 --- a/gregor_django/gregor_anvil/tests/test_audit.py +++ b/gregor_django/gregor_anvil/tests/test_audit.py @@ -162,6 +162,67 @@ def test_get_errors_table(self): self.assertEqual(table.rows[0].get_cell("value"), "c") +class UploadWorkspaceSharingAuditTableTest(TestCase): + """General tests of the UploadWorkspaceSharingAuditTable class.""" + + def test_no_rows(self): + """Table works with no rows.""" + table = upload_workspace_sharing_audit.UploadWorkspaceSharingAuditTable([]) + self.assertIsInstance(table, upload_workspace_sharing_audit.UploadWorkspaceSharingAuditTable) + self.assertEqual(len(table.rows), 0) + + def test_one_row(self): + """Table works with one row.""" + upload_workspace = factories.UploadWorkspaceFactory.create() + group = ManagedGroupFactory.create() + WorkspaceGroupSharingFactory.create( + workspace=upload_workspace.workspace, group=group, access=WorkspaceGroupSharing.READER + ) + data = [ + { + "workspace": upload_workspace, + "managed_group": group, + "access": WorkspaceGroupSharing.READER, + "can_compute": None, + "note": "a note", + "action": "", + }, + ] + table = upload_workspace_sharing_audit.UploadWorkspaceSharingAuditTable(data) + self.assertIsInstance(table, upload_workspace_sharing_audit.UploadWorkspaceSharingAuditTable) + self.assertEqual(len(table.rows), 1) + + def test_two_rows(self): + """Table works with two rows.""" + upload_workspace = factories.UploadWorkspaceFactory.create() + group_1 = ManagedGroupFactory.create() + group_2 = ManagedGroupFactory.create() + WorkspaceGroupSharingFactory.create( + workspace=upload_workspace.workspace, group=group_1, access=WorkspaceGroupSharing.READER + ) + data = [ + { + "workspace": upload_workspace, + "managed_group": group_1, + "access": WorkspaceGroupSharing.READER, + "can_compute": None, + "note": "a note", + "action": "", + }, + { + "workspace": upload_workspace, + "managed_group": group_2, + "access": None, + "can_compute": None, + "note": "a note", + "action": "", + }, + ] + table = upload_workspace_sharing_audit.UploadWorkspaceSharingAuditTable(data) + self.assertIsInstance(table, upload_workspace_sharing_audit.UploadWorkspaceSharingAuditTable) + self.assertEqual(len(table.rows), 2) + + class UploadWorkspaceSharingAuditTest(TestCase): """General tests of the `UploadWorkspaceSharingAudit` class.""" @@ -3860,6 +3921,68 @@ def test_other_group_shared_as_owner(self): self.assertEqual(record.note, upload_workspace_sharing_audit.UploadWorkspaceSharingAudit.OTHER_GROUP_NO_ACCESS) +class UploadWorkspaceAuthDomainAuditTableTest(TestCase): + """General tests of the UploadWorkspaceAuthDomainAuditTable class.""" + + def test_no_rows(self): + """Table works with no rows.""" + table = upload_workspace_auth_domain_audit.UploadWorkspaceAuthDomainAuditTable([]) + self.assertIsInstance(table, upload_workspace_auth_domain_audit.UploadWorkspaceAuthDomainAuditTable) + self.assertEqual(len(table.rows), 0) + + def test_one_row(self): + """Table works with one row.""" + upload_workspace = factories.UploadWorkspaceFactory.create() + group = ManagedGroupFactory.create() + GroupGroupMembershipFactory.create( + parent_group=upload_workspace.workspace.authorization_domains.first(), + child_group=group, + role=GroupGroupMembership.MEMBER, + ) + data = [ + { + "workspace": upload_workspace, + "managed_group": group, + "role": GroupGroupMembership.MEMBER, + "note": "a note", + "action": "", + }, + ] + table = upload_workspace_auth_domain_audit.UploadWorkspaceAuthDomainAuditTable(data) + self.assertIsInstance(table, upload_workspace_auth_domain_audit.UploadWorkspaceAuthDomainAuditTable) + self.assertEqual(len(table.rows), 1) + + def test_two_rows(self): + """Table works with two rows.""" + upload_workspace = factories.UploadWorkspaceFactory.create() + group_1 = ManagedGroupFactory.create() + group_2 = ManagedGroupFactory.create() + GroupGroupMembershipFactory.create( + parent_group=upload_workspace.workspace.authorization_domains.first(), + child_group=group_1, + role=GroupGroupMembership.MEMBER, + ) + data = [ + { + "workspace": upload_workspace, + "managed_group": group_1, + "role": GroupGroupMembership.MEMBER, + "note": "a note", + "action": "", + }, + { + "workspace": upload_workspace, + "managed_group": group_2, + "role": None, + "note": "a note", + "action": "", + }, + ] + table = upload_workspace_auth_domain_audit.UploadWorkspaceAuthDomainAuditTable(data) + self.assertIsInstance(table, upload_workspace_auth_domain_audit.UploadWorkspaceAuthDomainAuditTable) + self.assertEqual(len(table.rows), 2) + + class UploadWorkspaceAuthDomainAuditTest(TestCase): """General tests of the `UploadWorkspaceAuthDomainAudit` class.""" From ac6c5193e7d17581defd2b409c1a65a2a7288f13 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Tue, 3 Sep 2024 11:18:08 -0700 Subject: [PATCH 04/10] Only show can_compute icon for owners and writers Do not show can_compute for readers. Also, add tests for the audit result classes so that we can test the get_table_dictionary method. In this case, there is no need to test the individual classes, since they are all just inheriting from the main class without much different behavior. --- .../audit/upload_workspace_sharing_audit.py | 5 +- .../gregor_anvil/tests/test_audit.py | 131 ++++++++++++++++++ 2 files changed, 135 insertions(+), 1 deletion(-) diff --git a/gregor_django/gregor_anvil/audit/upload_workspace_sharing_audit.py b/gregor_django/gregor_anvil/audit/upload_workspace_sharing_audit.py index 3ef33806..af7befe6 100644 --- a/gregor_django/gregor_anvil/audit/upload_workspace_sharing_audit.py +++ b/gregor_django/gregor_anvil/audit/upload_workspace_sharing_audit.py @@ -34,11 +34,14 @@ def get_action_url(self): def get_table_dictionary(self): """Return a dictionary that can be used to populate an instance of `dbGaPDataSharingSnapshotAuditTable`.""" + can_compute = None + if self.current_sharing_instance and self.current_sharing_instance.access != WorkspaceGroupSharing.READER: + can_compute = self.current_sharing_instance.can_compute row = { "workspace": self.workspace, "managed_group": self.managed_group, "access": self.current_sharing_instance.access if self.current_sharing_instance else None, - "can_compute": self.current_sharing_instance.can_compute if self.current_sharing_instance else None, + "can_compute": can_compute, "note": self.note, "action": self.action, "action_url": self.get_action_url(), diff --git a/gregor_django/gregor_anvil/tests/test_audit.py b/gregor_django/gregor_anvil/tests/test_audit.py index ac30b6ac..83f4975e 100644 --- a/gregor_django/gregor_anvil/tests/test_audit.py +++ b/gregor_django/gregor_anvil/tests/test_audit.py @@ -162,6 +162,87 @@ def test_get_errors_table(self): self.assertEqual(table.rows[0].get_cell("value"), "c") +class UploadWorkspaceSharingAuditResultTest(TestCase): + """General tests of the UploadWorkspaceSharingAuditResult dataclasses.""" + + def test_shared_as_owner(self): + upload_workspace = factories.UploadWorkspaceFactory.create(upload_cycle__is_future=True) + group = ManagedGroupFactory.create() + sharing = WorkspaceGroupSharingFactory.create( + workspace=upload_workspace.workspace, group=group, access=WorkspaceGroupSharing.OWNER, can_compute=True + ) + instance = upload_workspace_sharing_audit.UploadWorkspaceSharingAuditResult( + workspace=upload_workspace, + managed_group=group, + current_sharing_instance=sharing, + note="foo", + ) + table_dictionary = instance.get_table_dictionary() + self.assertEqual(table_dictionary["access"], sharing.OWNER) + self.assertEqual(table_dictionary["can_compute"], True) + + def test_shared_as_writer_with_compute(self): + upload_workspace = factories.UploadWorkspaceFactory.create(upload_cycle__is_future=True) + group = ManagedGroupFactory.create() + sharing = WorkspaceGroupSharingFactory.create( + workspace=upload_workspace.workspace, group=group, access=WorkspaceGroupSharing.WRITER, can_compute=True + ) + instance = upload_workspace_sharing_audit.UploadWorkspaceSharingAuditResult( + workspace=upload_workspace, + managed_group=group, + current_sharing_instance=sharing, + note="foo", + ) + table_dictionary = instance.get_table_dictionary() + self.assertEqual(table_dictionary["access"], sharing.WRITER) + self.assertEqual(table_dictionary["can_compute"], True) + + def test_shared_as_writer_without_compute(self): + upload_workspace = factories.UploadWorkspaceFactory.create(upload_cycle__is_future=True) + group = ManagedGroupFactory.create() + sharing = WorkspaceGroupSharingFactory.create( + workspace=upload_workspace.workspace, group=group, access=WorkspaceGroupSharing.WRITER, can_compute=False + ) + instance = upload_workspace_sharing_audit.UploadWorkspaceSharingAuditResult( + workspace=upload_workspace, + managed_group=group, + current_sharing_instance=sharing, + note="foo", + ) + table_dictionary = instance.get_table_dictionary() + self.assertEqual(table_dictionary["access"], sharing.WRITER) + self.assertEqual(table_dictionary["can_compute"], False) + + def test_shared_as_reader(self): + upload_workspace = factories.UploadWorkspaceFactory.create(upload_cycle__is_future=True) + group = ManagedGroupFactory.create() + sharing = WorkspaceGroupSharingFactory.create( + workspace=upload_workspace.workspace, group=group, access=WorkspaceGroupSharing.READER + ) + instance = upload_workspace_sharing_audit.UploadWorkspaceSharingAuditResult( + workspace=upload_workspace, + managed_group=group, + current_sharing_instance=sharing, + note="foo", + ) + table_dictionary = instance.get_table_dictionary() + self.assertEqual(table_dictionary["access"], sharing.READER) + self.assertIsNone(table_dictionary["can_compute"]) + + def test_not_shared(self): + upload_workspace = factories.UploadWorkspaceFactory.create(upload_cycle__is_future=True) + group = ManagedGroupFactory.create() + instance = upload_workspace_sharing_audit.UploadWorkspaceSharingAuditResult( + workspace=upload_workspace, + managed_group=group, + current_sharing_instance=None, + note="foo", + ) + table_dictionary = instance.get_table_dictionary() + self.assertIsNone(table_dictionary["access"]) + self.assertIsNone(table_dictionary["can_compute"]) + + class UploadWorkspaceSharingAuditTableTest(TestCase): """General tests of the UploadWorkspaceSharingAuditTable class.""" @@ -3921,6 +4002,56 @@ def test_other_group_shared_as_owner(self): self.assertEqual(record.note, upload_workspace_sharing_audit.UploadWorkspaceSharingAudit.OTHER_GROUP_NO_ACCESS) +class UploadWorkspaceAuthDomainAuditResultTest(TestCase): + """General tests of the UploadWorkspaceAuthDomainAuditResult dataclasses.""" + + def test_member_as_admin(self): + upload_workspace = factories.UploadWorkspaceFactory.create(upload_cycle__is_future=True) + group = ManagedGroupFactory.create() + membership = GroupGroupMembershipFactory.create( + parent_group=upload_workspace.workspace.authorization_domains.first(), + child_group=group, + role=GroupGroupMembership.ADMIN, + ) + instance = upload_workspace_sharing_audit.UploadWorkspaceSharingAuditResult( + workspace=upload_workspace, + managed_group=group, + current_membership_instance=membership, + note="foo", + ) + table_dictionary = instance.get_table_dictionary() + self.assertEqual(table_dictionary["role"], membership.ADMIN) + + def test_member_as_member(self): + upload_workspace = factories.UploadWorkspaceFactory.create(upload_cycle__is_future=True) + group = ManagedGroupFactory.create() + membership = GroupGroupMembershipFactory.create( + parent_group=upload_workspace.workspace.authorization_domains.first(), + child_group=group, + role=GroupGroupMembership.MEMBER, + ) + instance = upload_workspace_sharing_audit.UploadWorkspaceSharingAuditResult( + workspace=upload_workspace, + managed_group=group, + current_membership_instance=membership, + note="foo", + ) + table_dictionary = instance.get_table_dictionary() + self.assertEqual(table_dictionary["role"], membership.MEMBER) + + def test_not_member(self): + upload_workspace = factories.UploadWorkspaceFactory.create(upload_cycle__is_future=True) + group = ManagedGroupFactory.create() + instance = upload_workspace_sharing_audit.UploadWorkspaceSharingAuditResult( + workspace=upload_workspace, + managed_group=group, + current_membership_instance=None, + note="foo", + ) + table_dictionary = instance.get_table_dictionary() + self.assertIsNone(table_dictionary["role"]) + + class UploadWorkspaceAuthDomainAuditTableTest(TestCase): """General tests of the UploadWorkspaceAuthDomainAuditTable class.""" From a2b0ee07fc903a9e65001a11b982846b462eb429 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Tue, 3 Sep 2024 11:22:08 -0700 Subject: [PATCH 05/10] Remove unused code from sharing audit --- .../audit/upload_workspace_sharing_audit.py | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/gregor_django/gregor_anvil/audit/upload_workspace_sharing_audit.py b/gregor_django/gregor_anvil/audit/upload_workspace_sharing_audit.py index af7befe6..45d640aa 100644 --- a/gregor_django/gregor_anvil/audit/upload_workspace_sharing_audit.py +++ b/gregor_django/gregor_anvil/audit/upload_workspace_sharing_audit.py @@ -20,18 +20,6 @@ class UploadWorkspaceSharingAuditResult(GREGoRAuditResult): action: str = None current_sharing_instance: WorkspaceGroupSharing = None - def get_action_url(self): - """The URL that handles the action needed.""" - # return reverse( - # "gregor_anvil:audit:upload_workspaces:sharing:resolve", - # args=[ - # self.dbgap_application.dbgap_project_id, - # self.workspace.workspace.billing_project.name, - # self.workspace.workspace.name, - # ], - # ) - return "" - def get_table_dictionary(self): """Return a dictionary that can be used to populate an instance of `dbGaPDataSharingSnapshotAuditTable`.""" can_compute = None @@ -44,7 +32,6 @@ def get_table_dictionary(self): "can_compute": can_compute, "note": self.note, "action": self.action, - "action_url": self.get_action_url(), } return row @@ -53,8 +40,6 @@ def get_table_dictionary(self): class VerifiedShared(UploadWorkspaceSharingAuditResult): """Audit results class for when Sharing has been verified.""" - is_shared: bool = True - def __str__(self): return f"Verified sharing: {self.note}" @@ -63,8 +48,6 @@ def __str__(self): class VerifiedNotShared(UploadWorkspaceSharingAuditResult): """Audit results class for when no Sharing has been verified.""" - is_shared: bool = False - def __str__(self): return f"Verified not shared: {self.note}" @@ -73,7 +56,6 @@ def __str__(self): class ShareAsReader(UploadWorkspaceSharingAuditResult): """Audit results class for when Sharing should be granted as a reader.""" - is_shared: bool = False action: str = "Share as reader" def __str__(self): @@ -84,7 +66,6 @@ def __str__(self): class ShareAsWriter(UploadWorkspaceSharingAuditResult): """Audit results class for when Sharing should be granted as a writer.""" - is_shared: bool = False action: str = "Share as writer" def __str__(self): @@ -95,7 +76,6 @@ def __str__(self): class ShareAsOwner(UploadWorkspaceSharingAuditResult): """Audit results class for when Sharing should be granted as an owner.""" - is_shared: bool = False action: str = "Share as owner" def __str__(self): @@ -106,7 +86,6 @@ def __str__(self): class ShareWithCompute(UploadWorkspaceSharingAuditResult): """Audit results class for when Sharing should be granted with compute access.""" - is_shared: bool = False action: str = "Share with compute" def __str__(self): @@ -117,7 +96,6 @@ def __str__(self): class StopSharing(UploadWorkspaceSharingAuditResult): """Audit results class for when Sharing should be removed for a known reason.""" - is_shared: bool = True action: str = "Stop sharing" def __str__(self): @@ -136,11 +114,9 @@ class UploadWorkspaceSharingAuditTable(tables.Table): workspace = tables.Column(linkify=True) managed_group = tables.Column(linkify=True) - # is_shared = tables.Column() access = tables.Column(verbose_name="Current access") can_compute = BooleanIconColumn(show_false_icon=True, null=True, true_color="green", false_color="black") note = tables.Column() - # action = tables.Column() action = tables.TemplateColumn( template_name="gregor_anvil/snippets/upload_workspace_sharing_audit_action_button.html" ) From e3fa75157aa5351b81f5b34e65ef0f2b6ba305c9 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Tue, 3 Sep 2024 12:02:59 -0700 Subject: [PATCH 06/10] Fix tests for auth domain audit classes --- gregor_django/gregor_anvil/tests/test_audit.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gregor_django/gregor_anvil/tests/test_audit.py b/gregor_django/gregor_anvil/tests/test_audit.py index 83f4975e..7c0b4b10 100644 --- a/gregor_django/gregor_anvil/tests/test_audit.py +++ b/gregor_django/gregor_anvil/tests/test_audit.py @@ -4013,7 +4013,7 @@ def test_member_as_admin(self): child_group=group, role=GroupGroupMembership.ADMIN, ) - instance = upload_workspace_sharing_audit.UploadWorkspaceSharingAuditResult( + instance = upload_workspace_auth_domain_audit.UploadWorkspaceAuthDomainAuditResult( workspace=upload_workspace, managed_group=group, current_membership_instance=membership, @@ -4030,7 +4030,7 @@ def test_member_as_member(self): child_group=group, role=GroupGroupMembership.MEMBER, ) - instance = upload_workspace_sharing_audit.UploadWorkspaceSharingAuditResult( + instance = upload_workspace_auth_domain_audit.UploadWorkspaceAuthDomainAuditResult( workspace=upload_workspace, managed_group=group, current_membership_instance=membership, @@ -4042,7 +4042,7 @@ def test_member_as_member(self): def test_not_member(self): upload_workspace = factories.UploadWorkspaceFactory.create(upload_cycle__is_future=True) group = ManagedGroupFactory.create() - instance = upload_workspace_sharing_audit.UploadWorkspaceSharingAuditResult( + instance = upload_workspace_auth_domain_audit.UploadWorkspaceAuthDomainAuditResult( workspace=upload_workspace, managed_group=group, current_membership_instance=None, From 1cc3f8783693cc9891b1f19df3ff892f631c9d38 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Tue, 3 Sep 2024 12:04:39 -0700 Subject: [PATCH 07/10] Shorten error explanation for sharing audit --- .../snippets/upload_workspace_sharing_audit_explanation.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gregor_django/templates/gregor_anvil/snippets/upload_workspace_sharing_audit_explanation.html b/gregor_django/templates/gregor_anvil/snippets/upload_workspace_sharing_audit_explanation.html index af07d58f..cdf2a379 100644 --- a/gregor_django/templates/gregor_anvil/snippets/upload_workspace_sharing_audit_explanation.html +++ b/gregor_django/templates/gregor_anvil/snippets/upload_workspace_sharing_audit_explanation.html @@ -36,7 +36,7 @@

  • Errors
    • -
    • The workspace has been shared with an unexpected group as an "OWNER".
    • +
    • The workspace has been shared with an unexpected group.

    From f4552b1d8b895148f179d43fc440951352daeb4f Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Tue, 3 Sep 2024 12:07:02 -0700 Subject: [PATCH 08/10] Fix auth domain audit explanation for final changes The auth domain audit explanation still had the previous behavior (before Cat's review and subsequent changes). Update the explanation to reflect the actual behavior. --- ...ad_workspace_auth_domain_audit_explanation.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gregor_django/templates/gregor_anvil/snippets/upload_workspace_auth_domain_audit_explanation.html b/gregor_django/templates/gregor_anvil/snippets/upload_workspace_auth_domain_audit_explanation.html index edd9af6c..8eca84f7 100644 --- a/gregor_django/templates/gregor_anvil/snippets/upload_workspace_auth_domain_audit_explanation.html +++ b/gregor_django/templates/gregor_anvil/snippets/upload_workspace_auth_domain_audit_explanation.html @@ -12,6 +12,12 @@

    This audit checks that auth domain membership is appropriate for the current point in the upload cycle. Membership is expected to be as follows.
      +
    • Before the upload cycle begins:
    • +
        +
      • GREGOR_DCC_ADMINS (as admin)
      • +
      • GREGOR_DCC_WRITERS
      • +
      • GREGOR_DCC_MEMBERS
      • +
    • Before the combined workspace is completed:
      • GREGOR_DCC_ADMINS (as admin)
      • @@ -21,6 +27,14 @@

      • The member group for the Research Center associated with this upload workspace
      • The non-member group for the Research Center associated with this upload workspace
      +
    • After QC has been completed:
    • +
        +
      • GREGOR_DCC_ADMINS (as admin)
      • +
      • GREGOR_DCC_WRITERS
      • +
      • GREGOR_DCC_MEMBERS
      • +
      • The member group for the Research Center associated with this upload workspace
      • +
      • The non-member group for the Research Center associated with this upload workspace
      • +
    • After the combined workspace is completed:
      • GREGOR_DCC_ADMINS (as admin)
      • From dd6d56c145bca4253b085ba94ad4f29b32fa19db Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Tue, 3 Sep 2024 12:48:11 -0700 Subject: [PATCH 09/10] Update CI to fail if no files are found The coverage job is failing because github added a breaking change in v4.4 of the upload-artifact job such that hidden files were no longer uploaded by default. This breaks the current coverage setup where the coverage file is hidden (.coverage). This change causes the upload-artifact job to fail if no files are found, which is really what we want. With this change, I expect all pytest jobs to fail at the step of uploading the coverage file. --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e45bc4a..eaab61e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,6 +103,7 @@ jobs: with: name: coverage-data-${{ strategy.job-index }} path: .coverage-${{ strategy.job-index }} + if-no-files-found: error coverage: needs: From 3f04ec354423e1b74a28f213c7643d0ce4fe1d1f Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Tue, 3 Sep 2024 13:38:59 -0700 Subject: [PATCH 10/10] Rename coverage files to not have a . at the beginning This way they won't be considered hidden files by the upload-artifacts action. --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eaab61e3..b8200359 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,7 +93,7 @@ jobs: - name: Run tests run: | pytest --cov=gregor_django -n auto - mv .coverage .coverage-${{ strategy.job-index }} + mv .coverage coverage-${{ strategy.job-index }} - name: List files for debugging purposes run: ls -lhta @@ -102,7 +102,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: coverage-data-${{ strategy.job-index }} - path: .coverage-${{ strategy.job-index }} + path: coverage-${{ strategy.job-index }} if-no-files-found: error coverage: @@ -130,7 +130,7 @@ jobs: - name: Merge coverage files run: | - python -m coverage combine ./artifacts/coverage-data*/.coverage-* + python -m coverage combine ./artifacts/coverage-data*/coverage-* python -m coverage xml ls -la .coverage*