From 20ba2b49fb37b6b980f7966b0cabf3d4563ad8ea Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Fri, 17 Oct 2025 15:13:37 +0200 Subject: [PATCH] testing: mock ssh during nix-copy prompt test we don't need full ssh, we only need to know something makes it onto the terminal. Change-Id: Ic31808e10e1b876b35d0dbdeee0b5ede7b5b9883 --- tests/nixos/nix-copy.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/nixos/nix-copy.nix b/tests/nixos/nix-copy.nix index bb4363021..084a6cbda 100644 --- a/tests/nixos/nix-copy.nix +++ b/tests/nixos/nix-copy.nix @@ -12,6 +12,21 @@ let pkgC = pkgs.hello; pkgD = pkgs.tmux; + # fake SSH executable that simulates interaction with the tty. + # ssh does this for password prompts and host key confirmation + fakeSSH = pkgs.writeTextFile { + name = "fake-ssh"; + text = '' + #!${pkgs.runtimeShell} + + set -euo pipefail + echo "fake-ssh ran" >/dev/tty + exit 1 + ''; + executable = true; + destination = "/bin/ssh"; + }; + in { name = "nix-copy"; @@ -70,7 +85,7 @@ in { # requires some proper cli automation, which we do not have. however, since ssh interacts with # /dev/tty directly and the host key message goes there too, we don't even need to check this. server.fail("nix-store --check-validity ${pkgA}") - client.succeed("echo | script -f /dev/stdout -c 'nix copy --to ssh://server ${pkgA}' | grep 'continue connecting'") + client.succeed("echo | script -f /dev/stdout -c 'PATH=\"${fakeSSH}/bin:$PATH\" nix copy --to ssh://server ${pkgA}' | grep 'fake-ssh ran'") client.copy_from_host("key", "/root/.ssh/id_ed25519.setup") client.succeed("chmod 600 /root/.ssh/id_ed25519.setup")