2021-02-16 01:40:54 +03:00
|
|
|
import ./make-test-python.nix ({ lib, ... }: {
|
|
|
|
name = "user-activation-scripts";
|
|
|
|
meta = with lib.maintainers; { maintainers = [ chkno ]; };
|
|
|
|
|
2022-03-21 02:15:30 +03:00
|
|
|
nodes.machine = {
|
2021-02-16 01:40:54 +03:00
|
|
|
system.userActivationScripts.foo = "mktemp ~/user-activation-ran.XXXXXX";
|
|
|
|
users.users.alice = {
|
|
|
|
initialPassword = "pass1";
|
|
|
|
isNormalUser = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
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")
|
2022-06-04 07:22:03 +03:00
|
|
|
machine.wait_until_tty_matches("1", "login: ")
|
2021-02-16 01:40:54 +03:00
|
|
|
machine.send_chars("alice\n")
|
2022-06-04 07:22:03 +03:00
|
|
|
machine.wait_until_tty_matches("1", "Password: ")
|
2021-02-16 01:40:54 +03:00
|
|
|
machine.send_chars("pass1\n")
|
|
|
|
machine.send_chars("touch login-ok\n")
|
|
|
|
machine.wait_for_file("/home/alice/login-ok")
|
2021-02-16 02:09:30 +03:00
|
|
|
verify_user_activation_run_count(1)
|
2021-02-16 01:40:54 +03:00
|
|
|
|
|
|
|
machine.succeed("/run/current-system/bin/switch-to-configuration test")
|
2021-02-16 02:09:30 +03:00
|
|
|
verify_user_activation_run_count(2)
|
2021-02-16 01:40:54 +03:00
|
|
|
'';
|
|
|
|
})
|