From b0b64316bcbefe8c128e2ac203975606163921a6 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Thu, 13 Mar 2025 22:46:32 +0100 Subject: [PATCH] nixosTests.acme-dns: migrate to runTest Part Of #386873 --- nixos/tests/acme-dns.nix | 89 +++++++++++++++++++-------------------- nixos/tests/all-tests.nix | 2 +- 2 files changed, 44 insertions(+), 47 deletions(-) diff --git a/nixos/tests/acme-dns.nix b/nixos/tests/acme-dns.nix index 16c33c8460e5..cb65d1bd460c 100644 --- a/nixos/tests/acme-dns.nix +++ b/nixos/tests/acme-dns.nix @@ -1,58 +1,55 @@ -import ./make-test-python.nix ( - { ... }: - { - name = "acme-dns"; +{ + name = "acme-dns"; - nodes.machine = - { pkgs, ... }: - { - services.acme-dns = { - enable = true; - settings = { - general = rec { - domain = "acme-dns.home.arpa"; - nsname = domain; - nsadmin = "admin.home.arpa"; - records = [ - "${domain}. A 127.0.0.1" - "${domain}. AAAA ::1" - "${domain}. NS ${domain}." - ]; - }; - logconfig.loglevel = "debug"; + nodes.machine = + { pkgs, ... }: + { + services.acme-dns = { + enable = true; + settings = { + general = rec { + domain = "acme-dns.home.arpa"; + nsname = domain; + nsadmin = "admin.home.arpa"; + records = [ + "${domain}. A 127.0.0.1" + "${domain}. AAAA ::1" + "${domain}. NS ${domain}." + ]; }; + logconfig.loglevel = "debug"; }; - environment.systemPackages = with pkgs; [ - curl - bind - ]; }; + environment.systemPackages = with pkgs; [ + curl + bind + ]; + }; - testScript = '' - import json + testScript = '' + import json - machine.wait_for_unit("acme-dns.service") - machine.wait_for_open_port(53) # dns - machine.wait_for_open_port(8080) # http api + machine.wait_for_unit("acme-dns.service") + machine.wait_for_open_port(53) # dns + machine.wait_for_open_port(8080) # http api - result = machine.succeed("curl --fail -X POST http://localhost:8080/register") - print(result) + result = machine.succeed("curl --fail -X POST http://localhost:8080/register") + print(result) - registration = json.loads(result) + registration = json.loads(result) - machine.succeed(f'dig -t TXT @localhost {registration["fulldomain"]} | grep "SOA" | grep "admin.home.arpa"') + machine.succeed(f'dig -t TXT @localhost {registration["fulldomain"]} | grep "SOA" | grep "admin.home.arpa"') - # acme-dns exspects a TXT value string length of exactly 43 chars - txt = "___dummy_validation_token_for_txt_record___" + # acme-dns exspects a TXT value string length of exactly 43 chars + txt = "___dummy_validation_token_for_txt_record___" - machine.succeed( - "curl --fail -X POST http://localhost:8080/update " - + f' -H "X-Api-User: {registration["username"]}"' - + f' -H "X-Api-Key: {registration["password"]}"' - + f' -d \'{{"subdomain":"{registration["subdomain"]}", "txt":"{txt}"}}\''' - ) + machine.succeed( + "curl --fail -X POST http://localhost:8080/update " + + f' -H "X-Api-User: {registration["username"]}"' + + f' -H "X-Api-Key: {registration["password"]}"' + + f' -d \'{{"subdomain":"{registration["subdomain"]}", "txt":"{txt}"}}\''' + ) - assert txt in machine.succeed(f'dig -t TXT +short @localhost {registration["fulldomain"]}') - ''; - } -) + assert txt in machine.succeed(f'dig -t TXT +short @localhost {registration["fulldomain"]}') + ''; +} diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index f1e11ba0ccd3..b29572378e22 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -147,7 +147,7 @@ in { _3proxy = runTest ./3proxy.nix; aaaaxy = runTest ./aaaaxy.nix; acme = import ./acme/default.nix { inherit runTest; }; - acme-dns = handleTest ./acme-dns.nix {}; + acme-dns = runTest ./acme-dns.nix; actual = handleTest ./actual.nix {}; adguardhome = runTest ./adguardhome.nix; aesmd = runTestOn ["x86_64-linux"] ./aesmd.nix;