1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 03:30:45 +00:00
nixpkgs/nixos/tests/user-activation-scripts.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1.2 KiB
Nix
Raw Normal View History

2021-02-15 22:40:54 +00:00
import ./make-test-python.nix ({ lib, ... }: {
name = "user-activation-scripts";
meta = with lib.maintainers; { maintainers = [ chkno ]; };
2022-03-20 23:15:30 +00:00
nodes.machine = {
2021-02-15 22:40:54 +00:00
system.userActivationScripts.foo = "mktemp ~/user-activation-ran.XXXXXX";
users.users.alice = {
initialPassword = "pass1";
isNormalUser = true;
};
systemd.user.tmpfiles.users.alice.rules = [ "r %h/file-to-remove" ];
2021-02-15 22:40:54 +00:00
};
testScript = ''
def verify_user_activation_run_count(n):
machine.succeed(
'[[ "$(find /home/alice/ -name user-activation-ran.\\* | wc -l)" == %s ]]' % n
)
machine.wait_for_unit("multi-user.target")
machine.wait_for_unit("getty@tty1.service")
machine.wait_until_tty_matches("1", "login: ")
2021-02-15 22:40:54 +00:00
machine.send_chars("alice\n")
machine.wait_until_tty_matches("1", "Password: ")
2021-02-15 22:40:54 +00:00
machine.send_chars("pass1\n")
machine.send_chars("touch login-ok\n")
machine.wait_for_file("/home/alice/login-ok")
verify_user_activation_run_count(1)
2021-02-15 22:40:54 +00:00
machine.succeed("touch /home/alice/file-to-remove")
2021-02-15 22:40:54 +00:00
machine.succeed("/run/current-system/bin/switch-to-configuration test")
verify_user_activation_run_count(2)
machine.succeed("[[ ! -f /home/alice/file-to-remove ]] || false")
2021-02-15 22:40:54 +00:00
'';
})