blob: bcaed7a0ccb0b3c485ba3b8588ace481dd6143d0 (
plain) (
blame)
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
|
let
alice = "alice";
bob = "bob";
eve = "eve";
passwd = "pass1";
in
{
name = "user-expiry";
nodes = {
machine = {
users.users = {
${alice} = {
initialPassword = passwd;
isNormalUser = true;
expires = "1990-01-01";
};
${bob} = {
initialPassword = passwd;
isNormalUser = true;
expires = "2990-01-01";
};
${eve} = {
initialPassword = passwd;
isNormalUser = true;
};
};
};
};
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("${alice} cannot login"):
machine.wait_until_tty_matches("1", "login: ")
machine.send_chars("${alice}\n")
machine.wait_until_tty_matches("1", "Password: ")
machine.send_chars("${passwd}\n")
machine.wait_until_succeeds("journalctl --grep='account ${alice} has expired \\(account expired\\)'")
machine.wait_until_tty_matches("1", "login: ")
with subtest("${bob} can login"):
switch_to_tty(2)
machine.wait_until_tty_matches("2", "login: ")
machine.send_chars("${bob}\n")
machine.wait_until_tty_matches("2", "Password: ")
machine.send_chars("${passwd}\n")
machine.wait_until_succeeds("pgrep -u ${bob} bash")
with subtest("${eve} can login"):
switch_to_tty(3)
machine.wait_until_tty_matches("3", "login: ")
machine.send_chars("${eve}\n")
machine.wait_until_tty_matches("3", "Password: ")
machine.send_chars("${passwd}\n")
machine.wait_until_succeeds("pgrep -u ${eve} bash")
'';
}
|