feat: extend test to check if a normal user can still login
This commit is contained in:
parent
a12f25aedd
commit
f4b5dae5c1
2 changed files with 38 additions and 13 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1,3 @@
|
||||||
/target
|
/target
|
||||||
|
/.nixos-test-history
|
||||||
|
/result
|
||||||
|
|
49
test.nix
49
test.nix
|
@ -13,17 +13,40 @@
|
||||||
};
|
};
|
||||||
testScript = ''
|
testScript = ''
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
machine.send_key("alt-f2")
|
|
||||||
machine.wait_until_succeeds("[ $(fgconsole) = 2 ]")
|
with subtest("create user"):
|
||||||
machine.wait_for_unit("getty@tty2.service")
|
machine.succeed("useradd -m alice")
|
||||||
machine.wait_until_succeeds("pgrep -f 'agetty.*tty2'")
|
machine.succeed("(echo foobar; echo foobar) | passwd alice")
|
||||||
machine.wait_until_tty_matches("2", "login: ")
|
|
||||||
machine.send_chars("Admin\n")
|
with subtest("Switch to tty2 and wait for agetty"):
|
||||||
machine.wait_until_tty_matches("2", "login: Admin")
|
machine.send_key("alt-f2")
|
||||||
machine.wait_until_succeeds("pgrep login")
|
machine.wait_until_succeeds("[ $(fgconsole) = 2 ]")
|
||||||
machine.wait_until_tty_matches("2", "Password: ")
|
machine.wait_for_unit("getty@tty2.service")
|
||||||
machine.send_chars("AdminPwdQ1\n")
|
machine.wait_until_succeeds("pgrep -f 'agetty.*tty2'")
|
||||||
machine.wait_until_tty_matches("2", "login: ")
|
|
||||||
machine.succeed("journalctl | grep 'log in with the honeypot credentials'")
|
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")
|
||||||
|
machine.wait_until_succeeds("pgrep login")
|
||||||
|
machine.wait_until_tty_matches("2", "Password: ")
|
||||||
|
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")
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue