lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

pihole-ftl: Add basic test

averyv 82a3e70b 88c7de53

+69 -9
+16 -9
nixos/modules/services/networking/pihole-ftl.nix
··· 198 198 ''; 199 199 }; 200 200 }; 201 + 202 + webserverEnabled = mkOption { 203 + type = types.bool; 204 + default = ( 205 + (hasAttrByPath [ "webserver" "port" ] cfg.settings) 206 + && !builtins.elem cfg.settings.webserver.port [ 207 + "" 208 + null 209 + ] 210 + ); 211 + internal = true; 212 + description = "Whether the webserver is enabled."; 213 + }; 201 214 }; 202 215 203 216 config = mkIf cfg.enable { ··· 208 221 } 209 222 210 223 { 211 - assertion = 212 - builtins.length cfg.lists == 0 213 - || ( 214 - (hasAttrByPath [ "webserver" "port" ] cfg.settings) 215 - && !builtins.elem cfg.settings.webserver.port [ 216 - "" 217 - null 218 - ] 219 - ); 224 + assertion = builtins.length cfg.lists == 0 || cfg.webserverEnabled; 220 225 message = '' 221 226 The Pi-hole webserver must be enabled for lists set in services.pihole-ftl.lists to be automatically loaded on startup via the web API. 222 227 services.pihole-ftl.settings.port must be defined, e.g. by enabling services.pihole-web.enable and defining services.pihole-web.port. ··· 348 353 349 354 pihole-ftl-setup = { 350 355 description = "Pi-hole FTL setup"; 356 + enable = builtins.length cfg.lists > 0; 357 + 351 358 # Wait for network so lists can be downloaded 352 359 after = [ "network-online.target" ]; 353 360 requires = [ "network-online.target" ];
+1
nixos/tests/all-tests.nix
··· 1194 1194 pict-rs = runTest ./pict-rs.nix; 1195 1195 pingvin-share = runTest ./pingvin-share.nix; 1196 1196 pinnwand = runTest ./pinnwand.nix; 1197 + pihole-ftl = import ./pihole-ftl { inherit runTest; }; 1197 1198 plantuml-server = runTest ./plantuml-server.nix; 1198 1199 plasma6 = runTest ./plasma6.nix; 1199 1200 plausible = runTest ./plausible.nix;
+47
nixos/tests/pihole-ftl/basic.nix
··· 1 + # A basic test with no webserver, no API, just checking DNS functionality 2 + { 3 + lib, 4 + pkgs, 5 + ... 6 + }: 7 + 8 + rec { 9 + name = "pihole-ftl-basic"; 10 + meta.maintainers = with lib.maintainers; [ averyvigolo ]; 11 + 12 + nodes.machine = 13 + { pkgs, lib, ... }: 14 + { 15 + services.pihole-ftl = { 16 + enable = true; 17 + openFirewallDNS = true; 18 + }; 19 + environment.systemPackages = with pkgs; [ dig ]; 20 + }; 21 + 22 + nodes.client = 23 + { pkgs, lib, ... }: 24 + { 25 + environment.systemPackages = with pkgs; [ dig ]; 26 + }; 27 + 28 + testScript = 29 + { nodes, ... }: 30 + '' 31 + machine.wait_for_unit("pihole-ftl.service") 32 + machine.wait_for_open_port(53) 33 + client.wait_for_unit("network.target") 34 + 35 + with subtest("the pi-hole machine resolves properly"): 36 + ret, out = machine.execute("dig @localhost +short pi.hole") 37 + assert ret == 0, "pi.hole should resolve on the local machine" 38 + assert out.rstrip() == "127.0.0.1", "pi.hole should resolve to localhost on the local machine" 39 + 40 + machine_address = "${(builtins.head nodes.machine.networking.interfaces.eth1.ipv4.addresses).address}" 41 + 42 + with subtest("a client machine resolves properly"): 43 + ret, out = client.execute(f"dig @{machine_address} +short pi.hole") 44 + assert ret == 0, "pi.hole should resolve on a client machine" 45 + assert out.rstrip() == machine_address, "pi.hole should resolve to the machine's address" 46 + ''; 47 + }
+5
nixos/tests/pihole-ftl/default.nix
··· 1 + { runTest }: 2 + 3 + { 4 + basic = runTest ./basic.nix; 5 + }