summaryrefslogtreecommitdiffstats
path: root/nixos/tests/greetd-no-shadow.nix
blob: e2f738188feb6c22cbe4a1e4dd420d0e7028d60e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{
  pkgs,
  latestKernel ? false,
  ...
}:
{
  name = "greetd-no-shadow";
  meta = {
    maintainers = [ ];
  };

  nodes.machine =
    { pkgs, lib, ... }:
    {

      users.users.alice = {
        isNormalUser = true;
        group = "alice";
        password = "foobar";
      };
      users.groups.alice = { };

      # This means login(1) breaks, so we must use greetd/agreety instead.
      security.shadow.enable = false;

      services.greetd = {
        enable = true;
        settings = {
          default_session = {
            command = "${pkgs.greetd}/bin/agreety --cmd bash";
          };
        };
      };
    };

  testScript = ''
    machine.start()

    machine.wait_for_unit("multi-user.target")
    machine.wait_until_succeeds("pgrep -f 'agretty.*tty1'")
    machine.screenshot("postboot")

    with subtest("Log in as alice on a virtual console"):
        machine.wait_until_tty_matches("1", "login: ")
        machine.send_chars("alice\n")
        machine.wait_until_tty_matches("1", "login: alice")
        machine.wait_until_succeeds("pgrep login")
        machine.wait_until_tty_matches("1", "Password: ")
        machine.send_chars("foobar\n")
        machine.wait_until_succeeds("pgrep -u alice bash")
        machine.send_chars("touch done\n")
        machine.wait_for_file("/home/alice/done")
  '';
}