2 dbDomain = "example.org";
3 dbSuffix = "dc=example,dc=org";
5 ldapRootUser = "admin";
6 ldapRootPassword = "foobar";
9 testPassword = "foobar";
10 testNewPassword = "barfoo";
12 import ./make-test-python.nix ({ pkgs, ... }: {
15 meta = with pkgs.lib.maintainers; {
16 maintainers = [ bbigras s1341 ];
19 nodes.machine = { pkgs, ... }: {
20 security.pam.services.systemd-user.makeHomeDir = true;
21 environment.etc."cert.pem".text = builtins.readFile ./common/acme/server/acme.test.cert.pem;
22 environment.etc."key.pem".text = builtins.readFile ./common/acme/server/acme.test.key.pem;
25 urlList = [ "ldap:///" "ldaps:///" ];
28 olcTLSCACertificateFile = "/etc/cert.pem";
29 olcTLSCertificateFile = "/etc/cert.pem";
30 olcTLSCertificateKeyFile = "/etc/key.pem";
31 olcTLSCipherSuite = "HIGH:MEDIUM:+3DES:+RC4:+aNULL";
32 olcTLSCRLCheck = "none";
33 olcTLSVerifyClient = "never";
34 olcTLSProtocolMin = "3.1";
37 "cn=schema".includes = [
38 "${pkgs.openldap}/etc/schema/core.ldif"
39 "${pkgs.openldap}/etc/schema/cosine.ldif"
40 "${pkgs.openldap}/etc/schema/inetorgperson.ldif"
41 "${pkgs.openldap}/etc/schema/nis.ldif"
43 "olcDatabase={1}mdb" = {
45 objectClass = [ "olcDatabaseConfig" "olcMdbConfig" ];
46 olcDatabase = "{1}mdb";
47 olcDbDirectory = "/var/lib/openldap/db";
49 olcRootDN = "cn=${ldapRootUser},${dbSuffix}";
50 olcRootPW = ldapRootPassword;
53 custom access rules for userPassword attributes
56 {0}to attrs=userPassword
62 allow read on anything else
72 declarativeContents = {
77 objectClass: organization
80 dn: ou=posix,${dbSuffix}
82 objectClass: organizationalUnit
84 dn: ou=accounts,ou=posix,${dbSuffix}
86 objectClass: organizationalUnit
88 dn: uid=${testUser},ou=accounts,ou=posix,${dbSuffix}
90 objectClass: posixAccount
91 userPassword: ${testPassword}
92 homeDirectory: /home/${testUser}
103 # just for testing purposes, don't put this into the Nix store in production!
104 environmentFile = "${pkgs.writeText "ldap-root" "LDAP_BIND_PW=${ldapRootPassword}"}";
107 config_file_version = 2
108 services = nss, pam, sudo
109 domains = ${dbDomain}
114 ldap_uri = ldaps://127.0.0.1:636
115 ldap_tls_reqcert = allow
116 ldap_tls_cacert = /etc/cert.pem
117 ldap_search_base = ${dbSuffix}
118 ldap_default_bind_dn = cn=${ldapRootUser},${dbSuffix}
119 ldap_default_authtok_type = password
120 ldap_default_authtok = $LDAP_BIND_PW
127 machine.wait_for_unit("openldap.service")
128 machine.wait_for_unit("sssd.service")
129 result = machine.execute("getent passwd ${testUser}")
131 assert "${testUser}" in result[1]
133 machine.wait_for_console_text("Backend is online")
134 machine.succeed("getent passwd ${testUser}")
136 with subtest("Log in as ${testUser}"):
137 machine.wait_until_tty_matches("1", "login: ")
138 machine.send_chars("${testUser}\n")
139 machine.wait_until_tty_matches("1", "login: ${testUser}")
140 machine.wait_until_succeeds("pgrep login")
141 machine.wait_until_tty_matches("1", "Password: ")
142 machine.send_chars("${testPassword}\n")
143 machine.wait_until_succeeds("pgrep -u ${testUser} bash")
144 machine.send_chars("touch done\n")
145 machine.wait_for_file("/home/${testUser}/done")
147 with subtest("Change ${testUser}'s password"):
148 machine.send_chars("passwd\n")
149 machine.wait_until_tty_matches("1", "Current Password: ")
150 machine.send_chars("${testPassword}\n")
151 machine.wait_until_tty_matches("1", "New Password: ")
152 machine.send_chars("${testNewPassword}\n")
153 machine.wait_until_tty_matches("1", "Reenter new Password: ")
154 machine.send_chars("${testNewPassword}\n")
155 machine.wait_until_tty_matches("1", "passwd: password updated successfully")
157 with subtest("Log in as ${testUser} with new password in virtual console 2"):
158 machine.send_key("alt-f2")
159 machine.wait_until_succeeds("[ $(fgconsole) = 2 ]")
160 machine.wait_for_unit("getty@tty2.service")
161 machine.wait_until_succeeds("pgrep -f 'agetty.*tty2'")
163 machine.wait_until_tty_matches("2", "login: ")
164 machine.send_chars("${testUser}\n")
165 machine.wait_until_tty_matches("2", "login: ${testUser}")
166 machine.wait_until_succeeds("pgrep login")
167 machine.wait_until_tty_matches("2", "Password: ")
168 machine.send_chars("${testNewPassword}\n")
169 machine.wait_until_succeeds("pgrep -u ${testUser} bash")
170 machine.send_chars("touch done2\n")
171 machine.wait_for_file("/home/${testUser}/done2")