1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +00:00

fix(logs): blocking a blocked user writes no row; one upload submit path

Follow-ups from the review of the audit log layers:

- Blocking a user who is already blocked, or unblocking one who is
  not, changes nothing and now writes no row, like any other edit
  that changes nothing.
- write_chunk takes the request instead of the user and an optional
  request; the view always had one, so the branch only tests used
  is gone and every chunk 0 goes through the same audited submit.
- Tests: a busy clone creates no job and its row carries the page's
  message; a later chunk that fails writes no submit row; libvirt
  refusing a network or pool delete is a failed row.
This commit is contained in:
catborise 2026-10-23 14:09:26 +03:00
parent d5df187de4
commit b24746c1cb
7 changed files with 52 additions and 29 deletions

View file

@ -81,6 +81,13 @@ class NetworkRowTests(TestCase):
self.assertIn(error, [str(m) for m in get_messages(response.wsgi_request)])
self.assertEqual(rows(), [(f"Network lab: stop: {error}", False)])
def test_a_refused_network_delete(self):
error = "Requested operation is not valid: network is in use"
with patch("vrtManager.network.wvmNetwork.delete", side_effect=libvirt.libvirtError(error)):
response = self.post({"delete": ""})
self.assertIn(error, [str(m) for m in get_messages(response.wsgi_request)])
self.assertEqual(rows(), [(f"Network lab: delete: {error}", False)])
def test_network_create(self):
url = reverse("networks", args=[self.compute.id])
self.client.post(url, {"create": "", "name": "audit-net", "forward": "nat", "subnet": "198.51.100.0/24",