mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 00:46:05 +00:00
feat(instances): a VM's console settings in two cards, with a password action
Settings > Console was one horizontal form, and on a running VM its
Update button was disabled. The owner chose this layout from three
rendered options: the console type on top, then a "VNC connection" card
(listen address, keymap) and a "VNC password" card.
- The password is changed by an action: keep it, generate a new one,
set a new one or remove it. This replaces the Generate and Clear
boxes and their precedence, and an emptied field no longer removes
the password silently. The pane says whether a password is set; the
form no longer carries the password itself.
- A VNC password takes at most 8 bytes: libvirt refuses a longer one
("VNC password is 9 characters long, only 8 permitted"). Generate and
a new VM's random password now make 8 characters; they made 12, which
libvirt 11 refuses. A set password keeps its spaces.
- Every check is in the form, so a refused save changes nothing; before,
a refused password removal still saved the other settings.
- The settings can be saved while the VM runs: they are in the
persistent definition. A line says the running console keeps its
settings until the VM is shut down and started.
- The console type shown and compared is the persistent one; it was the
running VM's, so a pending switch to Serial showed VNC and a later
save could switch again.
- While the saved type is Serial, the VNC settings are not shown or
taken; choosing Serial ignores the posted VNC settings.
This commit is contained in:
parent
20cfc25367
commit
301b73155d
12 changed files with 248 additions and 126 deletions
|
|
@ -1,9 +1,9 @@
|
|||
"""
|
||||
The console settings form on the VM detail page carries the VNC password
|
||||
(PasswordInput(render_value=True)). It must only be rendered for users who may
|
||||
change console settings, which is the rule update_console enforces: a
|
||||
superuser, or an owner with both is_change and is_vnc. In particular, is_staff
|
||||
and the global view_instances permission must not reveal the VNC password.
|
||||
The console settings form is rendered only for users who may change console
|
||||
settings, which is the rule update_console enforces: a superuser, or an owner
|
||||
with both is_change and is_vnc; not for is_staff or the global view_instances
|
||||
permission. The form never carries the VNC password: it says whether one is
|
||||
set.
|
||||
"""
|
||||
from unittest.mock import PropertyMock, patch
|
||||
|
||||
|
|
@ -75,14 +75,11 @@ class ConsoleSettingsAccessTestCase(TestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
return response.content.decode()
|
||||
|
||||
def test_staff_with_view_instances_does_not_see_vnc_password(self):
|
||||
self.assertFalse(VNC_PASSWORD in self._detail_page(self.staff_viewer), "VNC password leaked")
|
||||
|
||||
def test_staff_owner_without_is_vnc_does_not_see_vnc_password(self):
|
||||
self.assertFalse(VNC_PASSWORD in self._detail_page(self.staff_owner), "VNC password leaked")
|
||||
|
||||
def test_owner_with_is_change_and_is_vnc_sees_console_settings(self):
|
||||
self.assertTrue(VNC_PASSWORD in self._detail_page(self.vnc_owner), "console settings missing")
|
||||
|
||||
def test_superuser_sees_console_settings(self):
|
||||
self.assertTrue(VNC_PASSWORD in self._detail_page(self.superuser), "console settings missing")
|
||||
def test_only_users_who_may_change_the_console_see_its_settings(self):
|
||||
form = reverse("instances:update_console", args=[self.instance.id])
|
||||
for user, shown in ((self.staff_viewer, False), (self.staff_owner, False),
|
||||
(self.vnc_owner, True), (self.superuser, True)):
|
||||
with self.subTest(user.username):
|
||||
page = self._detail_page(user)
|
||||
self.assertEqual(form in page, shown)
|
||||
self.assertNotIn(VNC_PASSWORD, page)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue