mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 16:36:06 +00:00
fix(console): a VNC console whose access check fails is closed, not left unchecked
novncd checks every 10 seconds that an open VNC console's user may still open it. An error in that check, such as a locked database, ended the checking thread and left the session open for good, unchecked: a user removed from the VM afterwards kept its console. The session now ends with a warning in the log, as a serial console's worker does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
16ad625cda
commit
417be11616
2 changed files with 22 additions and 6 deletions
|
|
@ -16,6 +16,7 @@ from django.contrib.auth import get_user_model
|
|||
from django.contrib.auth.models import Permission
|
||||
from django.core.signing import TimestampSigner
|
||||
from django.conf import settings
|
||||
from django.db import OperationalError
|
||||
from django.test import TestCase, override_settings
|
||||
from instances.models import Instance
|
||||
from libvirt import libvirtError
|
||||
|
|
@ -298,6 +299,15 @@ class NovncdDaemonLogicTestCase(TestCase):
|
|||
may_still_open.assert_called_with(7, vm)
|
||||
tsock.shutdown.assert_called_once_with(novncd_mod.socket.SHUT_RDWR)
|
||||
|
||||
def test_a_vnc_session_whose_access_cannot_be_checked_ends(self):
|
||||
tsock, ended = MagicMock(), MagicMock()
|
||||
ended.wait.return_value = False
|
||||
with patch.object(novncd_mod, "may_still_open", side_effect=OperationalError("database is locked")), \
|
||||
self.assertLogs(level="WARNING") as logs:
|
||||
novncd_mod.end_when_refused(MagicMock(), 7, tsock, ended)
|
||||
tsock.shutdown.assert_called_once_with(novncd_mod.socket.SHUT_RDWR)
|
||||
self.assertIn("database is locked", logs.output[0])
|
||||
|
||||
def test_a_token_of_a_serial_console_does_not_open_a_vnc_console(self):
|
||||
user = get_user_model().objects.create_user("vnc-owner", password="pw")
|
||||
compute = Compute.objects.create(name="novnc-type-compute", hostname="127.0.0.1", login="root", password="", type=1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue