test: merge functions into lib and set backdoor everywhere

This commit is contained in:
ibizaman 2025-10-11 22:23:28 +02:00 committed by Pierre Penninckx
parent 9892f55ae2
commit 283e12d87d
28 changed files with 238 additions and 272 deletions

View file

@ -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 { ... };
}
```

View file

@ -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 {};
};
}
);

View file

@ -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 {

View file

@ -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;

View file

@ -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 = {

View file

@ -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, ... }: {

View file

@ -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, ... }:
{

View file

@ -6,7 +6,7 @@ let
charliePassword = "CharliePassword";
in
{
auth = pkgs.testers.runNixOSTest {
auth = lib.shb.runNixOSTest {
name = "ldap-auth";
nodes.server = { config, pkgs, ... }: {

View file

@ -39,7 +39,7 @@ let
);
in
{
default = pkgs.testers.runNixOSTest {
default = lib.shb.runNixOSTest {
name = "mitmdump-default";
nodes.machine = { config, pkgs, ... }: {

View file

@ -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, ... }: {

View file

@ -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, ... }: {

View file

@ -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, ... }: {

View file

@ -151,6 +151,10 @@ in
{
inherit baseImports accessScript;
runNixOSTest = args: pkgs.testers.runNixOSTest ({
interactive.sshBackdoor.enable = true;
} // args);
mkScripts = args:
{
access = accessScript args;

View file

@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ pkgs, ... }:
let
contracts = pkgs.callPackage ../../modules/contracts {};
in

View file

@ -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)
];
};

View file

@ -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
];
};

View file

@ -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
];

View file

@ -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
];
};

View file

@ -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
];
};

View file

@ -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
];
};

View file

@ -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 = {

View file

@ -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 ];

View file

@ -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
];
};

View file

@ -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
];

View file

@ -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, ... }: {

View file

@ -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
];
};

View file

@ -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
];
};

View file

@ -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)
];
};