From 2288aab12d4b8d1e82dabe501772a30945e0b584 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Tue, 10 Jun 2025 05:27:52 +0200 Subject: [PATCH] nixos/tests/postfix-tlspol: init Simple test if the service comes up and the CLI can interact with it and gives reasonable results. --- nixos/tests/all-tests.nix | 1 + nixos/tests/postfix-tlspol.nix | 29 ++++++++++++++++++++++ pkgs/by-name/po/postfix-tlspol/package.nix | 5 ++++ 3 files changed, 35 insertions(+) create mode 100644 nixos/tests/postfix-tlspol.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index aedc99b1a7e4..891e07cb6325 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1103,6 +1103,7 @@ in postfix-raise-smtpd-tls-security-level = handleTest ./postfix-raise-smtpd-tls-security-level.nix { }; + postfix-tlspol = runTest ./postfix-tlspol.nix; postfixadmin = runTest ./postfixadmin.nix; postgres-websockets = runTest ./postgres-websockets.nix; postgresql = handleTest ./postgresql { }; diff --git a/nixos/tests/postfix-tlspol.nix b/nixos/tests/postfix-tlspol.nix new file mode 100644 index 000000000000..0c76257f6a5a --- /dev/null +++ b/nixos/tests/postfix-tlspol.nix @@ -0,0 +1,29 @@ +{ + lib, + ... +}: +{ + name = "postfix-tlspol"; + + meta.maintainers = with lib.maintainers; [ hexa ]; + + nodes.machine = { + services.postfix-tlspol.enable = true; + }; + + enableOCR = true; + + testScript = '' + import json + + machine.wait_for_unit("postfix-tlspol.service") + + with subtest("Interact with the service"): + machine.succeed("postfix-tlspol -purge") + + response = json.loads((machine.succeed("postfix-tlspol -query localhost"))) + machine.log(json.dumps(response, indent=2)) + + ''; + +} diff --git a/pkgs/by-name/po/postfix-tlspol/package.nix b/pkgs/by-name/po/postfix-tlspol/package.nix index f3d2c5a2f0f2..69a89a8b8319 100644 --- a/pkgs/by-name/po/postfix-tlspol/package.nix +++ b/pkgs/by-name/po/postfix-tlspol/package.nix @@ -2,6 +2,7 @@ lib, buildGoModule, fetchFromGitHub, + nixosTests, }: buildGoModule rec { @@ -22,6 +23,10 @@ buildGoModule rec { ldflags = [ "-X main.Version=${version}" ]; + passthru.tests = { + inherit (nixosTests) postfix-tlspol; + }; + meta = { description = "Lightweight MTA-STS + DANE/TLSA resolver and TLS policy server for Postfix, prioritizing DANE."; homepage = "https://github.com/Zuplu/postfix-tlspol";