nixos/tests/shadow: ensure hashedPassword takes precedence over initialHashedPassword
This commit is contained in:
parent
bfa0bff644
commit
5508000ddf
1 changed files with 23 additions and 0 deletions
|
@ -5,6 +5,7 @@ let
|
|||
password4 = "asdf123";
|
||||
hashed_bcrypt = "$2b$05$8xIEflrk2RxQtcVXbGIxs.Vl0x7dF1/JSv3cyX6JJt0npzkTCWvxK"; # fnord
|
||||
hashed_yeshash = "$y$j9T$d8Z4EAf8P1SvM/aDFbxMS0$VnTXMp/Hnc7QdCBEaLTq5ZFOAFo2/PM0/xEAFuOE88."; # fnord
|
||||
hashed_sha512crypt = "$6$ymzs8WINZ5wGwQcV$VC2S0cQiX8NVukOLymysTPn4v1zJoJp3NGyhnqyv/dAf4NWZsBWYveQcj6gEJr4ZUjRBRjM0Pj1L8TCQ8hUUp0"; # meow
|
||||
in import ./make-test-python.nix ({ pkgs, ... }: {
|
||||
name = "shadow";
|
||||
meta = with pkgs.lib.maintainers; { maintainers = [ nequissimus ]; };
|
||||
|
@ -39,6 +40,12 @@ in import ./make-test-python.nix ({ pkgs, ... }: {
|
|||
hashedPassword = hashed_yeshash;
|
||||
shell = pkgs.bash;
|
||||
};
|
||||
users.leo = {
|
||||
isNormalUser = true;
|
||||
initialHashedPassword = "!";
|
||||
hashedPassword = hashed_sha512crypt; # should take precedence over initialHashedPassword
|
||||
shell = pkgs.bash;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -145,5 +152,21 @@ in import ./make-test-python.nix ({ pkgs, ... }: {
|
|||
print(shadow.succeed(f"cat /tmp/{u}"))
|
||||
assert u in shadow.succeed(f"cat /tmp/{u}")
|
||||
shadow.send_chars("logout\n")
|
||||
|
||||
with subtest("Ensure hashedPassword does not get overridden by initialHashedPassword"):
|
||||
shadow.send_key("alt-f6")
|
||||
shadow.wait_until_succeeds("[ $(fgconsole) = 6 ]")
|
||||
shadow.wait_for_unit("getty@tty6.service")
|
||||
shadow.wait_until_succeeds("pgrep -f 'agetty.*tty6'")
|
||||
shadow.wait_until_tty_matches("6", "login: ")
|
||||
shadow.send_chars("leo\n")
|
||||
shadow.wait_until_tty_matches("6", "login: leo")
|
||||
shadow.wait_until_succeeds("pgrep login")
|
||||
shadow.sleep(2)
|
||||
shadow.send_chars("meow\n")
|
||||
shadow.send_chars("whoami > /tmp/leo\n")
|
||||
shadow.wait_for_file("/tmp/leo")
|
||||
assert "leo" in shadow.succeed("cat /tmp/leo")
|
||||
shadow.send_chars("logout\n")
|
||||
'';
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue