1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-09 19:56:48 +00:00

fix(console): the console daemons hold to what the console page allowed

The token now names the console type it was made for: novncd accepts only
a VNC page's token and socketiod only a serial page's, so a VNC page's
token no longer opens the serial console without the VNC password.

A VNC session re-checks every 10 s, as the serial one did, that its user
may still open the console; a deactivated user or a removed owner loses
it. The check (may_still_open) moves to console.tokens for both daemons.
This commit is contained in:
catborise 2026-11-05 15:49:31 +03:00
parent f670ee7333
commit 458074df82
10 changed files with 110 additions and 74 deletions

View file

@ -13,6 +13,7 @@ from django.test import TestCase as DjangoTestCase
from accounts.models import UserInstance
from computes.models import Compute
from console import tokens
from instances.models import Instance
CONSOLECALLBACK = Path(__file__).resolve().parent.parent.parent / "conf" / "daemon" / "consolecallback"
@ -100,7 +101,7 @@ class AccessTests(DjangoTestCase):
vm = Instance.objects.create(compute=compute, name="vm-a", uuid="11111111-0000-0000-0000-000000000009")
owner = get_user_model().objects.create_user("owner", password="pw")
ownership = UserInstance.objects.create(user=owner, instance=vm)
with patch.object(cb.db.connection, "close"): # the test's transaction keeps its connection
with patch.object(tokens.db.connection, "close"): # the test's transaction keeps its connection
self.assertTrue(cb.may_still_open(owner.pk, vm))
ownership.delete()
self.assertFalse(cb.may_still_open(owner.pk, vm))