about summary refs log tree commit diff
path: root/nixos/tests/intune.nix
blob: 41bf638d76610cad5a45f417b54ea90982ad174a (plain) (blame)
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
55
56
import ./make-test-python.nix ({ pkgs, ...} : {
  name = "intune";
  meta = {
    maintainers = with pkgs.lib.maintainers; [ rhysmdnz ];
  };
  enableOCR = true;

  nodes.machine =
    { nodes, ... }:
    let user = nodes.machine.users.users.alice;
    in {
      services.intune.enable=true;
      services.gnome.gnome-keyring.enable = true;
      imports = [ ./common/user-account.nix ./common/x11.nix ];
      test-support.displayManager.auto.user = user.name;
      environment = {
        variables.DBUS_SESSION_BUS_ADDRESS = "unix:path=/run/user/${builtins.toString user.uid}/bus";
      };
    };
  nodes.pam =
    { nodes, ... }:
    let user = nodes.machine.users.users.alice;
    in {
      services.intune.enable=true;
      imports = [ ./common/user-account.nix ];
    };

  testScript = ''
    start_all()

    # Check System Daemons successfully start
    machine.succeed("systemctl start microsoft-identity-device-broker.service")
    machine.succeed("systemctl start intune-daemon.service")

    # Check User Daemons and intune-portal execurtable works
    # Going any further than starting it would require internet access and a microsoft account
    machine.wait_for_x()
    # TODO: This needs an unlocked user keychain before it will work
    #machine.succeed("su - alice -c 'systemctl start --user microsoft-identity-broker.service'")
    machine.succeed("su - alice -c 'systemctl start --user intune-agent.service'")
    machine.succeed("su - alice -c intune-portal >&2 &")
    machine.wait_for_text("Intune Agent")

    # Check logging in creates password file
    def login_as_alice():
        pam.wait_until_tty_matches("1", "login: ")
        pam.send_chars("alice\n")
        pam.wait_until_tty_matches("1", "Password: ")
        pam.send_chars("foobar\n")
        pam.wait_until_tty_matches("1", "alice\@pam")

    pam.wait_for_unit("multi-user.target")
    login_as_alice()
    pam.wait_for_file("/run/intune/1000/pwquality")
  '';
})