summary refs log tree commit diff
path: root/nixos/tests/openssh.nix
diff options
context:
space:
mode:
authorGraham Christensen <graham@grahamc.com>2016-12-29 09:49:43 -0500
committerGraham Christensen <graham@grahamc.com>2016-12-29 17:04:52 -0500
commitbf659128a031842a479ea1cda8ca62772b23e6de (patch)
treea458ca5c252cfb277294bb8a8b16d204c85b3e35 /nixos/tests/openssh.nix
parent8ed4c8b73bee52f04499500020d4a0a750501789 (diff)
downloadnixlib-bf659128a031842a479ea1cda8ca62772b23e6de.tar
nixlib-bf659128a031842a479ea1cda8ca62772b23e6de.tar.gz
nixlib-bf659128a031842a479ea1cda8ca62772b23e6de.tar.bz2
nixlib-bf659128a031842a479ea1cda8ca62772b23e6de.tar.lz
nixlib-bf659128a031842a479ea1cda8ca62772b23e6de.tar.xz
nixlib-bf659128a031842a479ea1cda8ca62772b23e6de.tar.zst
nixlib-bf659128a031842a479ea1cda8ca62772b23e6de.zip
openssh: test that startWhenNeeded works
Diffstat (limited to 'nixos/tests/openssh.nix')
-rw-r--r--nixos/tests/openssh.nix23
1 files changed, 23 insertions, 0 deletions
diff --git a/nixos/tests/openssh.nix b/nixos/tests/openssh.nix
index 390363b88e21..291544996889 100644
--- a/nixos/tests/openssh.nix
+++ b/nixos/tests/openssh.nix
@@ -35,6 +35,18 @@ in {
         ];
       };
 
+    server_lazy =
+      { config, pkgs, ... }:
+
+      {
+        services.openssh = { enable = true; startWhenNeeded = true; };
+        security.pam.services.sshd.limits =
+          [ { domain = "*"; item = "memlock"; type = "-"; value = 1024; } ];
+        users.extraUsers.root.openssh.authorizedKeys.keys = [
+          snakeOilPublicKey
+        ];
+      };
+
     client =
       { config, pkgs, ... }: { };
 
@@ -50,6 +62,8 @@ in {
     subtest "manual-authkey", sub {
       $server->succeed("mkdir -m 700 /root/.ssh");
       $server->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
+      $server_lazy->succeed("mkdir -m 700 /root/.ssh");
+      $server_lazy->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");
 
       $client->succeed("mkdir -m 700 /root/.ssh");
       $client->copyFileFromHost("key", "/root/.ssh/id_ed25519");
@@ -58,6 +72,10 @@ in {
       $client->waitForUnit("network.target");
       $client->succeed("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server 'echo hello world' >&2");
       $client->succeed("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server 'ulimit -l' | grep 1024");
+
+      $client->succeed("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server_lazy 'echo hello world' >&2");
+      $client->succeed("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server_lazy 'ulimit -l' | grep 1024");
+
     };
 
     subtest "configured-authkey", sub {
@@ -66,6 +84,11 @@ in {
       $client->succeed("ssh -o UserKnownHostsFile=/dev/null" .
                        " -o StrictHostKeyChecking=no -i privkey.snakeoil" .
                        " server true");
+
+      $client->succeed("ssh -o UserKnownHostsFile=/dev/null" .
+                       " -o StrictHostKeyChecking=no -i privkey.snakeoil" .
+                       " server_lazy true");
+
     };
   '';
 })