1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(virtsecrets): a secret in use is not deleted by its UUID in capitals

libvirt finds a secret by its UUID in capitals too, but its users were
looked up by the UUID as posted: a secret a VM's disk or a pool named
was deleted, and that VM or pool no longer started. They are now looked
up by the secret's own UUID.

A usage with a control character made the page fail (lxml refuses it in
XML text) and libvirt dropped a line break silently; the form refuses
both. An empty value set later showed libvirt's "value in
virSecretSetValue must not be NULL"; it is refused in words.
This commit is contained in:
catborise 2026-11-12 15:49:24 +03:00
parent 159049736d
commit b7724928fd
8 changed files with 104 additions and 49 deletions

View file

@ -20,6 +20,19 @@ class CreateSecretFormTests(SimpleTestCase):
self.assertEqual((form.cleaned_data["value"], form.cleaned_data["ephemeral"], form.cleaned_data["private"]),
(" pw ", False, True))
def test_a_usage_with_a_control_character_is_refused(self):
# lxml refuses it in XML text (a 500); libvirt drops a line break
# at its ends too, which stripping would hide
for usage in ("iqn.test\x01", "a\nb", "iqn.test\n", "\tiqn.test"):
with self.subTest(usage=usage):
form = AddSecret({"usage_type": "iscsi", "usage": usage})
self.assertIn("control characters", str(form.errors["usage"]))
form = AddSecret({"usage_type": "iscsi", "usage": " "})
self.assertEqual(form.errors["usage"].as_data()[0].code, "required")
form = AddSecret({"usage_type": "iscsi", "usage": " iqn.test "})
self.assertTrue(form.is_valid(), form.errors)
self.assertEqual(form.cleaned_data["usage"], "iqn.test")
class CreateSecretDialogTests(TestCase):
def test_the_dialog_offers_the_usage_types_the_form_takes(self):