at master 2.1 kB view raw
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. 4 5{ pkgs, lib, ... }: 6{ 7 name = "powerdns"; 8 9 nodes.server = 10 { ... }: 11 { 12 services.powerdns.enable = true; 13 services.powerdns.extraConfig = '' 14 launch=gmysql 15 gmysql-user=pdns 16 zone-cache-refresh-interval=0 17 ''; 18 19 services.mysql = { 20 enable = true; 21 package = pkgs.mariadb; 22 ensureDatabases = [ "powerdns" ]; 23 ensureUsers = lib.singleton { 24 name = "pdns"; 25 ensurePermissions = { 26 "powerdns.*" = "ALL PRIVILEGES"; 27 }; 28 }; 29 }; 30 31 environment.systemPackages = with pkgs; [ 32 dnsutils 33 powerdns 34 mariadb 35 ]; 36 }; 37 38 testScript = '' 39 with subtest("PowerDNS database exists"): 40 server.wait_for_unit("mysql") 41 server.succeed("echo 'SHOW DATABASES;' | sudo -u pdns mysql -u pdns >&2") 42 43 with subtest("Loading the MySQL schema works"): 44 server.succeed( 45 "sudo -u pdns mysql -u pdns -D powerdns <" 46 "${pkgs.powerdns}/share/doc/pdns/schema.mysql.sql" 47 ) 48 49 with subtest("PowerDNS server starts"): 50 server.wait_for_unit("pdns") 51 server.succeed("dig version.bind txt chaos @127.0.0.1 >&2") 52 53 with subtest("Adding an example zone works"): 54 # Extract configuration file needed by pdnsutil 55 pdnsutil = "sudo -u pdns pdnsutil " 56 server.succeed(f"{pdnsutil} create-zone example.com ns1.example.com") 57 server.succeed(f"{pdnsutil} add-record example.com ns1 A 192.168.1.2") 58 59 with subtest("Querying the example zone works"): 60 reply = server.succeed("dig +noall +answer ns1.example.com @127.0.0.1") 61 assert ( 62 "192.168.1.2" in reply 63 ), f"""" 64 The reply does not contain the expected IP address: 65 Expected: 66 ns1.example.com. 3600 IN A 192.168.1.2 67 Reply: 68 {reply}""" 69 ''; 70}