about summary refs log tree commit diff
path: root/nixos/tests/kerberos/mit.nix
blob: 1191d047abbf0b38c671dddd5ab692c6d55c679f (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
import ../make-test-python.nix ({pkgs, ...}: {
  name = "kerberos_server-mit";

  nodes.machine = { config, libs, pkgs, ...}:
  { services.kerberos_server =
    { enable = true;
      realms = {
        "FOO.BAR".acl = [{principal = "admin"; access = ["add" "cpw"];}];
      };
    };
    security.krb5 = {
      enable = true;
      package = pkgs.krb5;
      settings = {
        libdefaults = {
          default_realm = "FOO.BAR";
        };
        realms = {
          "FOO.BAR" = {
            admin_server = "machine";
            kdc = "machine";
          };
        };
      };
    };
    users.extraUsers.alice = { isNormalUser = true; };
  };

  testScript = ''
    machine.succeed(
        "kdb5_util create -s -r FOO.BAR -P master_key",
        "systemctl restart kadmind.service kdc.service",
    )

    for unit in ["kadmind", "kdc"]:
        machine.wait_for_unit(f"{unit}.service")

    machine.succeed(
        "kadmin.local add_principal -pw admin_pw admin",
        "kadmin -p admin -w admin_pw addprinc -pw alice_pw alice",
        "echo alice_pw | sudo -u alice kinit",
    )
  '';

  meta.maintainers = [ pkgs.lib.maintainers.dblsaiko ];
})