1 import ./make-test-python.nix ({ lib, ... }: {
4 meta = with lib.maintainers; {
5 maintainers = [ rnhmjoj ];
8 nodes.machine = { ... }: {
9 virtualisation.useBootLoader = true;
11 boot.loader.timeout = null;
14 users.alice.password = "supersecret";
16 # OCR is not accurate enough
17 extraConfig = "serial; terminal_output serial";
22 def grub_login_as(user, password):
24 Enters user and password to log into GRUB
26 machine.wait_for_console_text("Enter username:")
27 machine.send_chars(user + "\n")
28 machine.wait_for_console_text("Enter password:")
29 machine.send_chars(password + "\n")
32 def grub_select_all_configurations():
34 Selects "All configurations" from the GRUB menu
35 to trigger a login request.
37 machine.send_monitor_command("sendkey down")
38 machine.send_monitor_command("sendkey ret")
43 # wait for grub screen
44 machine.wait_for_console_text("GNU GRUB")
46 grub_select_all_configurations()
47 with subtest("Invalid credentials are rejected"):
48 grub_login_as("wronguser", "wrongsecret")
49 machine.wait_for_console_text("error: access denied.")
51 grub_select_all_configurations()
52 with subtest("Valid credentials are accepted"):
53 grub_login_as("alice", "supersecret")
54 machine.send_chars("\n") # press enter to boot
55 machine.wait_for_console_text("Linux version")
57 with subtest("Machine boots correctly"):
58 machine.wait_for_unit("multi-user.target")