summaryrefslogtreecommitdiffstats
path: root/nixos/tests/hickory-dns.nix
blob: 341b25b91cc2c3889b224bbd349580eb54ac890a (plain)
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
{ pkgs, ... }:
{
  name = "hickory-dns";

  meta.maintainers = with pkgs.lib.maintainers; [ adamcstephens ];

  containers.machine = {
    environment.systemPackages = [ pkgs.doggo ];

    services.hickory-dns = {
      enable = true;
      settings.zones = [
        {
          zone = "example.test";
          file = pkgs.writeText "example.test.zone" ''
            $ORIGIN example.test.
            $TTL 3600
            @ IN SOA ns.example.test. hostmaster.example.test. (1 3600 600 86400 3600)
            @ IN NS ns.example.test.
            ns IN A 127.0.0.1
            www IN A 192.0.2.1
          '';
        }
      ];
    };
  };

  testScript = ''
    import json

    machine.start()
    machine.wait_for_unit("hickory-dns.service")
    machine.wait_for_open_port(53)

    response = json.loads(machine.succeed("doggo @127.0.0.1 www.example.test. A --json"))
    answers = response["responses"][0]["answers"]
    assert [(answer["name"], answer["type"], answer["address"]) for answer in answers] == [
        ("www.example.test.", "A", "192.0.2.1")
    ], response
  '';
}