summary refs log tree commit diff
path: root/nixos/tests/adguardhome.nix
blob: ec1cc1e497b5080deaaac393e0c08507bdc2037e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{
  name = "adguardhome";

  nodes = {
    nullConf = { ... }: { services.adguardhome = { enable = true; }; };

    emptyConf = { lib, ... }: {
      services.adguardhome = {
        enable = true;
        settings = {};
      };
    };

    declarativeConf = { ... }: {
      services.adguardhome = {
        enable = true;

        mutableSettings = false;
        settings = {
          schema_version = 0;
          dns = {
            bind_host = "0.0.0.0";
            bootstrap_dns = "127.0.0.1";
          };
        };
      };
    };

    mixedConf = { ... }: {
      services.adguardhome = {
        enable = true;

        mutableSettings = true;
        settings = {
          schema_version = 0;
          dns = {
            bind_host = "0.0.0.0";
            bootstrap_dns = "127.0.0.1";
          };
        };
      };
    };
  };

  testScript = ''
    with subtest("Minimal (settings = null) config test"):
        nullConf.wait_for_unit("adguardhome.service")

    with subtest("Default config test"):
        emptyConf.wait_for_unit("adguardhome.service")
        emptyConf.wait_for_open_port(3000)

    with subtest("Declarative config test, DNS will be reachable"):
        declarativeConf.wait_for_unit("adguardhome.service")
        declarativeConf.wait_for_open_port(53)
        declarativeConf.wait_for_open_port(3000)

    with subtest("Mixed config test, check whether merging works"):
        mixedConf.wait_for_unit("adguardhome.service")
        mixedConf.wait_for_open_port(53)
        mixedConf.wait_for_open_port(3000)
        # Test whether merging works properly, even if nothing is changed
        mixedConf.systemctl("restart adguardhome.service")
        mixedConf.wait_for_unit("adguardhome.service")
        mixedConf.wait_for_open_port(3000)
  '';
}