1 import ./make-test-python.nix ({ pkgs, ... }:
3 certs = import ./common/acme/server/snakeoil-certs.nix;
4 serverDomain = certs.domain;
8 meta.maintainers = with pkgs.lib.maintainers; [ erictapen Flakebi ];
10 nodes.server = { config, pkgs, lib, ... }: {
14 origin = "https://${serverDomain}";
15 domain = serverDomain;
16 bindaddress = "[::1]:8443";
17 ldapbindaddress = "[::1]:636";
23 recommendedProxySettings = true;
24 virtualHosts."${serverDomain}" = {
26 sslCertificate = certs."${serverDomain}".cert;
27 sslCertificateKey = certs."${serverDomain}".key;
28 locations."/".proxyPass = "http://[::1]:8443";
32 security.pki.certificateFiles = [ certs.ca.cert ];
34 networking.hosts."::1" = [ serverDomain ];
35 networking.firewall.allowedTCPPorts = [ 80 443 ];
37 users.users.kanidm.shell = pkgs.bashInteractive;
39 environment.systemPackages = with pkgs; [ kanidm openldap ripgrep ];
42 nodes.client = { pkgs, nodes, ... }: {
46 uri = "https://${serverDomain}";
48 verify_hostnames = true;
52 pam_allowed_login_groups = [ "shell" ];
56 networking.hosts."${nodes.server.config.networking.primaryIPAddress}" = [ serverDomain ];
58 security.pki.certificateFiles = [ certs.ca.cert ];
61 testScript = { nodes, ... }:
63 ldapBaseDN = builtins.concatStringsSep "," (map (s: "dc=" + s) (pkgs.lib.splitString "." serverDomain));
65 # We need access to the config file in the test script.
66 filteredConfig = pkgs.lib.converge
67 (pkgs.lib.filterAttrsRecursive (_: v: v != null))
68 nodes.server.config.services.kanidm.serverSettings;
69 serverConfigFile = (pkgs.formats.toml { }).generate "server.toml" filteredConfig;
74 server.wait_for_unit("kanidm.service")
75 server.wait_until_succeeds("curl -sf https://${serverDomain} | grep Kanidm")
76 server.succeed("ldapsearch -H ldap://[::1]:636 -b '${ldapBaseDN}' -x '(name=test)'")
77 client.succeed("kanidm login -D anonymous && kanidm self whoami | grep anonymous@${serverDomain}")
78 rv, result = server.execute("kanidmd recover_account -c ${serverConfigFile} idm_admin 2>&1 | rg -o '[A-Za-z0-9]{48}'")
80 client.wait_for_unit("kanidm-unixd.service")
81 client.succeed("kanidm_unixd_status | grep working!")