summary refs log tree commit diff
path: root/nixos/tests/nix-ssh-serve.nix
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2018-02-28 16:55:00 -0500
committerShea Levy <shea@shealevy.com>2018-02-28 16:55:00 -0500
commit4de72b90f36641c81b19b44b4de0b63cabbf83aa (patch)
tree05a99e12433a8993944435ae5d566e5cbead3a83 /nixos/tests/nix-ssh-serve.nix
parentedf0a762117c589eece24b5cbcef11f0ebcc9011 (diff)
downloadnixlib-4de72b90f36641c81b19b44b4de0b63cabbf83aa.tar
nixlib-4de72b90f36641c81b19b44b4de0b63cabbf83aa.tar.gz
nixlib-4de72b90f36641c81b19b44b4de0b63cabbf83aa.tar.bz2
nixlib-4de72b90f36641c81b19b44b4de0b63cabbf83aa.tar.lz
nixlib-4de72b90f36641c81b19b44b4de0b63cabbf83aa.tar.xz
nixlib-4de72b90f36641c81b19b44b4de0b63cabbf83aa.tar.zst
nixlib-4de72b90f36641c81b19b44b4de0b63cabbf83aa.zip
nixos: nix.sshServe: Support ssh-ng.
Diffstat (limited to 'nixos/tests/nix-ssh-serve.nix')
-rw-r--r--nixos/tests/nix-ssh-serve.nix39
1 files changed, 39 insertions, 0 deletions
diff --git a/nixos/tests/nix-ssh-serve.nix b/nixos/tests/nix-ssh-serve.nix
new file mode 100644
index 000000000000..aa366d8612d7
--- /dev/null
+++ b/nixos/tests/nix-ssh-serve.nix
@@ -0,0 +1,39 @@
+import ./make-test.nix ({ pkgs, lib, ... }:
+let inherit (import ./ssh-keys.nix pkgs)
+      snakeOilPrivateKey snakeOilPublicKey;
+    ssh-config = builtins.toFile "ssh.conf" ''
+      UserKnownHostsFile=/dev/null
+      StrictHostKeyChecking=no
+    '';
+in
+   { name = "nix-ssh-serve";
+     meta.maintainers = [ lib.maintainers.shlevy ];
+     nodes =
+       { server.nix.sshServe =
+           { enable = true;
+             keys = [ snakeOilPublicKey ];
+             protocol = "ssh-ng";
+           };
+         server.nix.package = pkgs.nixUnstable;
+         client.nix.package = pkgs.nixUnstable;
+       };
+     testScript = ''
+       startAll;
+
+       $client->succeed("mkdir -m 700 /root/.ssh");
+       $client->copyFileFromHost("${ssh-config}", "/root/.ssh/config");
+       $client->succeed("cat ${snakeOilPrivateKey} > /root/.ssh/id_ecdsa");
+       $client->succeed("chmod 600 /root/.ssh/id_ecdsa");
+
+       $client->succeed("nix-store --add /etc/machine-id > mach-id-path");
+
+       $server->waitForUnit("sshd");
+
+       $client->fail("diff /root/other-store\$(cat mach-id-path) /etc/machine-id");
+       # Currently due to shared store this is a noop :(
+       $client->succeed("nix copy --to ssh-ng://nix-ssh\@server \$(cat mach-id-path)");
+       $client->succeed("nix-store --realise \$(cat mach-id-path) --store /root/other-store --substituters ssh-ng://nix-ssh\@server");
+       $client->succeed("diff /root/other-store\$(cat mach-id-path) /etc/machine-id");
+     '';
+   }
+)