vuls: init at 0.27.0
[NixPkgs.git] / nixos / tests / rkvm / default.nix
blob22425948d8bf91c2d9fb830269d910e295ed0f83
1 import ../make-test-python.nix ({ pkgs, ... }:
2 let
3   # Generated with
4   #
5   # nix shell .#rkvm --command "rkvm-certificate-gen --ip-addresses 10.0.0.1 cert.pem key.pem"
6   #
7   snakeoil-cert = ./cert.pem;
8   snakeoil-key = ./key.pem;
9 in
11   name = "rkvm";
13   nodes = {
14     server = { pkgs, ... }: {
15       imports = [ ../common/user-account.nix ];
17       virtualisation.vlans = [ 1 ];
19       networking = {
20         useNetworkd = true;
21         useDHCP = false;
22         firewall.enable = false;
23       };
25       systemd.network.networks."01-eth1" = {
26         name = "eth1";
27         networkConfig.Address = "10.0.0.1/24";
28       };
30       services.getty.autologinUser = "alice";
32       services.rkvm.server = {
33         enable = true;
34         settings = {
35           certificate = snakeoil-cert;
36           key = snakeoil-key;
37           password = "snakeoil";
38           switch-keys = [ "left-alt" "right-alt" ];
39         };
40       };
41     };
43     client = { pkgs, ... }: {
44       imports = [ ../common/user-account.nix ];
46       virtualisation.vlans = [ 1 ];
48       networking = {
49         useNetworkd = true;
50         useDHCP = false;
51         firewall.enable = false;
52       };
54       systemd.network.networks."01-eth1" = {
55         name = "eth1";
56         networkConfig.Address = "10.0.0.2/24";
57       };
59       services.getty.autologinUser = "alice";
61       services.rkvm.client = {
62         enable = true;
63         settings = {
64           server = "10.0.0.1:5258";
65           certificate = snakeoil-cert;
66           key = snakeoil-key;
67           password = "snakeoil";
68         };
69       };
70     };
71   };
73   testScript = ''
74     server.wait_for_unit("getty@tty1.service")
75     server.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
76     server.wait_for_unit("rkvm-server")
77     server.wait_for_open_port(5258)
79     client.wait_for_unit("getty@tty1.service")
80     client.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
81     client.wait_for_unit("rkvm-client")
83     server.sleep(1)
85     # Switch to client
86     server.send_key("alt-alt_r", delay=0.2)
87     server.send_chars("echo 'hello client' > /tmp/test.txt\n")
89     # Switch to server
90     server.send_key("alt-alt_r", delay=0.2)
91     server.send_chars("echo 'hello server' > /tmp/test.txt\n")
93     server.sleep(1)
95     client.systemctl("stop rkvm-client.service")
96     server.systemctl("stop rkvm-server.service")
98     server_file = server.succeed("cat /tmp/test.txt")
99     assert server_file.strip() == "hello server"
101     client_file = client.succeed("cat /tmp/test.txt")
102     assert client_file.strip() == "hello client"
103   '';