summary refs log tree commit diff
path: root/nixos/tests/openldap.nix
diff options
context:
space:
mode:
authorKai Wohlfahrt <kai.wohlfahrt@gmail.com>2022-06-05 20:03:46 +0100
committerJörg Thalheim <joerg@thalheim.io>2022-06-29 19:59:29 +0200
commit334d622ec72c79a23bc5102f424ca535685e3dfb (patch)
tree779b100f177523b8b59ed10dce595830d5c81852 /nixos/tests/openldap.nix
parent8a7193fc0a9fa7fa098299a321fd2bd3f4fa2d7c (diff)
downloadnixpkgs-334d622ec72c79a23bc5102f424ca535685e3dfb.tar
nixpkgs-334d622ec72c79a23bc5102f424ca535685e3dfb.tar.gz
nixpkgs-334d622ec72c79a23bc5102f424ca535685e3dfb.tar.bz2
nixpkgs-334d622ec72c79a23bc5102f424ca535685e3dfb.tar.lz
nixpkgs-334d622ec72c79a23bc5102f424ca535685e3dfb.tar.xz
nixpkgs-334d622ec72c79a23bc5102f424ca535685e3dfb.tar.zst
nixpkgs-334d622ec72c79a23bc5102f424ca535685e3dfb.zip
openldap: test starting with empty DB
This addresses the original concern behind #92544
Diffstat (limited to 'nixos/tests/openldap.nix')
-rw-r--r--nixos/tests/openldap.nix18
1 files changed, 14 insertions, 4 deletions
diff --git a/nixos/tests/openldap.nix b/nixos/tests/openldap.nix
index b31df594a36..04e2650e380 100644
--- a/nixos/tests/openldap.nix
+++ b/nixos/tests/openldap.nix
@@ -81,12 +81,17 @@ in {
           };
         };
       };
-      declarativeContents."dc=example" = dbContents;
     };
 
     specialisation = {
+      declarativeContents.configuration = { ... }: {
+        services.openldap.declarativeContents."dc=example" = dbContents;
+      };
       mutableConfig.configuration = { ... }: {
-        services.openldap.mutableConfig = true;
+        services.openldap = {
+          declarativeContents."dc=example" = dbContents;
+          mutableConfig = true;
+        };
       };
       manualConfigDir = {
         inheritParentConfig = false;
@@ -108,9 +113,14 @@ in {
       olcRootPW: foobar
     '';
   in ''
+    # Test startup with empty DB
     machine.wait_for_unit("openldap.service")
-    machine.succeed('ldapsearch -LLL -D "cn=root,dc=example" -w notapassword -b "dc=example"')
-    machine.fail('ldapmodify -D cn=root,cn=config -w configpassword -f ${pkgs.writeText "rootpw.ldif" changeRootPw}')
+
+    with subtest("declarative contents"):
+      machine.succeed('${specializations}/declarativeContents/bin/switch-to-configuration test')
+      machine.wait_for_unit("openldap.service")
+      machine.succeed('ldapsearch -LLL -D "cn=root,dc=example" -w notapassword -b "dc=example"')
+      machine.fail('ldapmodify -D cn=root,cn=config -w configpassword -f ${pkgs.writeText "rootpw.ldif" changeRootPw}')
 
     with subtest("mutable config"):
       machine.succeed('${specializations}/mutableConfig/bin/switch-to-configuration test')