3
0
Fork 0
forked from mirrors/nixpkgs

nixos/tests/shadow: add switch user subtest

This commit is contained in:
Milan Pässler 2021-01-03 13:53:34 +01:00 committed by Frederik Rietdijk
parent 018072ea22
commit 12f3e2c42c

View file

@ -2,6 +2,7 @@ let
password1 = "foobar";
password2 = "helloworld";
password3 = "bazqux";
password4 = "asdf123";
in import ./make-test-python.nix ({ pkgs, ... }: {
name = "shadow";
meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ nequissimus ]; };
@ -19,6 +20,10 @@ in import ./make-test-python.nix ({ pkgs, ... }: {
password = password2;
shell = pkgs.shadow;
};
users.ash = {
password = password4;
shell = pkgs.bash;
};
};
};
@ -41,6 +46,15 @@ in import ./make-test-python.nix ({ pkgs, ... }: {
shadow.wait_for_file("/tmp/1")
assert "emma" in shadow.succeed("cat /tmp/1")
with subtest("Switch user"):
shadow.send_chars("su - ash\n")
shadow.sleep(2)
shadow.send_chars("${password4}\n")
shadow.sleep(2)
shadow.send_chars("whoami > /tmp/3\n")
shadow.wait_for_file("/tmp/3")
assert "ash" in shadow.succeed("cat /tmp/3")
with subtest("Change password"):
shadow.send_key("alt-f3")
shadow.wait_until_succeeds(f"[ $(fgconsole) = 3 ]")