diff --git a/docs/service-implementation-guide.md b/docs/service-implementation-guide.md index 2ecdc8b..d259357 100644 --- a/docs/service-implementation-guide.md +++ b/docs/service-implementation-guide.md @@ -296,12 +296,12 @@ let in { # Test variants (all 6 required) - basic = pkgs.testers.runNixOSTest { ... }; - backup = pkgs.testers.runNixOSTest { ... }; - https = pkgs.testers.runNixOSTest { ... }; - ldap = pkgs.testers.runNixOSTest { ... }; - monitoring = pkgs.testers.runNixOSTest { ... }; - sso = pkgs.testers.runNixOSTest { ... }; + basic = lib.shb.runNixOSTest { ... }; + backup = lib.shb.runNixOSTest { ... }; + https = lib.shb.runNixOSTest { ... }; + ldap = lib.shb.runNixOSTest { ... }; + monitoring = lib.shb.runNixOSTest { ... }; + sso = lib.shb.runNixOSTest { ... }; } ``` diff --git a/flake.nix b/flake.nix index 2f327ec..9e0fc13 100644 --- a/flake.nix +++ b/flake.nix @@ -178,7 +178,9 @@ vm_test = name: path: flattenAttrs "vm_${name}" ( import path { inherit pkgs; - inherit (pkgs) lib; + lib = pkgs.lib // { + shb = pkgs.callPackage ./test/common.nix {}; + }; } ); diff --git a/modules/contracts/backup/test.nix b/modules/contracts/backup/test.nix index 61c594d..b3748a9 100644 --- a/modules/contracts/backup/test.nix +++ b/modules/contracts/backup/test.nix @@ -1,7 +1,5 @@ -{ pkgs, lib, ... }: +{ pkgs, lib }: let - testLib = pkgs.callPackage ../../../test/common.nix {}; - inherit (lib) concatMapStringsSep getAttrFromPath mkIf optionalAttrs setAttrByPath; in { name, @@ -14,11 +12,11 @@ in ], settings, # { repository, config } -> attrset extraConfig ? null, # { username, config } -> attrset -}: pkgs.testers.runNixOSTest { +}: lib.shb.runNixOSTest { inherit name; nodes.machine = { config, ... }: { - imports = [ testLib.baseImports ] ++ modules; + imports = [ lib.shb.baseImports ] ++ modules; config = lib.mkMerge [ (setAttrByPath providerRoot { diff --git a/modules/contracts/databasebackup/test.nix b/modules/contracts/databasebackup/test.nix index 081bf00..ecb9e83 100644 --- a/modules/contracts/databasebackup/test.nix +++ b/modules/contracts/databasebackup/test.nix @@ -1,7 +1,5 @@ -{ pkgs, lib, ... }: +{ pkgs, lib }: let - testLib = pkgs.callPackage ../../../test/common.nix {}; - inherit (lib) getAttrFromPath mkIf optionalAttrs setAttrByPath; in { name, @@ -11,11 +9,11 @@ in modules ? [], database ? "me", settings, # { repository, config } -> attrset -}: pkgs.testers.runNixOSTest { +}: lib.shb.runNixOSTest { inherit name; nodes.machine = { config, ... }: { - imports = [ testLib.baseImports ] ++ modules; + imports = [ lib.shb.baseImports ] ++ modules; config = lib.mkMerge [ (setAttrByPath providerRoot { request = (getAttrFromPath requesterRoot config).request; diff --git a/modules/contracts/secret/test.nix b/modules/contracts/secret/test.nix index 272bcb9..7d69e5d 100644 --- a/modules/contracts/secret/test.nix +++ b/modules/contracts/secret/test.nix @@ -1,7 +1,5 @@ -{ pkgs, lib, ... }: +{ pkgs, lib }: let - testLib = pkgs.callPackage ../../../test/common.nix {}; - inherit (lib) getAttrFromPath setAttrByPath; inherit (lib) mkIf; in @@ -13,11 +11,11 @@ in group ? "root", mode ? "0400", restartUnits ? [ "myunit.service" ], - }: pkgs.testers.runNixOSTest { + }: lib.shb.runNixOSTest { name = "secret_${name}_${owner}_${group}_${mode}"; nodes.machine = { config, ... }: { - imports = [ testLib.baseImports ] ++ modules; + imports = [ lib.shb.baseImports ] ++ modules; config = lib.mkMerge [ (setAttrByPath configRoot { A = { diff --git a/test/blocks/authelia.nix b/test/blocks/authelia.nix index c673c43..2f72a1b 100644 --- a/test/blocks/authelia.nix +++ b/test/blocks/authelia.nix @@ -1,11 +1,11 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: let pkgs' = pkgs; ldapAdminPassword = "ldapAdminPassword"; in { - basic = pkgs.testers.runNixOSTest { + basic = lib.shb.runNixOSTest { name = "authelia-basic"; nodes.machine = { config, pkgs, ... }: { diff --git a/test/blocks/lib.nix b/test/blocks/lib.nix index d594650..860c453 100644 --- a/test/blocks/lib.nix +++ b/test/blocks/lib.nix @@ -54,7 +54,7 @@ in generator = shblib.replaceSecretsFormatAdapter (shblib.formatXML {enclosingRoot = "Root";}); }; in - pkgs.testers.runNixOSTest { + lib.shb.runNixOSTest { name = "lib-template"; nodes.machine = { config, pkgs, ... }: { diff --git a/test/blocks/lldap.nix b/test/blocks/lldap.nix index b9527b4..f6de9e0 100644 --- a/test/blocks/lldap.nix +++ b/test/blocks/lldap.nix @@ -6,7 +6,7 @@ let charliePassword = "CharliePassword"; in { - auth = pkgs.testers.runNixOSTest { + auth = lib.shb.runNixOSTest { name = "ldap-auth"; nodes.server = { config, pkgs, ... }: { diff --git a/test/blocks/mitmdump.nix b/test/blocks/mitmdump.nix index 03048cb..b6c0e11 100644 --- a/test/blocks/mitmdump.nix +++ b/test/blocks/mitmdump.nix @@ -39,7 +39,7 @@ let ); in { - default = pkgs.testers.runNixOSTest { + default = lib.shb.runNixOSTest { name = "mitmdump-default"; nodes.machine = { config, pkgs, ... }: { diff --git a/test/blocks/postgresql.nix b/test/blocks/postgresql.nix index fed7fb9..340e411 100644 --- a/test/blocks/postgresql.nix +++ b/test/blocks/postgresql.nix @@ -1,9 +1,9 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: let pkgs' = pkgs; in { - peerWithoutUser = pkgs.testers.runNixOSTest { + peerWithoutUser = lib.shb.runNixOSTest { name = "postgresql-peerWithoutUser"; nodes.machine = { config, pkgs, ... }: { @@ -40,7 +40,7 @@ in ''; }; - peerAuth = pkgs.testers.runNixOSTest { + peerAuth = lib.shb.runNixOSTest { name = "postgresql-peerAuth"; nodes.machine = { config, pkgs, ... }: { @@ -90,7 +90,7 @@ in ''; }; - tcpIPWithoutPasswordAuth = pkgs.testers.runNixOSTest { + tcpIPWithoutPasswordAuth = lib.shb.runNixOSTest { name = "postgresql-tcpIpWithoutPasswordAuth"; nodes.machine = { config, pkgs, ... }: { @@ -128,7 +128,7 @@ in ''; }; - tcpIPPasswordAuth = pkgs.testers.runNixOSTest { + tcpIPPasswordAuth = lib.shb.runNixOSTest { name = "postgresql-tcpIPPasswordAuth"; nodes.machine = { config, pkgs, ... }: { diff --git a/test/blocks/restic.nix b/test/blocks/restic.nix index b5dad51..6adbca3 100644 --- a/test/blocks/restic.nix +++ b/test/blocks/restic.nix @@ -1,8 +1,8 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: let testLib = pkgs.callPackage ../common.nix {}; - commonTest = user: pkgs.testers.runNixOSTest { + commonTest = user: lib.shb.runNixOSTest { name = "restic_backupAndRestore_${user}"; nodes.machine = { config, ... }: { diff --git a/test/blocks/ssl.nix b/test/blocks/ssl.nix index e0b074f..3f38704 100644 --- a/test/blocks/ssl.nix +++ b/test/blocks/ssl.nix @@ -1,9 +1,9 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: let pkgs' = pkgs; in { - test = pkgs.testers.runNixOSTest { + test = lib.shb.runNixOSTest { name = "ssl-test"; nodes.server = { config, pkgs, ... }: { diff --git a/test/common.nix b/test/common.nix index a011377..ec4c606 100644 --- a/test/common.nix +++ b/test/common.nix @@ -151,6 +151,10 @@ in { inherit baseImports accessScript; + runNixOSTest = args: pkgs.testers.runNixOSTest ({ + interactive.sshBackdoor.enable = true; + } // args); + mkScripts = args: { access = accessScript args; diff --git a/test/contracts/backup.nix b/test/contracts/backup.nix index c53e7f3..0370290 100644 --- a/test/contracts/backup.nix +++ b/test/contracts/backup.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, ... }: +{ pkgs, ... }: let contracts = pkgs.callPackage ../../modules/contracts {}; in diff --git a/test/services/arr.nix b/test/services/arr.nix index a58f199..71e5bdc 100644 --- a/test/services/arr.nix +++ b/test/services/arr.nix @@ -3,10 +3,8 @@ let healthUrl = "/health"; loginUrl = "/UI/Login"; - testLib = pkgs.callPackage ../common.nix {}; - # TODO: Test login - commonTestScript = appname: cfgPathFn: testLib.mkScripts { + commonTestScript = appname: cfgPathFn: lib.shb.mkScripts { hasSSL = { node, ... }: !(isNull node.config.shb.arr.${appname}.ssl); waitForServices = { ... }: [ "${appname}.service" @@ -44,7 +42,7 @@ let basic = appname: { config, ... }: { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/services/arr.nix ]; @@ -62,8 +60,8 @@ let clientLogin = appname: { config, ... }: { imports = [ - testLib.baseModule - testLib.clientLoginModule + lib.shb.baseModule + lib.shb.clientLoginModule ]; test = { @@ -83,7 +81,7 @@ let }; }; - basicTest = appname: cfgPathFn: pkgs.testers.runNixOSTest { + basicTest = appname: cfgPathFn: lib.shb.runNixOSTest { name = "arr_${appname}_basic"; nodes.client = { @@ -100,13 +98,13 @@ let testScript = (commonTestScript appname cfgPathFn).access; }; - backupTest = appname: cfgPathFn: pkgs.testers.runNixOSTest { + backupTest = appname: cfgPathFn: lib.shb.runNixOSTest { name = "arr_${appname}_backup"; nodes.server = { config, ... }: { imports = [ (basic appname) - (testLib.backup config.shb.arr.${appname}.backup) + (lib.shb.backup config.shb.arr.${appname}.backup) ]; }; @@ -121,13 +119,13 @@ let }; }; - httpsTest = appname: cfgPathFn: pkgs.testers.runNixOSTest { + httpsTest = appname: cfgPathFn: lib.shb.runNixOSTest { name = "arr_${appname}_https"; nodes.server = { config, pkgs, ... }: { imports = [ (basic appname) - testLib.certs + lib.shb.certs (https appname) ]; }; @@ -143,16 +141,16 @@ let }; }; - ssoTest = appname: cfgPathFn: pkgs.testers.runNixOSTest { + ssoTest = appname: cfgPathFn: lib.shb.runNixOSTest { name = "arr_${appname}_sso"; nodes.server = { config, pkgs, ... }: { imports = [ (basic appname) - testLib.certs + lib.shb.certs (https appname) - testLib.ldap - (testLib.sso config.shb.certs.certs.selfsigned.n) + lib.shb.ldap + (lib.shb.sso config.shb.certs.certs.selfsigned.n) (sso appname) ]; }; diff --git a/test/services/audiobookshelf.nix b/test/services/audiobookshelf.nix index 17294a4..6a465fd 100644 --- a/test/services/audiobookshelf.nix +++ b/test/services/audiobookshelf.nix @@ -1,8 +1,6 @@ -{ pkgs, ... }: +{ lib, ... }: let - testLib = pkgs.callPackage ../common.nix {}; - - commonTestScript = testLib.accessScript { + commonTestScript = lib.shb.accessScript { hasSSL = { node, ... }: !(isNull node.config.shb.audiobookshelf.ssl); waitForServices = { ... }: [ "audiobookshelf.service" @@ -18,7 +16,7 @@ let basic = { config, ... }: { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/services/audiobookshelf.nix ]; @@ -33,8 +31,8 @@ let clientLogin = { config, ... }: { imports = [ - testLib.baseModule - testLib.clientLoginModule + lib.shb.baseModule + lib.shb.clientLoginModule ]; virtualisation.memorySize = 4096; @@ -89,7 +87,7 @@ let }; in { - basic = pkgs.testers.runNixOSTest { + basic = lib.shb.runNixOSTest { name = "audiobookshelf-basic"; nodes.client = { @@ -107,13 +105,13 @@ in testScript = commonTestScript; }; - https = pkgs.testers.runNixOSTest { + https = lib.shb.runNixOSTest { name = "audiobookshelf-https"; nodes.server = { imports = [ basic - testLib.certs + lib.shb.certs https ]; }; @@ -123,16 +121,16 @@ in testScript = commonTestScript; }; - sso = pkgs.testers.runNixOSTest { + sso = lib.shb.runNixOSTest { name = "audiobookshelf-sso"; nodes.server = { config, ... }: { imports = [ basic - testLib.certs + lib.shb.certs https - testLib.ldap - (testLib.sso config.shb.certs.certs.selfsigned.n) + lib.shb.ldap + (lib.shb.sso config.shb.certs.certs.selfsigned.n) sso ]; }; diff --git a/test/services/deluge.nix b/test/services/deluge.nix index 610a3d8..3f506fb 100644 --- a/test/services/deluge.nix +++ b/test/services/deluge.nix @@ -1,8 +1,6 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: let - testLib = pkgs.callPackage ../common.nix {}; - - commonTestScript = testLib.mkScripts { + commonTestScript = lib.shb.mkScripts { hasSSL = { node, ... }: !(isNull node.config.shb.deluge.ssl); waitForServices = { ... }: [ "nginx.service" @@ -69,7 +67,7 @@ let basic = { config, ... }: { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/blocks/hardcodedsecret.nix ../../modules/services/deluge.nix ]; @@ -100,8 +98,8 @@ let clientLogin = { config, ... }: { imports = [ - testLib.baseModule - testLib.clientLoginModule + lib.shb.baseModule + lib.shb.clientLoginModule ]; test = { subdomain = "d"; @@ -146,7 +144,7 @@ let }; in { - basic = pkgs.testers.runNixOSTest { + basic = lib.shb.runNixOSTest { name = "deluge_basic"; nodes.client = { @@ -163,13 +161,13 @@ in testScript = commonTestScript.access; }; - backup = pkgs.testers.runNixOSTest { + backup = lib.shb.runNixOSTest { name = "deluge_backup"; nodes.server = { config, ... }: { imports = [ basic - (testLib.backup config.shb.deluge.backup) + (lib.shb.backup config.shb.deluge.backup) ]; }; @@ -178,13 +176,13 @@ in testScript = commonTestScript.backup; }; - https = pkgs.testers.runNixOSTest { + https = lib.shb.runNixOSTest { name = "deluge_https"; nodes.server = { imports = [ basic - testLib.certs + lib.shb.certs https ]; }; @@ -194,16 +192,16 @@ in testScript = commonTestScript.access; }; - sso = pkgs.testers.runNixOSTest { + sso = lib.shb.runNixOSTest { name = "deluge_sso"; nodes.server = { config, ... }: { imports = [ basic - testLib.certs + lib.shb.certs https - testLib.ldap - (testLib.sso config.shb.certs.certs.selfsigned.n) + lib.shb.ldap + (lib.shb.sso config.shb.certs.certs.selfsigned.n) sso ]; }; @@ -215,13 +213,13 @@ in }; }; - prometheus = pkgs.testers.runNixOSTest { + prometheus = lib.shb.runNixOSTest { name = "deluge_https"; nodes.server = { imports = [ basic - testLib.certs + lib.shb.certs https prometheus ]; diff --git a/test/services/forgejo.nix b/test/services/forgejo.nix index 32be99d..8b4d6ad 100644 --- a/test/services/forgejo.nix +++ b/test/services/forgejo.nix @@ -1,10 +1,8 @@ -{ pkgs, ... }: +{ lib, ... }: let - testLib = pkgs.callPackage ../common.nix {}; - adminPassword = "AdminPassword"; - commonTestScript = testLib.mkScripts { + commonTestScript = lib.shb.mkScripts { hasSSL = { node, ... }: !(isNull node.config.shb.forgejo.ssl); waitForServices = { ... }: [ "forgejo.service" @@ -21,7 +19,7 @@ let basic = { config, ... }: { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/blocks/hardcodedsecret.nix ../../modules/services/forgejo.nix ]; @@ -71,8 +69,8 @@ let clientLogin = { config, ... }: { imports = [ - testLib.baseModule - testLib.clientLoginModule + lib.shb.baseModule + lib.shb.clientLoginModule ]; test = { subdomain = "f"; @@ -152,7 +150,7 @@ let }; in { - basic = pkgs.testers.runNixOSTest { + basic = lib.shb.runNixOSTest { name = "forgejo_basic"; nodes.client = { @@ -169,13 +167,13 @@ in testScript = commonTestScript.access; }; - backup = pkgs.testers.runNixOSTest { + backup = lib.shb.runNixOSTest { name = "forgejo_backup"; nodes.server = { config, ... }: { imports = [ basic - (testLib.backup config.shb.forgejo.backup) + (lib.shb.backup config.shb.forgejo.backup) ]; }; @@ -184,13 +182,13 @@ in testScript = commonTestScript.backup; }; - https = pkgs.testers.runNixOSTest { + https = lib.shb.runNixOSTest { name = "forgejo_https"; nodes.server = { imports = [ basic - testLib.certs + lib.shb.certs https ]; }; @@ -200,15 +198,13 @@ in testScript = commonTestScript.access; }; - ldap = pkgs.testers.runNixOSTest { + ldap = lib.shb.runNixOSTest { name = "forgejo_ldap"; - interactive.sshBackdoor.enable = true; - nodes.server = { imports = [ basic - testLib.ldap + lib.shb.ldap ldap ]; }; @@ -217,8 +213,8 @@ in imports = [ ({ config, ... }: { imports = [ - testLib.baseModule - testLib.clientLoginModule + lib.shb.baseModule + lib.shb.clientLoginModule ]; test = { @@ -262,16 +258,16 @@ in testScript = commonTestScript.access; }; - sso = pkgs.testers.runNixOSTest { + sso = lib.shb.runNixOSTest { name = "forgejo_sso"; nodes.server = { config, pkgs, ... }: { imports = [ basic - testLib.certs + lib.shb.certs https - testLib.ldap - (testLib.sso config.shb.certs.certs.selfsigned.n) + lib.shb.ldap + (lib.shb.sso config.shb.certs.certs.selfsigned.n) sso ]; }; diff --git a/test/services/grocy.nix b/test/services/grocy.nix index 9eb6662..c2955a0 100644 --- a/test/services/grocy.nix +++ b/test/services/grocy.nix @@ -1,8 +1,6 @@ { pkgs, lib, ... }: let - testLib = pkgs.callPackage ../common.nix {}; - - commonTestScript = testLib.mkScripts { + commonTestScript = lib.shb.mkScripts { hasSSL = { node, ... }: !(isNull node.config.shb.grocy.ssl); waitForServices = { ... }: [ "phpfpm-grocy.service" @@ -15,7 +13,7 @@ let basic = { config, ... }: { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/services/grocy.nix ]; @@ -31,8 +29,8 @@ let clientLogin = { config, ... }: { imports = [ - testLib.baseModule - testLib.clientLoginModule + lib.shb.baseModule + lib.shb.clientLoginModule ]; virtualisation.memorySize = 4096; @@ -65,7 +63,7 @@ let }; in { - basic = pkgs.testers.runNixOSTest { + basic = lib.shb.runNixOSTest { name = "grocy_basic"; nodes.client = { @@ -82,13 +80,13 @@ in testScript = commonTestScript.access; }; - https = pkgs.testers.runNixOSTest { + https = lib.shb.runNixOSTest { name = "grocy_https"; nodes.server = { imports = [ basic - testLib.certs + lib.shb.certs https ]; }; diff --git a/test/services/hledger.nix b/test/services/hledger.nix index c40beec..2f36315 100644 --- a/test/services/hledger.nix +++ b/test/services/hledger.nix @@ -1,8 +1,6 @@ -{ pkgs, ... }: +{ lib, ... }: let - testLib = pkgs.callPackage ../common.nix {}; - - commonTestScript = testLib.mkScripts { + commonTestScript = lib.shb.mkScripts { hasSSL = { node, ... }: !(isNull node.config.shb.hledger.ssl); waitForServices = { ... }: [ "hledger-web.service" @@ -12,7 +10,7 @@ let basic = { config, ... }: { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/services/hledger.nix ]; @@ -28,8 +26,8 @@ let clientLogin = { config, ... }: { imports = [ - testLib.baseModule - testLib.clientLoginModule + lib.shb.baseModule + lib.shb.clientLoginModule ]; test = { @@ -59,7 +57,7 @@ let }; in { - basic = pkgs.testers.runNixOSTest { + basic = lib.shb.runNixOSTest { name = "hledger_basic"; nodes.client = { @@ -77,13 +75,13 @@ in testScript = commonTestScript.access; }; - backup = pkgs.testers.runNixOSTest { + backup = lib.shb.runNixOSTest { name = "hledger_backup"; nodes.server = { config, ... }: { imports = [ basic - (testLib.backup config.shb.hledger.backup) + (lib.shb.backup config.shb.hledger.backup) ]; }; @@ -92,13 +90,13 @@ in testScript = commonTestScript.backup; }; - https = pkgs.testers.runNixOSTest { + https = lib.shb.runNixOSTest { name = "hledger_https"; nodes.server = { imports = [ basic - testLib.certs + lib.shb.certs https ]; }; @@ -108,16 +106,16 @@ in testScript = commonTestScript.access; }; - sso = pkgs.testers.runNixOSTest { + sso = lib.shb.runNixOSTest { name = "hledger_sso"; nodes.server = { config, pkgs, ... }: { imports = [ basic - testLib.certs + lib.shb.certs https - testLib.ldap - (testLib.sso config.shb.certs.certs.selfsigned.n) + lib.shb.ldap + (lib.shb.sso config.shb.certs.certs.selfsigned.n) sso ]; }; diff --git a/test/services/home-assistant.nix b/test/services/home-assistant.nix index 355f574..84fbcf4 100644 --- a/test/services/home-assistant.nix +++ b/test/services/home-assistant.nix @@ -1,8 +1,6 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: let - testLib = pkgs.callPackage ../common.nix {}; - - commonTestScript = testLib.mkScripts { + commonTestScript = lib.shb.mkScripts { hasSSL = { node, ... }: !(isNull node.config.shb.home-assistant.ssl); waitForServices = { ... }: [ "home-assistant.service" @@ -15,7 +13,7 @@ let basic = { config, ... }: { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/services/home-assistant.nix ]; @@ -40,8 +38,8 @@ let clientLogin = { config, ... }: { imports = [ - testLib.baseModule - testLib.clientLoginModule + lib.shb.baseModule + lib.shb.clientLoginModule ]; virtualisation.memorySize = 4096; @@ -151,7 +149,7 @@ let }; in { - basic = pkgs.testers.runNixOSTest { + basic = lib.shb.runNixOSTest { name = "homeassistant_basic"; nodes.client = { @@ -168,13 +166,13 @@ in testScript = commonTestScript.access; }; - backup = pkgs.testers.runNixOSTest { + backup = lib.shb.runNixOSTest { name = "homeassistant_backup"; nodes.server = { config, ... }: { imports = [ basic - (testLib.backup config.shb.home-assistant.backup) + (lib.shb.backup config.shb.home-assistant.backup) ]; }; @@ -183,13 +181,13 @@ in testScript = commonTestScript.backup; }; - https = pkgs.testers.runNixOSTest { + https = lib.shb.runNixOSTest { name = "homeassistant_https"; nodes.server = { imports = [ basic - testLib.certs + lib.shb.certs https ]; }; @@ -199,13 +197,13 @@ in testScript = commonTestScript.access; }; - ldap = pkgs.testers.runNixOSTest { + ldap = lib.shb.runNixOSTest { name = "homeassistant_ldap"; nodes.server = { imports = [ basic - testLib.ldap + lib.shb.ldap ldap ]; }; @@ -217,16 +215,16 @@ in # Not yet supported # - # sso = pkgs.testers.runNixOSTest { + # sso = lib.shb.runNixOSTest { # name = "vaultwarden_sso"; # # nodes.server = lib.mkMerge [ # basic - # (testLib.certs domain) + # (lib.shb.certs domain) # https # ldap - # (testLib.ldap domain pkgs') - # (testLib.sso domain pkgs' config.shb.certs.certs.selfsigned.n) + # (lib.shb.ldap domain pkgs') + # (lib.shb.sso domain pkgs' config.shb.certs.certs.selfsigned.n) # sso # ]; # @@ -235,7 +233,7 @@ in # testScript = commonTestScript.access; # }; - voice = pkgs.testers.runNixOSTest { + voice = lib.shb.runNixOSTest { name = "homeassistant_voice"; nodes.server = { diff --git a/test/services/immich.nix b/test/services/immich.nix index a249296..8e60b8a 100644 --- a/test/services/immich.nix +++ b/test/services/immich.nix @@ -1,11 +1,9 @@ { pkgs, lib }: let - testLib = pkgs.callPackage ../common.nix {}; - subdomain = "i"; domain = "example.com"; - commonTestScript = testLib.accessScript { + commonTestScript = lib.shb.accessScript { hasSSL = { node, ... }: !(isNull node.config.shb.immich.ssl); waitForServices = { ... }: [ "immich-server.service" "postgresql.service" "nginx.service" ]; waitForPorts = { ... }: [ 2283 80 ]; @@ -14,7 +12,7 @@ let base = { config, ... }: { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/services/immich.nix ]; @@ -45,7 +43,7 @@ let https = { config, ... }: { imports = [ base - testLib.certs + lib.shb.certs ]; test.hasSSL = true; @@ -55,15 +53,15 @@ let backup = { config, ... }: { imports = [ https - (testLib.backup config.shb.immich.backup) + (lib.shb.backup config.shb.immich.backup) ]; }; sso = { config, ... }: { imports = [ https - testLib.ldap - (testLib.sso config.shb.certs.certs.selfsigned.n) + lib.shb.ldap + (lib.shb.sso config.shb.certs.certs.selfsigned.n) ]; shb.immich.sso = { @@ -137,7 +135,7 @@ in nodes.server = backup; nodes.client = {}; - testScript = (testLib.mkScripts { + testScript = (lib.shb.mkScripts { hasSSL = args: !(isNull args.node.config.shb.immich.ssl); waitForServices = args: [ "immich-server.service" "postgresql.service" "nginx.service" ]; waitForPorts = args: [ 2283 80 ]; diff --git a/test/services/jellyfin.nix b/test/services/jellyfin.nix index 8324d5d..10a5052 100644 --- a/test/services/jellyfin.nix +++ b/test/services/jellyfin.nix @@ -1,10 +1,8 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: let - testLib = pkgs.callPackage ../common.nix {}; - port = 9096; - commonTestScript = testLib.mkScripts { + commonTestScript = lib.shb.mkScripts { hasSSL = { node, ... }: !(isNull node.config.shb.jellyfin.ssl); waitForServices = { ... }: [ "jellyfin.service" @@ -39,7 +37,7 @@ let basic = { config, ... }: { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/services/jellyfin.nix ]; test = { @@ -69,7 +67,7 @@ let clientLogin = { config, ... }: { imports = [ - testLib.clientLoginModule + lib.shb.clientLoginModule ]; virtualisation.memorySize = 4096; @@ -152,10 +150,9 @@ let }; }; - jellyfinTest = name: { nodes, testScript }: pkgs.testers.runNixOSTest { + jellyfinTest = name: { nodes, testScript }: lib.shb.runNixOSTest { name = "jellyfin_${name}"; - interactive.sshBackdoor.enable = true; interactive.nodes.server = { environment.systemPackages = [ pkgs.sqlite @@ -186,7 +183,7 @@ in nodes.server = { config, ... }: { imports = [ basic - (testLib.backup config.shb.jellyfin.backup) + (lib.shb.backup config.shb.jellyfin.backup) ]; }; @@ -199,14 +196,14 @@ in nodes.server = { imports = [ basic - testLib.certs + lib.shb.certs https ]; }; nodes.client = { config, lib, ... }: { imports = [ - testLib.baseModule + lib.shb.baseModule clientLogin ]; }; @@ -218,7 +215,7 @@ in nodes.server = { imports = [ basic - testLib.ldap + lib.shb.ldap ldap ]; }; @@ -232,10 +229,10 @@ in nodes.server = { config, pkgs, ... }: { imports = [ basic - testLib.certs + lib.shb.certs https - testLib.ldap - (testLib.sso config.shb.certs.certs.selfsigned.n) + lib.shb.ldap + (lib.shb.sso config.shb.certs.certs.selfsigned.n) sso ]; }; diff --git a/test/services/monitoring.nix b/test/services/monitoring.nix index 112518f..39e66a0 100644 --- a/test/services/monitoring.nix +++ b/test/services/monitoring.nix @@ -1,10 +1,8 @@ -{ pkgs, ... }: +{ lib, ... }: let - testLib = pkgs.callPackage ../common.nix {}; - password = "securepw"; - commonTestScript = testLib.accessScript { + commonTestScript = lib.shb.accessScript { hasSSL = { node, ... }: !(isNull node.config.shb.monitoring.ssl); waitForServices = { ... }: [ "grafana.service" @@ -45,12 +43,12 @@ let }; in { - basic = pkgs.testers.runNixOSTest { + basic = lib.shb.runNixOSTest { name = "monitoring_basic"; nodes.server = { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/blocks/monitoring.nix basic ]; @@ -61,14 +59,14 @@ in testScript = commonTestScript; }; - https = pkgs.testers.runNixOSTest { + https = lib.shb.runNixOSTest { name = "monitoring_https"; nodes.server = { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/blocks/monitoring.nix - testLib.certs + lib.shb.certs basic https ]; diff --git a/test/services/nextcloud.nix b/test/services/nextcloud.nix index dba441f..0d5e4da 100644 --- a/test/services/nextcloud.nix +++ b/test/services/nextcloud.nix @@ -1,12 +1,10 @@ -{ pkgs, lib, ... }: +{ lib, ... }: let adminUser = "root"; adminPass = "rootpw"; oidcSecret = "oidcSecret"; - testLib = pkgs.callPackage ../common.nix {}; - - commonTestScript = testLib.mkScripts { + commonTestScript = lib.shb.mkScripts { hasSSL = { node, ... }: !(isNull node.config.shb.nextcloud.ssl); waitForServices = { ... }: [ "phpfpm-nextcloud.service" @@ -91,7 +89,7 @@ let basic = { config, ... }: { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/services/nextcloud-server.nix ]; @@ -123,8 +121,8 @@ let clientLogin = { config, ... }: { imports = [ - testLib.baseModule - testLib.clientLoginModule + lib.shb.baseModule + lib.shb.clientLoginModule ]; virtualisation.memorySize = 4096; @@ -153,8 +151,8 @@ let clientLdapLogin = { config, ... }: { imports = [ - testLib.baseModule - testLib.clientLoginModule + lib.shb.baseModule + lib.shb.clientLoginModule ]; virtualisation.memorySize = 4096; @@ -190,8 +188,8 @@ let clientSsoLogin = { config, ... }: { imports = [ - testLib.baseModule - testLib.clientLoginModule + lib.shb.baseModule + lib.shb.clientLoginModule ]; virtualisation.memorySize = 4096; @@ -365,7 +363,7 @@ let ''; in { - basic = pkgs.testers.runNixOSTest { + basic = lib.shb.runNixOSTest { name = "nextcloud_basic"; nodes.client = { @@ -382,7 +380,7 @@ in testScript = commonTestScript.access; }; - cron = pkgs.testers.runNixOSTest { + cron = lib.shb.runNixOSTest { name = "nextcloud_cron"; nodes.server = { @@ -418,13 +416,13 @@ in }; }; - backup = pkgs.testers.runNixOSTest { + backup = lib.shb.runNixOSTest { name = "nextcloud_backup"; nodes.server = { config, ... }: { imports = [ basic - (testLib.backup config.shb.nextcloud.backup) + (lib.shb.backup config.shb.nextcloud.backup) ]; }; @@ -433,13 +431,13 @@ in testScript = commonTestScript.backup; }; - https = pkgs.testers.runNixOSTest { + https = lib.shb.runNixOSTest { name = "nextcloud_https"; nodes.server = { imports = [ basic - testLib.certs + lib.shb.certs https ]; }; @@ -450,13 +448,13 @@ in testScript = commonTestScript.access; }; - previewGenerator = pkgs.testers.runNixOSTest { + previewGenerator = lib.shb.runNixOSTest { name = "nextcloud_previewGenerator"; nodes.server = { imports = [ basic - testLib.certs + lib.shb.certs https previewgenerator ]; @@ -467,13 +465,13 @@ in testScript = commonTestScript.access; }; - externalStorage = pkgs.testers.runNixOSTest { + externalStorage = lib.shb.runNixOSTest { name = "nextcloud_externalStorage"; nodes.server = { imports = [ basic - testLib.certs + lib.shb.certs https externalstorage ]; @@ -487,13 +485,13 @@ in # TODO: fix memories app # See https://github.com/ibizaman/selfhostblocks/issues/476 - # memories = pkgs.testers.runNixOSTest { + # memories = lib.shb.runNixOSTest { # name = "nextcloud_memories"; # nodes.server = { # imports = [ # basic - # testLib.certs + # lib.shb.certs # https # memories # ]; @@ -504,13 +502,13 @@ in # testScript = commonTestScript.access; # }; - recognize = pkgs.testers.runNixOSTest { + recognize = lib.shb.runNixOSTest { name = "nextcloud_recognize"; nodes.server = { imports = [ basic - testLib.certs + lib.shb.certs https recognize ]; @@ -521,15 +519,15 @@ in testScript = commonTestScript.access; }; - ldap = pkgs.testers.runNixOSTest { + ldap = lib.shb.runNixOSTest { name = "nextcloud_ldap"; nodes.server = { config, ... }: { imports = [ basic - testLib.certs + lib.shb.certs https - testLib.ldap + lib.shb.ldap ldap ]; }; @@ -543,18 +541,16 @@ in testScript = commonTestScript.access; }; - sso = pkgs.testers.runNixOSTest { + sso = lib.shb.runNixOSTest { name = "nextcloud_sso"; - interactive.sshBackdoor.enable = true; - nodes.server = { config, ... }: { imports = [ basic - testLib.certs + lib.shb.certs https - testLib.ldap - (testLib.sso config.shb.certs.certs.selfsigned.n) + lib.shb.ldap + (lib.shb.sso config.shb.certs.certs.selfsigned.n) sso ({ config, ... }: { networking.hosts = { @@ -578,7 +574,7 @@ in testScript = commonTestScript.access; }; - prometheus = pkgs.testers.runNixOSTest { + prometheus = lib.shb.runNixOSTest { name = "nextcloud_prometheus"; nodes.server = { config, ... }: { diff --git a/test/services/open-webui.nix b/test/services/open-webui.nix index 23caf9d..07f3fa0 100644 --- a/test/services/open-webui.nix +++ b/test/services/open-webui.nix @@ -1,10 +1,8 @@ -{ pkgs, ... }: +{ lib, ... }: let oidcSecret = "oidcSecret"; - testLib = pkgs.callPackage ../common.nix {}; - - commonTestScript = testLib.mkScripts { + commonTestScript = lib.shb.mkScripts { hasSSL = { node, ... }: !(isNull node.config.shb.open-webui.ssl); waitForServices = { ... }: [ "open-webui.service" @@ -17,7 +15,7 @@ let basic = { config, ... }: { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/blocks/hardcodedsecret.nix ../../modules/services/open-webui.nix ]; @@ -58,8 +56,8 @@ let clientLoginSso = { config, ... }: { imports = [ - testLib.baseModule - testLib.clientLoginModule + lib.shb.baseModule + lib.shb.clientLoginModule ]; virtualisation.memorySize = 4096; test = { @@ -127,7 +125,7 @@ let }; in { - basic = pkgs.testers.runNixOSTest { + basic = lib.shb.runNixOSTest { name = "open-webui_basic"; nodes.client = {}; @@ -140,13 +138,13 @@ in testScript = commonTestScript.access; }; - backup = pkgs.testers.runNixOSTest { + backup = lib.shb.runNixOSTest { name = "open-webui_backup"; nodes.server = { config, ... }: { imports = [ basic - (testLib.backup config.shb.open-webui.backup) + (lib.shb.backup config.shb.open-webui.backup) ]; }; @@ -155,14 +153,14 @@ in testScript = commonTestScript.backup; }; - https = pkgs.testers.runNixOSTest { + https = lib.shb.runNixOSTest { name = "open-webui_https"; nodes.client = {}; nodes.server = { imports = [ basic - testLib.certs + lib.shb.certs https ]; }; @@ -170,9 +168,8 @@ in testScript = commonTestScript.access; }; - sso = pkgs.testers.runNixOSTest { + sso = lib.shb.runNixOSTest { name = "open-webui_sso"; - interactive.sshBackdoor.enable = true; nodes.client = { imports = [ @@ -182,11 +179,11 @@ in nodes.server = { config, pkgs, ... }: { imports = [ basic - testLib.certs + lib.shb.certs https - testLib.ldap + lib.shb.ldap ldap - (testLib.sso config.shb.certs.certs.selfsigned.n) + (lib.shb.sso config.shb.certs.certs.selfsigned.n) sso ]; }; diff --git a/test/services/pinchflat.nix b/test/services/pinchflat.nix index 39baf4d..5f3ea46 100644 --- a/test/services/pinchflat.nix +++ b/test/services/pinchflat.nix @@ -1,8 +1,6 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: let - testLib = pkgs.callPackage ../common.nix {}; - - commonTestScript = testLib.mkScripts { + commonTestScript = lib.shb.mkScripts { hasSSL = { node, ... }: !(isNull node.config.shb.pinchflat.ssl); waitForServices = { ... }: [ "pinchflat.service" @@ -15,7 +13,7 @@ let basic = { config, ... }: { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/blocks/hardcodedsecret.nix ../../modules/services/pinchflat.nix ]; @@ -49,8 +47,8 @@ let clientLogin = { config, ... }: { imports = [ - testLib.baseModule - testLib.clientLoginModule + lib.shb.baseModule + lib.shb.clientLoginModule ]; test = { subdomain = "p"; @@ -85,8 +83,8 @@ let clientLoginSso = { config, ... }: { imports = [ - testLib.baseModule - testLib.clientLoginModule + lib.shb.baseModule + lib.shb.clientLoginModule ]; test = { subdomain = "p"; @@ -134,7 +132,7 @@ let }; in { - basic = pkgs.testers.runNixOSTest { + basic = lib.shb.runNixOSTest { name = "pinchflat_basic"; nodes.client = { @@ -151,13 +149,13 @@ in testScript = commonTestScript.access; }; - backup = pkgs.testers.runNixOSTest { + backup = lib.shb.runNixOSTest { name = "pinchflat_backup"; nodes.server = { config, ... }: { imports = [ basic - (testLib.backup config.shb.pinchflat.backup) + (lib.shb.backup config.shb.pinchflat.backup) ]; }; @@ -166,7 +164,7 @@ in testScript = commonTestScript.backup; }; - https = pkgs.testers.runNixOSTest { + https = lib.shb.runNixOSTest { name = "pinchflat_https"; nodes.client = { @@ -177,7 +175,7 @@ in nodes.server = { imports = [ basic - testLib.certs + lib.shb.certs https ]; }; @@ -185,7 +183,7 @@ in testScript = commonTestScript.access; }; - sso = pkgs.testers.runNixOSTest { + sso = lib.shb.runNixOSTest { name = "pinchflat_sso"; nodes.client = { @@ -196,11 +194,11 @@ in nodes.server = { config, pkgs, ... }: { imports = [ basic - testLib.certs + lib.shb.certs https - testLib.ldap + lib.shb.ldap ldap - (testLib.sso config.shb.certs.certs.selfsigned.n) + (lib.shb.sso config.shb.certs.certs.selfsigned.n) sso ]; }; diff --git a/test/services/vaultwarden.nix b/test/services/vaultwarden.nix index 155e94b..759715d 100644 --- a/test/services/vaultwarden.nix +++ b/test/services/vaultwarden.nix @@ -1,8 +1,6 @@ -{ pkgs, ... }: +{ lib, ... }: let - testLib = pkgs.callPackage ../common.nix {}; - - commonTestScript = testLib.mkScripts { + commonTestScript = lib.shb.mkScripts { hasSSL = { node, ... }: !(isNull node.config.shb.vaultwarden.ssl); waitForServices = { ... }: [ "vaultwarden.service" @@ -87,12 +85,12 @@ let }; in { - basic = pkgs.testers.runNixOSTest { + basic = lib.shb.runNixOSTest { name = "vaultwarden_basic"; nodes.server = { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/blocks/hardcodedsecret.nix ../../modules/services/vaultwarden.nix basic @@ -104,15 +102,15 @@ in testScript = commonTestScript.access; }; - https = pkgs.testers.runNixOSTest { + https = lib.shb.runNixOSTest { name = "vaultwarden_https"; nodes.server = { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/blocks/hardcodedsecret.nix ../../modules/services/vaultwarden.nix - testLib.certs + lib.shb.certs basic https ]; @@ -125,11 +123,11 @@ in # Not yet supported # - # ldap = pkgs.testers.runNixOSTest { + # ldap = lib.shb.runNixOSTest { # name = "vaultwarden_ldap"; # # nodes.server = lib.mkMerge [ - # testLib.baseModule + # lib.shb.baseModule # ../../modules/blocks/hardcodedsecret.nix # ../../modules/services/vaultwarden.nix # basic @@ -141,19 +139,19 @@ in # testScript = commonTestScript.access; # }; - sso = pkgs.testers.runNixOSTest { + sso = lib.shb.runNixOSTest { name = "vaultwarden_sso"; nodes.server = { config, ... }: { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/blocks/hardcodedsecret.nix ../../modules/services/vaultwarden.nix - testLib.certs + lib.shb.certs basic https - testLib.ldap - (testLib.sso config.shb.certs.certs.selfsigned.n) + lib.shb.ldap + (lib.shb.sso config.shb.certs.certs.selfsigned.n) sso ]; }; @@ -180,16 +178,16 @@ in }; }; - backup = pkgs.testers.runNixOSTest { + backup = lib.shb.runNixOSTest { name = "vaultwarden_backup"; nodes.server = { config, ... }: { imports = [ - testLib.baseModule + lib.shb.baseModule ../../modules/blocks/hardcodedsecret.nix ../../modules/services/vaultwarden.nix basic - (testLib.backup config.shb.vaultwarden.backup) + (lib.shb.backup config.shb.vaultwarden.backup) ]; };