feat: extend test to check if a normal user can still login

This commit is contained in:
Tim Schubert 2025-01-04 15:14:09 +01:00
parent a12f25aedd
commit f4b5dae5c1
Signed by: dadada
SSH key fingerprint: SHA256:bFAjFH3hR8zRBaJjzQDjc3o4jqoq5EZ87l+KXEjxIz0
2 changed files with 38 additions and 13 deletions

2
.gitignore vendored
View file

@ -1 +1,3 @@
/target
/.nixos-test-history
/result

View file

@ -13,10 +13,18 @@
};
testScript = ''
machine.wait_for_unit("multi-user.target")
with subtest("create user"):
machine.succeed("useradd -m alice")
machine.succeed("(echo foobar; echo foobar) | passwd alice")
with subtest("Switch to tty2 and wait for agetty"):
machine.send_key("alt-f2")
machine.wait_until_succeeds("[ $(fgconsole) = 2 ]")
machine.wait_for_unit("getty@tty2.service")
machine.wait_until_succeeds("pgrep -f 'agetty.*tty2'")
with subtest("Log in with honeypot credentials should fail and be logged"):
machine.wait_until_tty_matches("2", "login: ")
machine.send_chars("Admin\n")
machine.wait_until_tty_matches("2", "login: Admin")
@ -25,5 +33,20 @@
machine.send_chars("AdminPwdQ1\n")
machine.wait_until_tty_matches("2", "login: ")
machine.succeed("journalctl | grep 'log in with the honeypot credentials'")
with subtest("Switch to tty3 and wait for agetty"):
machine.send_key("alt-f3")
machine.wait_until_succeeds("[ $(fgconsole) = 3 ]")
machine.wait_for_unit("getty@tty3.service")
machine.wait_until_succeeds("pgrep -f 'agetty.*tty3'")
with subtest("Log in as alice on a virtual console should still work"):
machine.wait_until_tty_matches("3", "login: ")
machine.send_chars("alice\n")
machine.wait_until_tty_matches("3", "login: alice")
machine.wait_until_succeeds("pgrep login")
machine.wait_until_tty_matches("3", "Password: ")
machine.send_chars("foobar\n")
machine.wait_until_succeeds("pgrep -u alice bash")
'';
}