hooks/test_ptr_records.py: introduce

This commit is contained in:
CroneKorkN 2026-01-11 10:18:21 +01:00
parent a0f5f80a16
commit 7ea760d5eb
Signed by: cronekorkn
SSH key fingerprint: SHA256:v0410ZKfuO1QHdgKBsdQNF64xmTxOF8osF1LIqwTcVw
2 changed files with 19 additions and 0 deletions

View file

@ -82,6 +82,7 @@ def dns(metadata):
'dns': dns,
}
@metadata_reactor.provides(
'letsencrypt/domains',
)

18
hooks/test_ptr_records.py Normal file
View file

@ -0,0 +1,18 @@
from subprocess import check_output
def test_node(repo, node, **kwargs):
for node in repo.nodes_in_group('mailserver'):
domain = node.metadata.get('mailserver/hostname')
expected_ptr_record = f"{domain}."
expected_a_record = node.hostname
# check A record
actual_a_record = check_output(['dig', '+short', 'A', domain, '@9.9.9.9'], text=True).strip()
if actual_a_record != expected_a_record:
raise AssertionError(f"A record for {expected_a_record} on node {node.name} is {actual_a_record}, expected {expected_a_record}")
# check otr record
actual_ptr_record = check_output(['dig', '+short', '-x', expected_a_record, '@9.9.9.9'], text=True).strip()
if actual_ptr_record != expected_ptr_record:
raise AssertionError(f"PTR record for {expected_a_record} on node {node.name} is {actual_ptr_record}, expected {expected_ptr_record}")