llm-ls: cleanup (#372936)
[NixPkgs.git] / nixos / tests / acme-dns.nix
blob16c33c8460e52cfc3e13b0666163cf8d4785ec2a
1 import ./make-test-python.nix (
2   { ... }:
3   {
4     name = "acme-dns";
6     nodes.machine =
7       { pkgs, ... }:
8       {
9         services.acme-dns = {
10           enable = true;
11           settings = {
12             general = rec {
13               domain = "acme-dns.home.arpa";
14               nsname = domain;
15               nsadmin = "admin.home.arpa";
16               records = [
17                 "${domain}. A 127.0.0.1"
18                 "${domain}. AAAA ::1"
19                 "${domain}. NS ${domain}."
20               ];
21             };
22             logconfig.loglevel = "debug";
23           };
24         };
25         environment.systemPackages = with pkgs; [
26           curl
27           bind
28         ];
29       };
31     testScript = ''
32       import json
34       machine.wait_for_unit("acme-dns.service")
35       machine.wait_for_open_port(53) # dns
36       machine.wait_for_open_port(8080) # http api
38       result = machine.succeed("curl --fail -X POST http://localhost:8080/register")
39       print(result)
41       registration = json.loads(result)
43       machine.succeed(f'dig -t TXT @localhost {registration["fulldomain"]} | grep "SOA" | grep "admin.home.arpa"')
45       # acme-dns exspects a TXT value string length of exactly 43 chars
46       txt = "___dummy_validation_token_for_txt_record___"
48       machine.succeed(
49         "curl --fail -X POST http://localhost:8080/update "
50         + f' -H "X-Api-User: {registration["username"]}"'
51         + f' -H "X-Api-Key: {registration["password"]}"'
52         + f' -d \'{{"subdomain":"{registration["subdomain"]}", "txt":"{txt}"}}\'''
53       )
55       assert txt in machine.succeed(f'dig -t TXT +short @localhost {registration["fulldomain"]}')
56     '';
57   }