1 # This test runs PowerDNS authoritative server with the
2 # generic MySQL backend (gmysql) to connect to a
3 # MariaDB server using UNIX sockets authentication.
5 import ./make-test-python.nix ({ pkgs, lib, ... }: {
8 nodes.server = { ... }: {
9 services.powerdns.enable = true;
10 services.powerdns.extraConfig = ''
13 zone-cache-refresh-interval=0
18 package = pkgs.mariadb;
19 ensureDatabases = [ "powerdns" ];
20 ensureUsers = lib.singleton
22 ensurePermissions = { "powerdns.*" = "ALL PRIVILEGES"; };
26 environment.systemPackages = with pkgs;
27 [ dnsutils powerdns mariadb ];
31 with subtest("PowerDNS database exists"):
32 server.wait_for_unit("mysql")
33 server.succeed("echo 'SHOW DATABASES;' | sudo -u pdns mysql -u pdns >&2")
35 with subtest("Loading the MySQL schema works"):
37 "sudo -u pdns mysql -u pdns -D powerdns <"
38 "${pkgs.powerdns}/share/doc/pdns/schema.mysql.sql"
41 with subtest("PowerDNS server starts"):
42 server.wait_for_unit("pdns")
43 server.succeed("dig version.bind txt chaos @127.0.0.1 >&2")
45 with subtest("Adding an example zone works"):
46 # Extract configuration file needed by pdnsutil
47 pdnsutil = "sudo -u pdns pdnsutil "
48 server.succeed(f"{pdnsutil} create-zone example.com ns1.example.com")
49 server.succeed(f"{pdnsutil} add-record example.com ns1 A 192.168.1.2")
51 with subtest("Querying the example zone works"):
52 reply = server.succeed("dig +noall +answer ns1.example.com @127.0.0.1")
54 "192.168.1.2" in reply
56 The reply does not contain the expected IP address:
58 ns1.example.com. 3600 IN A 192.168.1.2