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