vuls: init at 0.27.0
[NixPkgs.git] / nixos / tests / adguardhome.nix
blob005d54e17dfdc3dfc04a369acfa1c2001b9fd141
2   name = "adguardhome";
4   nodes = {
5     nullConf = { services.adguardhome.enable = true; };
7     emptyConf = {
8       services.adguardhome = {
9         enable = true;
11         settings = { };
12       };
13     };
15     schemaVersionBefore23 = {
16       services.adguardhome = {
17         enable = true;
19         settings.schema_version = 20;
20       };
21     };
23     declarativeConf = {
24       services.adguardhome = {
25         enable = true;
27         mutableSettings = false;
28         settings.dns.bootstrap_dns = [ "127.0.0.1" ];
29       };
30     };
32     mixedConf = {
33       services.adguardhome = {
34         enable = true;
36         mutableSettings = true;
37         settings.dns.bootstrap_dns = [ "127.0.0.1" ];
38       };
39     };
41     dhcpConf = { lib, ... }: {
42       virtualisation.vlans = [ 1 ];
44       networking = {
45         # Configure static IP for DHCP server
46         useDHCP = false;
47         interfaces."eth1" = lib.mkForce {
48           useDHCP = false;
49           ipv4 = {
50             addresses = [{
51               address = "10.0.10.1";
52               prefixLength = 24;
53             }];
55             routes = [{
56               address = "10.0.10.0";
57               prefixLength = 24;
58             }];
59           };
60         };
62         # Required for DHCP
63         firewall.allowedUDPPorts = [ 67 68 ];
64       };
66       services.adguardhome = {
67         enable = true;
68         allowDHCP = true;
69         mutableSettings = false;
70         settings = {
71           dns.bootstrap_dns = [ "127.0.0.1" ];
72           dhcp = {
73             # This implicitly enables CAP_NET_RAW
74             enabled = true;
75             interface_name = "eth1";
76             local_domain_name = "lan";
77             dhcpv4 = {
78               gateway_ip = "10.0.10.1";
79               range_start = "10.0.10.100";
80               range_end = "10.0.10.101";
81               subnet_mask = "255.255.255.0";
82             };
83           };
84         };
85       };
86     };
88     client = { lib, ... }: {
89       virtualisation.vlans = [ 1 ];
90       networking = {
91         interfaces.eth1 = {
92           useDHCP = true;
93           ipv4.addresses = lib.mkForce [ ];
94         };
95       };
96     };
97   };
99   testScript = ''
100     with subtest("Minimal (settings = null) config test"):
101       nullConf.wait_for_unit("adguardhome.service")
102       nullConf.wait_for_open_port(3000)
104     with subtest("Default config test"):
105       emptyConf.wait_for_unit("adguardhome.service")
106       emptyConf.wait_for_open_port(3000)
108     with subtest("Default schema_version 23 config test"):
109       schemaVersionBefore23.wait_for_unit("adguardhome.service")
110       schemaVersionBefore23.wait_for_open_port(3000)
112     with subtest("Declarative config test, DNS will be reachable"):
113       declarativeConf.wait_for_unit("adguardhome.service")
114       declarativeConf.wait_for_open_port(53)
115       declarativeConf.wait_for_open_port(3000)
117     with subtest("Mixed config test, check whether merging works"):
118       mixedConf.wait_for_unit("adguardhome.service")
119       mixedConf.wait_for_open_port(53)
120       mixedConf.wait_for_open_port(3000)
121       # Test whether merging works properly, even if nothing is changed
122       mixedConf.systemctl("restart adguardhome.service")
123       mixedConf.wait_for_unit("adguardhome.service")
124       mixedConf.wait_for_open_port(3000)
126     with subtest("Testing successful DHCP start"):
127       dhcpConf.wait_for_unit("adguardhome.service")
128       client.systemctl("start network-online.target")
129       client.wait_for_unit("network-online.target")
130       # Test IP assignment via DHCP
131       dhcpConf.wait_until_succeeds("ping -c 5 10.0.10.100")
132       # Test hostname resolution over DHCP-provided DNS
133       dhcpConf.wait_until_succeeds("ping -c 5 client.lan")
134   '';