From b171cf8abac0b59f5d9020cb33362a09faf9e15e Mon Sep 17 00:00:00 2001 From: ibizaman Date: Sat, 30 Nov 2024 01:50:52 +0100 Subject: [PATCH 1/4] add test for hledger --- flake.nix | 1 + modules/services/hledger.nix | 4 +- test/services/hledger.nix | 114 +++++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 test/services/hledger.nix diff --git a/flake.nix b/flake.nix index 01e0316..307b4a6 100644 --- a/flake.nix +++ b/flake.nix @@ -124,6 +124,7 @@ // (vm_test "deluge" ./test/services/deluge.nix) // (vm_test "forgejo" ./test/services/forgejo.nix) // (vm_test "grocy" ./test/services/grocy.nix) + // (vm_test "hledger" ./test/services/hledger.nix) // (vm_test "homeassistant" ./test/services/home-assistant.nix) // (vm_test "jellyfin" ./test/services/jellyfin.nix) // (vm_test "monitoring" ./test/services/monitoring.nix) diff --git a/modules/services/hledger.nix b/modules/services/hledger.nix index 99bbd03..efdd801 100644 --- a/modules/services/hledger.nix +++ b/modules/services/hledger.nix @@ -49,15 +49,17 @@ in }; authEndpoint = lib.mkOption { - type = lib.types.str; + type = lib.types.nullOr lib.types.str; description = "OIDC endpoint for SSO"; example = "https://authelia.example.com"; + default = null; }; backup = lib.mkOption { description = '' Backup configuration. ''; + default = {}; type = lib.types.submodule { options = contracts.backup.mkRequester { user = "hledger"; diff --git a/test/services/hledger.nix b/test/services/hledger.nix new file mode 100644 index 0000000..dfae061 --- /dev/null +++ b/test/services/hledger.nix @@ -0,0 +1,114 @@ +{ pkgs, ... }: +let + pkgs' = pkgs; + + testLib = pkgs.callPackage ../common.nix {}; + + subdomain = "h"; + domain = "example.com"; + + adminPassword = "AdminPassword"; + + commonTestScript = testLib.mkScripts { + inherit subdomain domain; + hasSSL = { node, ... }: !(isNull node.config.shb.hledger.ssl); + waitForServices = { ... }: [ + "hledger-web.service" + "nginx.service" + ]; + }; + + base = testLib.base pkgs' [ + ../../modules/services/hledger.nix + ]; + + basic = { config, ... }: { + shb.hledger = { + enable = true; + inherit domain subdomain; + }; + }; + + https = { config, ... }: { + shb.hledger = { + ssl = config.shb.certs.certs.selfsigned.n; + }; + }; + + sso = { config, ... }: { + shb.hledger = { + authEndpoint = "https://${config.shb.authelia.subdomain}.${config.shb.authelia.domain}"; + }; + }; +in +{ + basic = pkgs.testers.runNixOSTest { + name = "hledger_basic"; + + nodes.server = { + imports = [ + base + basic + ]; + }; + + nodes.client = {}; + + testScript = commonTestScript.access; + }; + + backup = pkgs.testers.runNixOSTest { + name = "hledger_backup"; + + nodes.server = { config, ... }: { + imports = [ + base + basic + (testLib.backup config.shb.hledger.backup) + ]; + }; + + nodes.client = {}; + + testScript = commonTestScript.backup; + }; + + https = pkgs.testers.runNixOSTest { + name = "hledger_https"; + + nodes.server = { + imports = [ + base + (testLib.certs domain) + basic + https + ]; + }; + + nodes.client = {}; + + testScript = commonTestScript.access; + }; + + sso = pkgs.testers.runNixOSTest { + name = "hledger_sso"; + + nodes.server = { config, pkgs, ... }: { + imports = [ + base + (testLib.certs domain) + basic + https + (testLib.ldap domain pkgs') + (testLib.sso domain pkgs' config.shb.certs.certs.selfsigned.n) + sso + ]; + }; + + nodes.client = {}; + + testScript = commonTestScript.access.override { + redirectSSO = true; + }; + }; +} From 65d911d76c86b47ce77f049f4befe8fe6a4929b8 Mon Sep 17 00:00:00 2001 From: ibizaman Date: Sat, 30 Nov 2024 01:51:11 +0100 Subject: [PATCH 2/4] add backup test for deluge --- modules/services/deluge.nix | 1 + test/services/deluge.nix | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/modules/services/deluge.nix b/modules/services/deluge.nix index 11256b1..2335d24 100644 --- a/modules/services/deluge.nix +++ b/modules/services/deluge.nix @@ -247,6 +247,7 @@ in description = '' Backup configuration. ''; + default = {}; type = lib.types.submodule { options = contracts.backup.mkRequester { user = "deluge"; diff --git a/test/services/deluge.nix b/test/services/deluge.nix index a82ba7a..f124e94 100644 --- a/test/services/deluge.nix +++ b/test/services/deluge.nix @@ -7,7 +7,7 @@ let testLib = pkgs.callPackage ../common.nix {}; - commonTestScript = lib.makeOverridable testLib.accessScript { + commonTestScript = testLib.mkScripts { inherit subdomain domain; hasSSL = { node, ... }: !(isNull node.config.shb.deluge.ssl); waitForServices = { ... }: [ @@ -134,7 +134,23 @@ in nodes.client = {}; - testScript = commonTestScript; + testScript = commonTestScript.access; + }; + + backup = pkgs.testers.runNixOSTest { + name = "deluge_backup"; + + nodes.server = { config, ... }: { + imports = [ + base + basic + (testLib.backup config.shb.deluge.backup) + ]; + }; + + nodes.client = {}; + + testScript = commonTestScript.backup; }; https = pkgs.testers.runNixOSTest { @@ -151,7 +167,7 @@ in nodes.client = {}; - testScript = commonTestScript; + testScript = commonTestScript.access; }; sso = pkgs.testers.runNixOSTest { @@ -171,7 +187,7 @@ in nodes.client = {}; - testScript = commonTestScript.override { + testScript = commonTestScript.access.override { redirectSSO = true; }; }; @@ -192,7 +208,7 @@ in nodes.client = {}; testScript = inputs: - (commonTestScript inputs) + (commonTestScript.access inputs) + (prometheusTestScript inputs); }; } From ccf397c0392fcff778e1db86fd0cc2a92f2de042 Mon Sep 17 00:00:00 2001 From: ibizaman Date: Sat, 30 Nov 2024 01:51:20 +0100 Subject: [PATCH 3/4] add backup test for arr suite --- modules/services/arr.nix | 2 ++ test/modules/arr.nix | 2 ++ test/services/arr.nix | 76 ++++++++++++++++++++++++++-------------- 3 files changed, 53 insertions(+), 27 deletions(-) diff --git a/modules/services/arr.nix b/modules/services/arr.nix index f5c58ea..b08b793 100644 --- a/modules/services/arr.nix +++ b/modules/services/arr.nix @@ -267,6 +267,7 @@ let policy = "bypass"; resources = extraBypassResources ++ [ "^/api.*" + "^/feed.*" ]; } { @@ -319,6 +320,7 @@ let description = '' Backup configuration. ''; + default = {}; type = lib.types.submodule { options = contracts.backup.mkRequester { user = name; diff --git a/test/modules/arr.nix b/test/modules/arr.nix index bc90ee1..262909a 100644 --- a/test/modules/arr.nix +++ b/test/modules/arr.nix @@ -66,6 +66,7 @@ in policy = "bypass"; resources = [ "^/api.*" + "^/feed.*" ]; } { @@ -124,6 +125,7 @@ in policy = "bypass"; resources = [ "^/api.*" + "^/feed.*" ]; } { diff --git a/test/services/arr.nix b/test/services/arr.nix index 42d9baa..8d0531a 100644 --- a/test/services/arr.nix +++ b/test/services/arr.nix @@ -13,7 +13,7 @@ let let subdomain = appname; fqdn = "${subdomain}.${domain}"; - in lib.makeOverridable testLib.accessScript { + in testLib.mkScripts { inherit subdomain domain; hasSSL = { node, ... }: !(isNull node.config.shb.arr.${appname}.ssl); waitForServices = { ... }: [ @@ -76,7 +76,23 @@ let nodes.client = {}; - testScript = commonTestScript appname cfgPathFn; + testScript = (commonTestScript appname cfgPathFn).access; + }; + + backupTest = appname: cfgPathFn: pkgs.testers.runNixOSTest { + name = "arr_${appname}_backup"; + + nodes.server = { config, ... }: { + imports = [ + base + (basic appname) + (testLib.backup config.shb.arr.${appname}.backup) + ]; + }; + + nodes.client = {}; + + testScript = (commonTestScript appname cfgPathFn).backup; }; https = appname: { config, ...}: { @@ -99,7 +115,7 @@ let nodes.client = {}; - testScript = commonTestScript appname cfgPathFn; + testScript = (commonTestScript appname cfgPathFn).access; }; sso = appname: { config, ...}: { @@ -125,7 +141,7 @@ let nodes.client = {}; - testScript = (commonTestScript appname cfgPathFn).override { + testScript = (commonTestScript appname cfgPathFn).access.override { redirectSSO = true; }; }; @@ -138,27 +154,33 @@ let jackettCfgFn = cfg: "${cfg.dataDir}/ServerConfig.json"; in { - radarr_basic = basicTest "radarr" radarrCfgFn; - radarr_https = httpsTest "radarr" radarrCfgFn; - radarr_sso = ssoTest "radarr" radarrCfgFn; - - sonarr_basic = basicTest "sonarr" sonarrCfgFn; - sonarr_https = httpsTest "sonarr" sonarrCfgFn; - sonarr_sso = ssoTest "sonarr" sonarrCfgFn; - - bazarr_basic = basicTest "bazarr" bazarrCfgFn; - bazarr_https = httpsTest "bazarr" bazarrCfgFn; - bazarr_sso = ssoTest "bazarr" bazarrCfgFn; - - readarr_basic = basicTest "readarr" readarrCfgFn; - readarr_https = httpsTest "readarr" readarrCfgFn; - readarr_sso = ssoTest "readarr" readarrCfgFn; - - lidarr_basic = basicTest "lidarr" lidarrCfgFn; - lidarr_https = httpsTest "lidarr" lidarrCfgFn; - lidarr_sso = ssoTest "lidarr" lidarrCfgFn; - - jackett_basic = basicTest "jackett" jackettCfgFn; - jackett_https = httpsTest "jackett" jackettCfgFn; - jackett_sso = ssoTest "jackett" jackettCfgFn; + radarr_basic = basicTest "radarr" radarrCfgFn; + radarr_backup = backupTest "radarr" radarrCfgFn; + radarr_https = httpsTest "radarr" radarrCfgFn; + radarr_sso = ssoTest "radarr" radarrCfgFn; + + sonarr_basic = basicTest "sonarr" sonarrCfgFn; + sonarr_backup = backupTest "sonarr" sonarrCfgFn; + sonarr_https = httpsTest "sonarr" sonarrCfgFn; + sonarr_sso = ssoTest "sonarr" sonarrCfgFn; + + bazarr_basic = basicTest "bazarr" bazarrCfgFn; + bazarr_backup = backupTest "bazarr" bazarrCfgFn; + bazarr_https = httpsTest "bazarr" bazarrCfgFn; + bazarr_sso = ssoTest "bazarr" bazarrCfgFn; + + readarr_basic = basicTest "readarr" readarrCfgFn; + readarr_backup = backupTest "readarr" readarrCfgFn; + readarr_https = httpsTest "readarr" readarrCfgFn; + readarr_sso = ssoTest "readarr" readarrCfgFn; + + lidarr_basic = basicTest "lidarr" lidarrCfgFn; + lidarr_backup = backupTest "lidarr" lidarrCfgFn; + lidarr_https = httpsTest "lidarr" lidarrCfgFn; + lidarr_sso = ssoTest "lidarr" lidarrCfgFn; + + jackett_basic = basicTest "jackett" jackettCfgFn; + jackett_backup = backupTest "jackett" jackettCfgFn; + jackett_https = httpsTest "jackett" jackettCfgFn; + jackett_sso = ssoTest "jackett" jackettCfgFn; } From f7eb0c443a227aa62872e071758e3506b7d18d79 Mon Sep 17 00:00:00 2001 From: ibizaman Date: Sat, 30 Nov 2024 01:53:20 +0100 Subject: [PATCH 4/4] bump selfhostblocks to v0.2.5 --- CHANGELOG.md | 6 ++++++ VERSION | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bef5257..d08a4e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,12 @@ Template: # Upcoming Release +# v0.2.5 + +## Other Changes + +- Fix more modules using backup contract. + # v0.2.4 ## Other Changes diff --git a/VERSION b/VERSION index 72f9fa8..28af839 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.4 \ No newline at end of file +0.2.5 \ No newline at end of file