fix modules using backup contract (#386)

Co-authored-by: ibizaman <ibizapeanut@gmail.com>
This commit is contained in:
Pierre Penninckx 2024-11-30 02:07:08 +01:00 committed by GitHub
parent 260b5027b1
commit 30aa5dcc11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 195 additions and 29 deletions

View file

@ -14,6 +14,12 @@ Template:
# Upcoming Release # Upcoming Release
# v0.2.5
## Other Changes
- Fix more modules using backup contract.
# v0.2.4 # v0.2.4
## Other Changes ## Other Changes

View file

@ -1 +1 @@
0.2.4 0.2.5

View file

@ -124,6 +124,7 @@
// (vm_test "deluge" ./test/services/deluge.nix) // (vm_test "deluge" ./test/services/deluge.nix)
// (vm_test "forgejo" ./test/services/forgejo.nix) // (vm_test "forgejo" ./test/services/forgejo.nix)
// (vm_test "grocy" ./test/services/grocy.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 "homeassistant" ./test/services/home-assistant.nix)
// (vm_test "jellyfin" ./test/services/jellyfin.nix) // (vm_test "jellyfin" ./test/services/jellyfin.nix)
// (vm_test "monitoring" ./test/services/monitoring.nix) // (vm_test "monitoring" ./test/services/monitoring.nix)

View file

@ -267,6 +267,7 @@ let
policy = "bypass"; policy = "bypass";
resources = extraBypassResources ++ [ resources = extraBypassResources ++ [
"^/api.*" "^/api.*"
"^/feed.*"
]; ];
} }
{ {
@ -319,6 +320,7 @@ let
description = '' description = ''
Backup configuration. Backup configuration.
''; '';
default = {};
type = lib.types.submodule { type = lib.types.submodule {
options = contracts.backup.mkRequester { options = contracts.backup.mkRequester {
user = name; user = name;

View file

@ -247,6 +247,7 @@ in
description = '' description = ''
Backup configuration. Backup configuration.
''; '';
default = {};
type = lib.types.submodule { type = lib.types.submodule {
options = contracts.backup.mkRequester { options = contracts.backup.mkRequester {
user = "deluge"; user = "deluge";

View file

@ -49,15 +49,17 @@ in
}; };
authEndpoint = lib.mkOption { authEndpoint = lib.mkOption {
type = lib.types.str; type = lib.types.nullOr lib.types.str;
description = "OIDC endpoint for SSO"; description = "OIDC endpoint for SSO";
example = "https://authelia.example.com"; example = "https://authelia.example.com";
default = null;
}; };
backup = lib.mkOption { backup = lib.mkOption {
description = '' description = ''
Backup configuration. Backup configuration.
''; '';
default = {};
type = lib.types.submodule { type = lib.types.submodule {
options = contracts.backup.mkRequester { options = contracts.backup.mkRequester {
user = "hledger"; user = "hledger";

View file

@ -66,6 +66,7 @@ in
policy = "bypass"; policy = "bypass";
resources = [ resources = [
"^/api.*" "^/api.*"
"^/feed.*"
]; ];
} }
{ {
@ -124,6 +125,7 @@ in
policy = "bypass"; policy = "bypass";
resources = [ resources = [
"^/api.*" "^/api.*"
"^/feed.*"
]; ];
} }
{ {

View file

@ -13,7 +13,7 @@ let
let let
subdomain = appname; subdomain = appname;
fqdn = "${subdomain}.${domain}"; fqdn = "${subdomain}.${domain}";
in lib.makeOverridable testLib.accessScript { in testLib.mkScripts {
inherit subdomain domain; inherit subdomain domain;
hasSSL = { node, ... }: !(isNull node.config.shb.arr.${appname}.ssl); hasSSL = { node, ... }: !(isNull node.config.shb.arr.${appname}.ssl);
waitForServices = { ... }: [ waitForServices = { ... }: [
@ -76,7 +76,23 @@ let
nodes.client = {}; 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, ...}: { https = appname: { config, ...}: {
@ -99,7 +115,7 @@ let
nodes.client = {}; nodes.client = {};
testScript = commonTestScript appname cfgPathFn; testScript = (commonTestScript appname cfgPathFn).access;
}; };
sso = appname: { config, ...}: { sso = appname: { config, ...}: {
@ -125,7 +141,7 @@ let
nodes.client = {}; nodes.client = {};
testScript = (commonTestScript appname cfgPathFn).override { testScript = (commonTestScript appname cfgPathFn).access.override {
redirectSSO = true; redirectSSO = true;
}; };
}; };
@ -138,27 +154,33 @@ let
jackettCfgFn = cfg: "${cfg.dataDir}/ServerConfig.json"; jackettCfgFn = cfg: "${cfg.dataDir}/ServerConfig.json";
in in
{ {
radarr_basic = basicTest "radarr" radarrCfgFn; radarr_basic = basicTest "radarr" radarrCfgFn;
radarr_https = httpsTest "radarr" radarrCfgFn; radarr_backup = backupTest "radarr" radarrCfgFn;
radarr_sso = ssoTest "radarr" radarrCfgFn; radarr_https = httpsTest "radarr" radarrCfgFn;
radarr_sso = ssoTest "radarr" radarrCfgFn;
sonarr_basic = basicTest "sonarr" sonarrCfgFn; sonarr_basic = basicTest "sonarr" sonarrCfgFn;
sonarr_https = httpsTest "sonarr" sonarrCfgFn; sonarr_backup = backupTest "sonarr" sonarrCfgFn;
sonarr_sso = ssoTest "sonarr" sonarrCfgFn; sonarr_https = httpsTest "sonarr" sonarrCfgFn;
sonarr_sso = ssoTest "sonarr" sonarrCfgFn;
bazarr_basic = basicTest "bazarr" bazarrCfgFn; bazarr_basic = basicTest "bazarr" bazarrCfgFn;
bazarr_https = httpsTest "bazarr" bazarrCfgFn; bazarr_backup = backupTest "bazarr" bazarrCfgFn;
bazarr_sso = ssoTest "bazarr" bazarrCfgFn; bazarr_https = httpsTest "bazarr" bazarrCfgFn;
bazarr_sso = ssoTest "bazarr" bazarrCfgFn;
readarr_basic = basicTest "readarr" readarrCfgFn; readarr_basic = basicTest "readarr" readarrCfgFn;
readarr_https = httpsTest "readarr" readarrCfgFn; readarr_backup = backupTest "readarr" readarrCfgFn;
readarr_sso = ssoTest "readarr" readarrCfgFn; readarr_https = httpsTest "readarr" readarrCfgFn;
readarr_sso = ssoTest "readarr" readarrCfgFn;
lidarr_basic = basicTest "lidarr" lidarrCfgFn; lidarr_basic = basicTest "lidarr" lidarrCfgFn;
lidarr_https = httpsTest "lidarr" lidarrCfgFn; lidarr_backup = backupTest "lidarr" lidarrCfgFn;
lidarr_sso = ssoTest "lidarr" lidarrCfgFn; lidarr_https = httpsTest "lidarr" lidarrCfgFn;
lidarr_sso = ssoTest "lidarr" lidarrCfgFn;
jackett_basic = basicTest "jackett" jackettCfgFn; jackett_basic = basicTest "jackett" jackettCfgFn;
jackett_https = httpsTest "jackett" jackettCfgFn; jackett_backup = backupTest "jackett" jackettCfgFn;
jackett_sso = ssoTest "jackett" jackettCfgFn; jackett_https = httpsTest "jackett" jackettCfgFn;
jackett_sso = ssoTest "jackett" jackettCfgFn;
} }

View file

@ -7,7 +7,7 @@ let
testLib = pkgs.callPackage ../common.nix {}; testLib = pkgs.callPackage ../common.nix {};
commonTestScript = lib.makeOverridable testLib.accessScript { commonTestScript = testLib.mkScripts {
inherit subdomain domain; inherit subdomain domain;
hasSSL = { node, ... }: !(isNull node.config.shb.deluge.ssl); hasSSL = { node, ... }: !(isNull node.config.shb.deluge.ssl);
waitForServices = { ... }: [ waitForServices = { ... }: [
@ -134,7 +134,23 @@ in
nodes.client = {}; 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 { https = pkgs.testers.runNixOSTest {
@ -151,7 +167,7 @@ in
nodes.client = {}; nodes.client = {};
testScript = commonTestScript; testScript = commonTestScript.access;
}; };
sso = pkgs.testers.runNixOSTest { sso = pkgs.testers.runNixOSTest {
@ -171,7 +187,7 @@ in
nodes.client = {}; nodes.client = {};
testScript = commonTestScript.override { testScript = commonTestScript.access.override {
redirectSSO = true; redirectSSO = true;
}; };
}; };
@ -192,7 +208,7 @@ in
nodes.client = {}; nodes.client = {};
testScript = inputs: testScript = inputs:
(commonTestScript inputs) (commonTestScript.access inputs)
+ (prometheusTestScript inputs); + (prometheusTestScript inputs);
}; };
} }

114
test/services/hledger.nix Normal file
View file

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