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.systemctl("start network-online.target")
32 server.wait_for_unit("network-online.target")
34 # wait for upterm port to be reachable
35 client1.wait_until_succeeds("nc -z -v server 1337")
37 # Add SSH hostkeys from the server to both clients
38 # uptermd needs an '@cert-authority entry so we need to modify the known_hosts file
39 client1.execute("mkdir -p ~/.ssh && ssh -o StrictHostKeyChecking=no -p 1337 server ls")
40 client1.execute("echo @cert-authority $(cat ~/.ssh/known_hosts) > ~/.ssh/known_hosts")
41 client2.execute("mkdir -p ~/.ssh && ssh -o StrictHostKeyChecking=no -p 1337 server ls")
42 client2.execute("echo @cert-authority $(cat ~/.ssh/known_hosts) > ~/.ssh/known_hosts")
44 client1.wait_for_unit("multi-user.target")
45 client1.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
46 client1.wait_until_tty_matches("1", "login: ")
47 client1.send_chars("root\n")
48 client1.wait_until_succeeds("pgrep -u root bash")
50 client1.execute("ssh-keygen -t ed25519 -N \"\" -f /root/.ssh/id_ed25519")
51 client1.send_chars("TERM=xterm upterm host --server ssh://server:1337 --force-command hostname -- bash > /tmp/session-details\n")
52 client1.wait_for_file("/tmp/session-details")
55 # uptermd can't connect if we don't have a keypair
56 client2.execute("ssh-keygen -t ed25519 -N \"\" -f /root/.ssh/id_ed25519")
58 # Grep the ssh connect command from the output of 'upterm host'
59 ssh_command = client1.succeed("grep 'SSH Session' /tmp/session-details | cut -d':' -f2-").strip()
61 # Connect with client2. Because we used '--force-command hostname' we should get "client1" as the output
62 output = client2.succeed(ssh_command)
64 assert output.strip() == "client1"