at master 2.4 kB view raw
1let 2 normal-enabled = "username-normal-enabled"; 3 normal-disabled = "username-normal-disabled"; 4 system-enabled = "username-system-enabled"; 5 system-disabled = "username-system-disabled"; 6 passwd = "enableOptionPasswd"; 7in 8{ 9 name = "user-enable-option"; 10 11 nodes.machine = { 12 users = { 13 groups.test-group = { }; 14 users = { 15 # User is enabled (default behaviour). 16 ${normal-enabled} = { 17 enable = true; 18 isNormalUser = true; 19 initialPassword = passwd; 20 }; 21 22 # User is disabled. 23 ${normal-disabled} = { 24 enable = false; 25 isNormalUser = true; 26 initialPassword = passwd; 27 }; 28 29 # User is a system user, and is enabled. 30 ${system-enabled} = { 31 enable = true; 32 isSystemUser = true; 33 initialPassword = passwd; 34 group = "test-group"; 35 }; 36 37 # User is a system user, and is disabled. 38 ${system-disabled} = { 39 enable = false; 40 isSystemUser = true; 41 initialPassword = passwd; 42 group = "test-group"; 43 }; 44 }; 45 }; 46 }; 47 48 testScript = '' 49 def switch_to_tty(tty_number): 50 machine.fail(f"pgrep -f 'agetty.*tty{tty_number}'") 51 machine.send_key(f"alt-f{tty_number}") 52 machine.wait_until_succeeds(f"[ $(fgconsole) = {tty_number} ]") 53 machine.wait_for_unit(f"getty@tty{tty_number}.service") 54 machine.wait_until_succeeds(f"pgrep -f 'agetty.*tty{tty_number}'") 55 56 machine.wait_for_unit("multi-user.target") 57 machine.wait_for_unit("getty@tty1.service") 58 59 with subtest("${normal-enabled} exists"): 60 check_fn = "id ${normal-enabled}" 61 machine.succeed(check_fn) 62 machine.wait_until_tty_matches("1", "login: ") 63 machine.send_chars("${normal-enabled}\n") 64 machine.wait_until_tty_matches("1", "Password: ") 65 machine.send_chars("${passwd}\n") 66 67 with subtest("${normal-disabled} does not exist"): 68 switch_to_tty(2) 69 check_fn = "id ${normal-disabled}" 70 machine.fail(check_fn) 71 72 with subtest("${system-enabled} exists"): 73 switch_to_tty(3) 74 check_fn = "id ${system-enabled}" 75 machine.succeed(check_fn) 76 77 with subtest("${system-disabled} does not exist"): 78 switch_to_tty(4) 79 check_fn = "id ${system-disabled}" 80 machine.fail(check_fn) 81 ''; 82}