diff --git a/tests/unit/admin/views/test_malware_reports.py b/tests/unit/admin/views/test_malware_reports.py index cad8e71af6ba..aa98ff30c34d 100644 --- a/tests/unit/admin/views/test_malware_reports.py +++ b/tests/unit/admin/views/test_malware_reports.py @@ -102,7 +102,9 @@ def test_malware_reports_project_verdict_not_malware(self, db_request): assert action_record["reason"] == "This is a test" def test_malware_reports_project_verdict_quarantine(self, db_request): + owner_user = UserFactory.create(is_frozen=False) project = ProjectFactory.create() + RoleFactory(user=owner_user, project=project, role_name="Owner") report = ProjectObservationFactory.create(kind="is_malware", related=project) db_request.route_path = lambda a: "/admin/malware_reports/" @@ -130,6 +132,7 @@ def test_malware_reports_project_verdict_quarantine(self, db_request): == f"Quarantined by {db_request.user.username}." ) assert len(report.actions) == 0 + assert owner_user.is_frozen is True def test_malware_reports_project_verdict_remove_malware(self, db_request): owner_user = UserFactory.create(is_frozen=False) @@ -148,7 +151,7 @@ def test_malware_reports_project_verdict_remove_malware(self, db_request): db_request.session = pretend.stub( flash=pretend.call_recorder(lambda *a, **kw: None) ) - db_request.user = owner_user + db_request.user = UserFactory.create() result = views.malware_reports_project_verdict_remove_malware( project, db_request @@ -167,7 +170,8 @@ def test_malware_reports_project_verdict_remove_malware(self, db_request): assert len(report.actions) == 1 assert db_request.db.get(Project, project.id) is None - assert db_request.user.is_frozen is True + assert owner_user.is_frozen is True + assert owner_user.observations[0].kind == "account_abuse" class TestMalwareReportsDetail: @@ -211,7 +215,10 @@ def test_detail_not_malware_for_project(self, db_request): assert action_record["reason"] == "This is a test" def test_detail_verdict_quarantine_project(self, db_request): - report = ProjectObservationFactory.create(kind="is_malware") + owner_user = UserFactory.create(is_frozen=False) + project = ProjectFactory.create() + RoleFactory(user=owner_user, project=project, role_name="Owner") + report = ProjectObservationFactory.create(kind="is_malware", related=project) db_request.matchdict["observation_id"] = str(report.id) db_request.route_path = lambda a: "/admin/malware_reports/" db_request.session = pretend.stub( @@ -237,6 +244,7 @@ def test_detail_verdict_quarantine_project(self, db_request): f"Quarantined by {db_request.user.username}." ) assert len(report.actions) == 0 + assert owner_user.is_frozen is True def test_detail_remove_malware_for_project(self, db_request): owner_user = UserFactory.create(is_frozen=False) @@ -257,7 +265,7 @@ def test_detail_remove_malware_for_project(self, db_request): db_request.session = pretend.stub( flash=pretend.call_recorder(lambda *a, **kw: None) ) - db_request.user = owner_user + db_request.user = UserFactory.create() result = views.remove_malware_for_project(db_request) @@ -273,4 +281,5 @@ def test_detail_remove_malware_for_project(self, db_request): assert len(report.actions) == 1 assert db_request.db.get(Project, project.id) is None - assert db_request.user.is_frozen is True + assert owner_user.is_frozen is True + assert owner_user.observations[0].kind == "account_abuse" diff --git a/warehouse/admin/static/js/warehouse.js b/warehouse/admin/static/js/warehouse.js index a2327fb45752..6d038cf08089 100644 --- a/warehouse/admin/static/js/warehouse.js +++ b/warehouse/admin/static/js/warehouse.js @@ -159,17 +159,22 @@ if (tokenTable.length) { } // Observations -let observationsTable = $("#observations"); -if (observationsTable.length) { - let table = observationsTable.DataTable({ - responsive: true, - lengthChange: false, - }); - table.column(".time").order("desc").draw(); - table.columns([".payload"]).visible(false); - new $.fn.dataTable.Buttons(table, {buttons: ["copy", "csv", "colvis"]}); - table.buttons().container().appendTo($(".col-md-6:eq(0)", table.table().container())); -} +// Note: Each of these tables **must** have the same columns for this to work. +const tableSelectors = ["#observations", "#user_observations"]; + +tableSelectors.forEach(selector => { + let tableElement = $(selector); + if (tableElement.length) { + let table = tableElement.DataTable({ + responsive: true, + lengthChange: false, + }); + table.column(".time").order("desc").draw(); + table.columns([".payload"]).visible(false); + new $.fn.dataTable.Buttons(table, {buttons: ["copy", "csv", "colvis"]}); + table.buttons().container().appendTo($(".col-md-6:eq(0)", table.table().container())); + } +}); // Malware Reports let malwareReportsTable = $("#malware-reports"); diff --git a/warehouse/admin/templates/admin/malware_reports/detail.html b/warehouse/admin/templates/admin/malware_reports/detail.html index d282d1f3be50..368682ec87c8 100644 --- a/warehouse/admin/templates/admin/malware_reports/detail.html +++ b/warehouse/admin/templates/admin/malware_reports/detail.html @@ -175,6 +175,7 @@
This will remove the Project from being installable, + freeze the Owner's account, and prohibit the Project from being changed by the Owner.
diff --git a/warehouse/admin/templates/admin/malware_reports/project_list.html b/warehouse/admin/templates/admin/malware_reports/project_list.html index b42553d3b24c..6588ba457a8b 100644 --- a/warehouse/admin/templates/admin/malware_reports/project_list.html +++ b/warehouse/admin/templates/admin/malware_reports/project_list.html @@ -221,6 +221,7 @@This will remove the Project from being installable, + freeze the Owner's account, and prohibit the Project from being changed by the Owner.
diff --git a/warehouse/admin/templates/admin/users/detail.html b/warehouse/admin/templates/admin/users/detail.html index ae738e6618d4..5d8ecd9eeaea 100644 --- a/warehouse/admin/templates/admin/users/detail.html +++ b/warehouse/admin/templates/admin/users/detail.html @@ -883,10 +883,42 @@{{ user.username }}
Time | +Related | +Kind | +Summary | +Payload | +
---|---|---|---|---|
{{ observation.created }} | +{{ observation.related }} | +{{ observation.kind_display }} | +{{ observation.summary }} | +{{ observation.payload }} | +