nixos-anywhere/tests/from-nixos-with-sudo.nix

40 lines
1.5 KiB
Nix
Raw Normal View History

2022-12-30 20:51:46 +03:00
(import ./lib/test-base.nix) {
2022-12-31 15:34:50 +03:00
name = "from-nixos-with-sudo";
2022-12-30 20:51:46 +03:00
nodes = {
installer = ./modules/installer.nix;
installed = {
services.openssh.enable = true;
virtualisation.memorySize = 4096;
users.users.nixos = {
isNormalUser = true;
openssh.authorizedKeys.keyFiles = [ ./modules/ssh-keys/ssh.pub ];
extraGroups = [ "wheel" ];
};
security.sudo.enable = true;
security.sudo.wheelNeedsPassword = false;
};
2022-12-30 20:51:46 +03:00
};
testScript = ''
start_all()
installer.succeed("echo super-secret > /tmp/disk-1.key")
output = installer.succeed("""
2023-02-01 21:49:46 +03:00
nixos-anywhere \
2022-12-30 20:51:46 +03:00
--debug \
2023-02-01 21:49:46 +03:00
--kexec /etc/nixos-anywhere/kexec-installer \
2022-12-30 20:51:46 +03:00
--stop-after-disko \
--disk-encryption-keys /tmp/disk-1.key /tmp/disk-1.key \
--disk-encryption-keys /tmp/disk-2.key <(echo another-secret) \
2023-02-01 21:49:46 +03:00
--store-paths /etc/nixos-anywhere/disko /etc/nixos-anywhere/system-to-install \
2022-12-30 20:51:46 +03:00
nixos@installed >&2
echo "disk-1.key: '$(ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
root@installed cat /tmp/disk-1.key)'"
echo "disk-2.key: '$(ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
root@installed cat /tmp/disk-2.key)'"
2022-12-30 20:51:46 +03:00
""")
assert "disk-1.key: 'super-secret'" in output, f"output does not contain expected values: {output}"
assert "disk-2.key: 'another-secret'" in output, f"output does not contain expected values: {output}"
2022-12-30 20:51:46 +03:00
'';
}