1 import ./make-test-python.nix ({ ... }: {
4 nodes.machine = { pkgs, ... }: {
9 domain = "acme-dns.home.arpa";
11 nsadmin = "admin.home.arpa";
13 "${domain}. A 127.0.0.1"
15 "${domain}. NS ${domain}."
18 logconfig.loglevel = "debug";
21 environment.systemPackages = with pkgs; [ curl bind ];
27 machine.wait_for_unit("acme-dns.service")
28 machine.wait_for_open_port(53) # dns
29 machine.wait_for_open_port(8080) # http api
31 result = machine.succeed("curl --fail -X POST http://localhost:8080/register")
34 registration = json.loads(result)
36 machine.succeed(f'dig -t TXT @localhost {registration["fulldomain"]} | grep "SOA" | grep "admin.home.arpa"')
38 # acme-dns exspects a TXT value string length of exactly 43 chars
39 txt = "___dummy_validation_token_for_txt_record___"
42 "curl --fail -X POST http://localhost:8080/update "
43 + f' -H "X-Api-User: {registration["username"]}"'
44 + f' -H "X-Api-Key: {registration["password"]}"'
45 + f' -d \'{{"subdomain":"{registration["subdomain"]}", "txt":"{txt}"}}\'''
48 assert txt in machine.succeed(f'dig -t TXT +short @localhost {registration["fulldomain"]}')