about summary refs log tree commit diff
path: root/nixos/tests/blocky.nix
blob: 18e7f45e1c738cebecd50730483bfe7eb6f2dccb (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
import ./make-test-python.nix {
  name = "blocky";

  nodes = {
    server = { pkgs, ... }: {
      environment.systemPackages = [ pkgs.dnsutils ];
      services.blocky = {
        enable = true;

        settings = {
          customDNS = {
            mapping = {
              "printer.lan" = "192.168.178.3,2001:0db8:85a3:08d3:1319:8a2e:0370:7344";
            };
          };
          upstream = {
            default = [ "8.8.8.8" "1.1.1.1" ];
          };
          port = 53;
          httpPort = 5000;
          logLevel = "info";
        };
      };
    };
  };

  testScript = ''
    with subtest("Service test"):
        server.wait_for_unit("blocky.service")
        server.wait_for_open_port(53)
        server.wait_for_open_port(5000)
        server.succeed("dig @127.0.0.1 +short -x 192.168.178.3 | grep -qF printer.lan")
  '';
}