Skip to content

Commit

Permalink
fix modules using backup contract (#386)
Browse files Browse the repository at this point in the history
Co-authored-by: ibizaman <ibizapeanut@gmail.com>
  • Loading branch information
ibizaman and ibizaman authored Nov 30, 2024
1 parent 260b502 commit 30aa5dc
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 34 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Template:

# Upcoming Release

# v0.2.5

## Other Changes

- Fix more modules using backup contract.

# v0.2.4

## Other Changes
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.4
0.2.5
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions modules/services/arr.nix
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ let
policy = "bypass";
resources = extraBypassResources ++ [
"^/api.*"
"^/feed.*"
];
}
{
Expand Down Expand Up @@ -319,6 +320,7 @@ let
description = ''
Backup configuration.
'';
default = {};
type = lib.types.submodule {
options = contracts.backup.mkRequester {
user = name;
Expand Down
1 change: 1 addition & 0 deletions modules/services/deluge.nix
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ in
description = ''
Backup configuration.
'';
default = {};
type = lib.types.submodule {
options = contracts.backup.mkRequester {
user = "deluge";
Expand Down
4 changes: 3 additions & 1 deletion modules/services/hledger.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 2 additions & 0 deletions test/modules/arr.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ in
policy = "bypass";
resources = [
"^/api.*"
"^/feed.*"
];
}
{
Expand Down Expand Up @@ -124,6 +125,7 @@ in
policy = "bypass";
resources = [
"^/api.*"
"^/feed.*"
];
}
{
Expand Down
76 changes: 49 additions & 27 deletions test/services/arr.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = { ... }: [
Expand Down Expand Up @@ -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, ...}: {
Expand All @@ -99,7 +115,7 @@ let

nodes.client = {};

testScript = commonTestScript appname cfgPathFn;
testScript = (commonTestScript appname cfgPathFn).access;
};

sso = appname: { config, ...}: {
Expand All @@ -125,7 +141,7 @@ let

nodes.client = {};

testScript = (commonTestScript appname cfgPathFn).override {
testScript = (commonTestScript appname cfgPathFn).access.override {
redirectSSO = true;
};
};
Expand All @@ -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;
}
26 changes: 21 additions & 5 deletions test/services/deluge.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = { ... }: [
Expand Down Expand Up @@ -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 {
Expand All @@ -151,7 +167,7 @@ in

nodes.client = {};

testScript = commonTestScript;
testScript = commonTestScript.access;
};

sso = pkgs.testers.runNixOSTest {
Expand All @@ -171,7 +187,7 @@ in

nodes.client = {};

testScript = commonTestScript.override {
testScript = commonTestScript.access.override {
redirectSSO = true;
};
};
Expand All @@ -192,7 +208,7 @@ in
nodes.client = {};

testScript = inputs:
(commonTestScript inputs)
(commonTestScript.access inputs)
+ (prometheusTestScript inputs);
};
}
114 changes: 114 additions & 0 deletions test/services/hledger.nix
Original file line number Diff line number Diff line change
@@ -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;
};
};
}

0 comments on commit 30aa5dc

Please sign in to comment.