mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-21 08:01:39 +01:00
The demo guest is what the command `run-kde` starts, so it should not stop working between the times somebody runs it by hand. The suite `run-kde` puts the guest module, nix/dev/run-kde.nix, on the session node, as the rdp suite does with krdp.nix, and checks what only a booted session can say: the demo opens two Konsole windows, Kate and Dolphin and komorebi tiles them clear of the panel, the cheat sheet is a window that is not a tile, what it shows of `komorebic check` has no error, and KWin says what it draws with. The node makes the directory the host shares as the guest finds it once it has mounted it: owned by a user the guest does not have, with a password and a public key in it. The suite checks that the guest takes them as root before the login, that ssh lets in that key and no other, that KRDP starts by itself and listens, and that a client with the password is let in and shows the display. The client of those RDP checks moves from the rdp suite into the library as RdpClient, with unit tests against the fake machine, so that both suites run the same checks; the machine protocol gains copy_from_machine for it.
58 lines
2.3 KiB
Python
58 lines
2.3 KiB
Python
# KRDP, Plasma's RDP server, runs in the Plasma session of the session node as the guest to develop
|
|
# in runs it (nix/dev/krdp.nix), and a client logs in and gets a picture of the desktop. What only a
|
|
# real session can tell: that the unit starts in the session once it has a password, that KWin lets
|
|
# KRDP have the screen without asking, that a client with the password is let in and one without
|
|
# it is not, and that the picture the client gets is what the display shows.
|
|
#
|
|
# The client is FreeRDP's, on an X server of its own (`komorebi_vm.RdpClient`), so its picture can be
|
|
# read back and compared with a screenshot of the display. The suite `run-kde` runs the same checks
|
|
# with a password that the demo guest takes from the host's directory.
|
|
import secrets
|
|
import time
|
|
|
|
from komorebi_vm import Checks, Kde, RdpClient
|
|
from komorebi_vm.rdp import colors
|
|
|
|
PASSWORD_FILE = "/home/komorebi/.config/komorebi-vm/rdp-password"
|
|
|
|
start_all()
|
|
machine.wait_for_unit("multi-user.target")
|
|
|
|
checks = Checks()
|
|
kde = Kde.session(machine, scale=SCALE)
|
|
rdp = RdpClient(machine, kde)
|
|
|
|
|
|
def active(unit: str) -> bool:
|
|
return kde.run(f"systemctl --user is-active --quiet {unit}")[0] == 0
|
|
|
|
|
|
checks.check("komorebi runs in the session", kde.wait_for(lambda: active("komorebi"), timeout=60))
|
|
checks.check("with no password, KRDP does not start", not active("krdp"))
|
|
|
|
password = secrets.token_hex(16)
|
|
kde.as_user(
|
|
f"umask 077 && mkdir -p $(dirname {PASSWORD_FILE}) && printf %s {password} > {PASSWORD_FILE}"
|
|
)
|
|
kde.systemctl("start", "krdp.service")
|
|
|
|
checks.check("with a password, KRDP listens on port 3389", kde.wait_for(rdp.listening, timeout=60))
|
|
|
|
rdp.start_x_server()
|
|
|
|
checks.check("a client with the password is let in", rdp.logs_in(password))
|
|
checks.check("a client with another password is not", not rdp.logs_in("not-" + password))
|
|
|
|
started = time.monotonic()
|
|
rdp.connect(password)
|
|
checks.check("the client's picture is the display", rdp.shows_display())
|
|
print(f"after {time.monotonic() - started:.1f}s")
|
|
|
|
remote = rdp.picture()
|
|
print(f"the client's picture: {remote.size}, {colors(remote)} colors")
|
|
remote.save(machine.out_dir / "client.png")
|
|
print(machine.execute("journalctl --no-pager _SYSTEMD_USER_UNIT=krdp.service | tail -n 20")[1])
|
|
print(machine.execute("tail -n 20 /tmp/xfreerdp.log")[1])
|
|
|
|
checks.finish()
|