python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / nixos / tests / tmate-ssh-server.nix
blobe7f94db9bfcf490decee8450e9a12bf790365671
1 import ./make-test-python.nix ({ pkgs, lib, ... }:
2 let
3   inherit (import ./ssh-keys.nix pkgs)
4     snakeOilPrivateKey snakeOilPublicKey;
6   setUpPrivateKey = name: ''
7     ${name}.succeed(
8         "mkdir -p /root/.ssh",
9         "chown 700 /root/.ssh",
10         "cat '${snakeOilPrivateKey}' > /root/.ssh/id_snakeoil",
11         "chown 600 /root/.ssh/id_snakeoil",
12     )
13     ${name}.wait_for_file("/root/.ssh/id_snakeoil")
14   '';
16   sshOpts = "-oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oIdentityFile=/root/.ssh/id_snakeoil";
20   name = "tmate-ssh-server";
21   nodes =
22     {
23       server = { ... }: {
24         services.tmate-ssh-server = {
25           enable = true;
26           port = 2223;
27         };
28       };
29       client = { ... }: {
30         environment.systemPackages = [ pkgs.tmate ];
31         services.openssh.enable = true;
32         users.users.root.openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
33       };
34       client2 = { ... }: {
35         environment.systemPackages = [ pkgs.openssh ];
36       };
37     };
38   testScript = ''
39     start_all()
41     server.wait_for_unit("tmate-ssh-server.service")
42     server.wait_for_open_port(2223)
43     server.wait_for_file("/etc/tmate-ssh-server-keys/ssh_host_ed25519_key.pub")
44     server.wait_for_file("/etc/tmate-ssh-server-keys/ssh_host_rsa_key.pub")
45     server.succeed("tmate-client-config > /tmp/tmate.conf")
46     server.wait_for_file("/tmp/tmate.conf")
48     ${setUpPrivateKey "server"}
49     client.wait_for_unit("sshd.service")
50     client.wait_for_open_port(22)
51     server.succeed("scp ${sshOpts} /tmp/tmate.conf client:/tmp/tmate.conf")
53     client.wait_for_file("/tmp/tmate.conf")
54     client.send_chars("root\n")
55     client.sleep(2)
56     client.send_chars("tmate -f /tmp/tmate.conf\n")
57     client.sleep(2)
58     client.send_chars("q")
59     client.sleep(2)
60     client.send_chars("tmate display -p '#{tmate_ssh}' > /tmp/ssh_command\n")
61     client.wait_for_file("/tmp/ssh_command")
62     ssh_cmd = client.succeed("cat /tmp/ssh_command")
64     client2.succeed("mkdir -p ~/.ssh; ssh-keyscan -p 2223 server > ~/.ssh/known_hosts")
65     client2.send_chars("root\n")
66     client2.sleep(2)
67     client2.send_chars(ssh_cmd.strip() + "\n")
68     client2.sleep(2)
69     client2.send_chars("touch /tmp/client_2\n")
71     client.wait_for_file("/tmp/client_2")
72   '';