about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorJohannes Schleifenbaum <johannes@js-webcoding.de>2022-01-18 08:59:57 +0100
committerJohannes Schleifenbaum <johannes@js-webcoding.de>2022-01-19 08:24:02 +0100
commit612ad7776a4d84cc2b1a966afb7cc93dc5d11f92 (patch)
tree1b2c131b251d1742821781480f34095ae9fbde48 /nixos
parent30ae792cd00a408a7b1784717fd5b9311554473c (diff)
downloadnixlib-612ad7776a4d84cc2b1a966afb7cc93dc5d11f92.tar
nixlib-612ad7776a4d84cc2b1a966afb7cc93dc5d11f92.tar.gz
nixlib-612ad7776a4d84cc2b1a966afb7cc93dc5d11f92.tar.bz2
nixlib-612ad7776a4d84cc2b1a966afb7cc93dc5d11f92.tar.lz
nixlib-612ad7776a4d84cc2b1a966afb7cc93dc5d11f92.tar.xz
nixlib-612ad7776a4d84cc2b1a966afb7cc93dc5d11f92.tar.zst
nixlib-612ad7776a4d84cc2b1a966afb7cc93dc5d11f92.zip
nixos/dnsdist: add test
Diffstat (limited to 'nixos')
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/dnsdist.nix48
2 files changed, 49 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 2bc34d6fd786..5fc390bcc2a7 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -104,6 +104,7 @@ in
   discourse = handleTest ./discourse.nix {};
   dnscrypt-proxy2 = handleTestOn ["x86_64-linux"] ./dnscrypt-proxy2.nix {};
   dnscrypt-wrapper = handleTestOn ["x86_64-linux"] ./dnscrypt-wrapper {};
+  dnsdist = handleTest ./dnsdist.nix {};
   doas = handleTest ./doas.nix {};
   docker = handleTestOn ["x86_64-linux"] ./docker.nix {};
   docker-rootless = handleTestOn ["x86_64-linux"] ./docker-rootless.nix {};
diff --git a/nixos/tests/dnsdist.nix b/nixos/tests/dnsdist.nix
new file mode 100644
index 000000000000..cfc41c13864e
--- /dev/null
+++ b/nixos/tests/dnsdist.nix
@@ -0,0 +1,48 @@
+import ./make-test-python.nix (
+  { pkgs, ... }: {
+    name = "dnsdist";
+    meta = with pkgs.lib; {
+      maintainers = with maintainers; [ jojosch ];
+    };
+
+    machine = { pkgs, lib, ... }: {
+      services.bind = {
+        enable = true;
+        extraOptions = "empty-zones-enable no;";
+        zones = lib.singleton {
+          name = ".";
+          master = true;
+          file = pkgs.writeText "root.zone" ''
+            $TTL 3600
+            . IN SOA ns.example.org. admin.example.org. ( 1 3h 1h 1w 1d )
+            . IN NS ns.example.org.
+
+            ns.example.org. IN A    192.168.0.1
+            ns.example.org. IN AAAA abcd::1
+
+            1.0.168.192.in-addr.arpa IN PTR ns.example.org.
+          '';
+        };
+      };
+      services.dnsdist = {
+        enable = true;
+        listenPort = 5353;
+        extraConfig = ''
+          newServer({address="127.0.0.1:53", name="local-bind"})
+        '';
+      };
+
+      environment.systemPackages = with pkgs; [ dig ];
+    };
+
+    testScript = ''
+      machine.wait_for_unit("bind.service")
+      machine.wait_for_open_port(53)
+      machine.succeed("dig @127.0.0.1 +short -x 192.168.0.1 | grep -qF ns.example.org")
+
+      machine.wait_for_unit("dnsdist.service")
+      machine.wait_for_open_port(5353)
+      machine.succeed("dig @127.0.0.1 -p 5353 +short -x 192.168.0.1 | grep -qF ns.example.org")
+    '';
+  }
+)