2022-05-05 11:09:42 +01:00
|
|
|
import ./make-test-python.nix ({ pkgs, ... }:
|
|
|
|
let
|
|
|
|
certs = import ./common/acme/server/snakeoil-certs.nix;
|
|
|
|
serverDomain = certs.domain;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
name = "kanidm";
|
|
|
|
meta.maintainers = with pkgs.lib.maintainers; [ erictapen Flakebi ];
|
|
|
|
|
|
|
|
nodes.server = { config, pkgs, lib, ... }: {
|
|
|
|
services.kanidm = {
|
|
|
|
enableServer = true;
|
|
|
|
serverSettings = {
|
|
|
|
origin = "https://${serverDomain}";
|
|
|
|
domain = serverDomain;
|
2022-11-20 17:10:15 +00:00
|
|
|
bindaddress = "[::]:443";
|
2022-05-05 11:09:42 +01:00
|
|
|
ldapbindaddress = "[::1]:636";
|
2022-11-20 17:10:15 +00:00
|
|
|
tls_chain = certs."${serverDomain}".cert;
|
|
|
|
tls_key = certs."${serverDomain}".key;
|
2022-05-05 11:09:42 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
security.pki.certificateFiles = [ certs.ca.cert ];
|
|
|
|
|
|
|
|
networking.hosts."::1" = [ serverDomain ];
|
2022-11-20 17:10:15 +00:00
|
|
|
networking.firewall.allowedTCPPorts = [ 443 ];
|
2022-05-05 11:09:42 +01:00
|
|
|
|
|
|
|
users.users.kanidm.shell = pkgs.bashInteractive;
|
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [ kanidm openldap ripgrep ];
|
|
|
|
};
|
|
|
|
|
|
|
|
nodes.client = { pkgs, nodes, ... }: {
|
|
|
|
services.kanidm = {
|
|
|
|
enableClient = true;
|
|
|
|
clientSettings = {
|
|
|
|
uri = "https://${serverDomain}";
|
2022-09-06 14:11:53 +01:00
|
|
|
verify_ca = true;
|
|
|
|
verify_hostnames = true;
|
|
|
|
};
|
|
|
|
enablePam = true;
|
|
|
|
unixSettings = {
|
|
|
|
pam_allowed_login_groups = [ "shell" ];
|
2022-05-05 11:09:42 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-04-19 21:46:14 +01:00
|
|
|
networking.hosts."${nodes.server.networking.primaryIPAddress}" = [ serverDomain ];
|
2022-05-05 11:09:42 +01:00
|
|
|
|
|
|
|
security.pki.certificateFiles = [ certs.ca.cert ];
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = { nodes, ... }:
|
|
|
|
let
|
|
|
|
ldapBaseDN = builtins.concatStringsSep "," (map (s: "dc=" + s) (pkgs.lib.splitString "." serverDomain));
|
|
|
|
|
|
|
|
# We need access to the config file in the test script.
|
|
|
|
filteredConfig = pkgs.lib.converge
|
|
|
|
(pkgs.lib.filterAttrsRecursive (_: v: v != null))
|
2023-04-19 21:46:14 +01:00
|
|
|
nodes.server.services.kanidm.serverSettings;
|
2022-05-05 11:09:42 +01:00
|
|
|
serverConfigFile = (pkgs.formats.toml { }).generate "server.toml" filteredConfig;
|
|
|
|
|
|
|
|
in
|
|
|
|
''
|
|
|
|
start_all()
|
|
|
|
server.wait_for_unit("kanidm.service")
|
|
|
|
server.wait_until_succeeds("curl -sf https://${serverDomain} | grep Kanidm")
|
2022-11-20 17:10:15 +00:00
|
|
|
server.succeed("ldapsearch -H ldaps://${serverDomain}:636 -b '${ldapBaseDN}' -x '(name=test)'")
|
2022-09-06 14:11:53 +01:00
|
|
|
client.succeed("kanidm login -D anonymous && kanidm self whoami | grep anonymous@${serverDomain}")
|
2022-09-05 13:56:23 +01:00
|
|
|
rv, result = server.execute("kanidmd recover_account -c ${serverConfigFile} idm_admin 2>&1 | rg -o '[A-Za-z0-9]{48}'")
|
2022-05-05 11:09:42 +01:00
|
|
|
assert rv == 0
|
2022-09-06 14:11:53 +01:00
|
|
|
client.wait_for_unit("kanidm-unixd.service")
|
|
|
|
client.succeed("kanidm_unixd_status | grep working!")
|
2022-05-05 11:09:42 +01:00
|
|
|
'';
|
|
|
|
})
|