agenix/test/integration.nix

57 lines
1.5 KiB
Nix
Raw Normal View History

2022-01-18 22:22:15 +03:00
args@{ pkgs ? <nixpkgs>, ... }:
2021-05-10 00:22:48 +03:00
2022-01-18 22:22:15 +03:00
import "${pkgs}/nixos/tests/make-test-python.nix"
{
2021-05-10 00:22:48 +03:00
name = "agenix-integration";
2022-01-18 22:22:15 +03:00
nodes.system1 = { config, ... }: {
2021-05-10 00:22:48 +03:00
imports = [
../modules/age.nix
./install_ssh_host_keys.nix
];
2022-01-18 22:22:15 +03:00
services.openssh = {
enable = true;
hostKeys = [{ type = "ed25519"; path = "/etc/ssh/ssh_host_ed25519_key"; }];
2021-05-10 00:22:48 +03:00
};
2022-01-18 22:22:15 +03:00
age.secrets.passwordfile-user1.file = ../example/passwordfile-user1.age;
2021-05-10 00:22:48 +03:00
users = {
mutableUsers = false;
users = {
user1 = {
isNormalUser = true;
passwordFile = config.age.secrets.passwordfile-user1.path;
};
};
};
};
testScript =
2022-01-18 22:22:15 +03:00
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