From ffcbf8c326f05f7a66563a12e57562f53af2c28b Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Wed, 4 Oct 2023 04:06:34 +0300 Subject: [PATCH] check that host key is copied in tests --- tests/from-nixos.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/from-nixos.nix b/tests/from-nixos.nix index c726dec6..ebee5b18 100644 --- a/tests/from-nixos.nix +++ b/tests/from-nixos.nix @@ -22,6 +22,11 @@ start_all() installer.succeed("mkdir -p /tmp/extra-files/var/lib/secrets") installer.succeed("echo value > /tmp/extra-files/var/lib/secrets/key") + ssh_key_path = "/etc/ssh/ssh_host_ed25519_key.pub" + ssh_key_output = installer.wait_until_succeeds(f""" + ssh -i /root/.ssh/install_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ + root@installed cat {ssh_key_path} + """) installer.succeed(""" nixos-anywhere \ -i /root/.ssh/install_key \ @@ -43,5 +48,7 @@ assert "nixos-anywhere" == hostname, f"'nixos-anywhere' != '{hostname}'" content = new_machine.succeed("cat /var/lib/secrets/key").strip() assert "value" == content, f"secret does not have expected value: {content}" + ssh_key_content = new_machine.succeed(f"cat {ssh_key_path}").strip() + assert ssh_key_content in ssh_key_output, "SSH host identity changed" ''; }