Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 018072ea2212
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 12f3e2c42cd7
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Jan 3, 2021

  1. nixos/tests/shadow: add switch user subtest

    Milan Pässler authored and FRidh committed Jan 3, 2021
    Copy the full SHA
    12f3e2c View commit details
Showing with 14 additions and 0 deletions.
  1. +14 −0 nixos/tests/shadow.nix
14 changes: 14 additions & 0 deletions nixos/tests/shadow.nix
Original file line number Diff line number Diff line change
@@ -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 ]")