diff options
author | Milan Pässler <mil@nyantec.com> | 2021-01-03 13:53:34 +0100 |
---|---|---|
committer | Frederik Rietdijk <freddyrietdijk@fridh.nl> | 2021-01-03 15:54:48 +0100 |
commit | 12f3e2c42cd7ece1dfb90ee96119d1db548dc734 (patch) | |
tree | ec20d749f196cab971d53b43e24c99a459829911 /nixos | |
parent | 018072ea221254a449d11e45acba0f4b1f688c9d (diff) |
nixos/tests/shadow: add switch user subtest
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/tests/shadow.nix | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/nixos/tests/shadow.nix b/nixos/tests/shadow.nix index 0cc1d6811400..8f8cdef7ef9d 100644 --- a/nixos/tests/shadow.nix +++ b/nixos/tests/shadow.nix @@ -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 ]") |