diff --git a/test/install_ssh_host_keys.nix b/test/install_ssh_host_keys.nix index 028845b..9bfd4b2 100644 --- a/test/install_ssh_host_keys.nix +++ b/test/install_ssh_host_keys.nix @@ -8,7 +8,6 @@ ( umask u=rw,g=,o= cp ${../example_keys/system1} /etc/ssh/ssh_host_ed25519_key - touch /etc/ssh/ssh_host_rsa_key ) ''; diff --git a/test/integration.nix b/test/integration.nix index 7cb840c..6954295 100644 --- a/test/integration.nix +++ b/test/integration.nix @@ -1,25 +1,22 @@ -{ -nixpkgs ? , -pkgs ? import { inherit system; config = {}; }, -system ? builtins.currentSystem -} @args: +args@{ pkgs ? , ... }: -import "${nixpkgs}/nixos/tests/make-test-python.nix" ({ pkgs, ...}: { +import "${pkgs}/nixos/tests/make-test-python.nix" +{ name = "agenix-integration"; - nodes.system1 = { config, lib, ... }: { - + nodes.system1 = { config, ... }: { imports = [ ../modules/age.nix ./install_ssh_host_keys.nix ]; - services.openssh.enable = true; - - age.secrets.passwordfile-user1 = { - file = ../example/passwordfile-user1.age; + services.openssh = { + enable = true; + hostKeys = [{ type = "ed25519"; path = "/etc/ssh/ssh_host_ed25519_key"; }]; }; + age.secrets.passwordfile-user1.file = ../example/passwordfile-user1.age; + users = { mutableUsers = false; @@ -30,29 +27,30 @@ import "${nixpkgs}/nixos/tests/make-test-python.nix" ({ pkgs, ...}: { }; }; }; - }; testScript = - let - user = "user1"; - password = "password1234"; - in '' - system1.wait_for_unit("multi-user.target") - system1.wait_until_succeeds("pgrep -f 'agetty.*tty1'") - system1.sleep(2) - system1.send_key("alt-f2") - system1.wait_until_succeeds("[ $(fgconsole) = 2 ]") - system1.wait_for_unit("getty@tty2.service") - system1.wait_until_succeeds("pgrep -f 'agetty.*tty2'") - system1.wait_until_tty_matches(2, "login: ") - system1.send_chars("${user}\n") - system1.wait_until_tty_matches(2, "login: ${user}") - system1.wait_until_succeeds("pgrep login") - system1.sleep(2) - system1.send_chars("${password}\n") - system1.send_chars("whoami > /tmp/1\n") - system1.wait_for_file("/tmp/1") - assert "${user}" in system1.succeed("cat /tmp/1") - ''; -}) args + let + user = "user1"; + password = "password1234"; + in + '' + system1.wait_for_unit("multi-user.target") + system1.wait_until_succeeds("pgrep -f 'agetty.*tty1'") + system1.sleep(2) + system1.send_key("alt-f2") + system1.wait_until_succeeds("[ $(fgconsole) = 2 ]") + system1.wait_for_unit("getty@tty2.service") + system1.wait_until_succeeds("pgrep -f 'agetty.*tty2'") + system1.wait_until_tty_matches(2, "login: ") + system1.send_chars("${user}\n") + system1.wait_until_tty_matches(2, "login: ${user}") + system1.wait_until_succeeds("pgrep login") + system1.sleep(2) + system1.send_chars("${password}\n") + system1.send_chars("whoami > /tmp/1\n") + system1.wait_for_file("/tmp/1") + assert "${user}" in system1.succeed("cat /tmp/1") + ''; +} + args