-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #246772 from R-VdP/nixos-user-expiry
nixos/update-users-groups: add support for account expiry
- Loading branch information
Showing
4 changed files
with
113 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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") | ||
''; | ||
} |