1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-01 16:36:06 +00:00

fix(instances): the delete page names the host only where hosts are shown

The confirmation page put "on <host>" in its heading for every owner who
may delete the VM, while the VM list and page show the host only to
superusers and users with view_instances.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
catborise 2026-11-09 13:54:28 +03:00
parent 0cee65805d
commit f18287d3b8
2 changed files with 11 additions and 1 deletions

View file

@ -236,6 +236,16 @@ class DestroyOrderTestCase(TransactionTestCase):
response = self.client.get(reverse("instances:destroy", args=[self.instance.id]))
self.assertEqual(b"Its TPM state is deleted" in response.content, shown)
def test_the_confirmation_page_names_the_host_only_to_whom_the_app_shows_hosts(self):
owner = get_user_model().objects.create_user("destroy_owner", password="pw")
self.instance.userinstance_set.create(user=owner, is_delete=True)
for user, shown in ((self.admin, True), (owner, False)):
with self.subTest(user=user.username), patch("instances.models.wvmInstance"):
self.client.force_login(user)
response = self.client.get(reverse("instances:destroy", args=[self.instance.id]))
self.assertEqual(response.status_code, 200)
self.assertEqual("on destroy-compute" in response.content.decode(), shown)
def test_the_confirmation_page_of_a_paused_vm_offers_the_form(self):
with patch("instances.models.wvmInstance") as wvm:
wvm.return_value.get_status.return_value = 3 # paused