about summary refs log tree commit diff
path: root/nixos/tests/xrdp.nix
blob: f277d4b79525619130589a5147f75a9ccec5ad49 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import ./make-test-python.nix ({ pkgs, ...} : {
  name = "xrdp";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ ];
  };

  nodes = {
    server = { pkgs, ... }: {
      imports = [ ./common/user-account.nix ];
      services.xrdp.enable = true;
      services.xrdp.defaultWindowManager = "${pkgs.xterm}/bin/xterm";
      networking.firewall.allowedTCPPorts = [ 3389 ];
    };

    client = { pkgs, ... }: {
      imports = [ ./common/x11.nix ./common/user-account.nix ];
      test-support.displayManager.auto.user = "alice";
      environment.systemPackages = [ pkgs.freerdp ];
      services.xrdp.enable = true;
      services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm";
    };
  };

  testScript = { nodes, ... }: let
    user = nodes.client.config.users.users.alice;
  in ''
    start_all()

    client.wait_for_x()
    client.wait_for_file("${user.home}/.Xauthority")
    client.succeed("xauth merge ${user.home}/.Xauthority")

    client.sleep(5)

    client.execute("xterm >&2 &")
    client.sleep(1)
    client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:127.0.0.1 /u:${user.name} /p:${user.password}\n")
    client.sleep(5)
    client.screenshot("localrdp")

    client.execute("xterm >&2 &")
    client.sleep(1)
    client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password}\n")
    client.sleep(5)
    client.screenshot("remoterdp")
  '';
})