1 import ./make-test-python.nix ({ pkgs, ...}:
5 environment.systemPackages = [ pkgs.upterm ];
10 meta = with pkgs.lib.maintainers; {
11 maintainers = [ fleaz ];
15 server = {config, ...}: {
30 server.wait_for_unit("uptermd.service")
31 server.wait_for_unit("network-online.target")
33 # wait for upterm port to be reachable
34 client1.wait_until_succeeds("nc -z -v server 1337")
36 # Add SSH hostkeys from the server to both clients
37 # uptermd needs an '@cert-authority entry so we need to modify the known_hosts file
38 client1.execute("mkdir -p ~/.ssh && ssh -o StrictHostKeyChecking=no -p 1337 server ls")
39 client1.execute("echo @cert-authority $(cat ~/.ssh/known_hosts) > ~/.ssh/known_hosts")
40 client2.execute("mkdir -p ~/.ssh && ssh -o StrictHostKeyChecking=no -p 1337 server ls")
41 client2.execute("echo @cert-authority $(cat ~/.ssh/known_hosts) > ~/.ssh/known_hosts")
43 client1.wait_for_unit("multi-user.target")
44 client1.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
45 client1.wait_until_tty_matches("1", "login: ")
46 client1.send_chars("root\n")
47 client1.wait_until_succeeds("pgrep -u root bash")
49 client1.execute("ssh-keygen -t ed25519 -N \"\" -f /root/.ssh/id_ed25519")
50 client1.send_chars("TERM=xterm upterm host --server ssh://server:1337 --force-command hostname -- bash > /tmp/session-details\n")
51 client1.wait_for_file("/tmp/session-details")
54 # uptermd can't connect if we don't have a keypair
55 client2.execute("ssh-keygen -t ed25519 -N \"\" -f /root/.ssh/id_ed25519")
57 # Grep the ssh connect command from the output of 'upterm host'
58 ssh_command = client1.succeed("grep 'SSH Session' /tmp/session-details | cut -d':' -f2-").strip()
60 # Connect with client2. Because we used '--force-command hostname' we should get "client1" as the output
61 output = client2.succeed(ssh_command)
63 assert output.strip() == "client1"