add tests for nsd
This commit is contained in:
parent
6dd625670e
commit
1951438f20
4 changed files with 28 additions and 0 deletions
|
@ -11,6 +11,7 @@
|
||||||
<file file_type="variable" source="nsd.signed" variable="nsd_reverse_filenames">nsd_reverse_filenames_signed</file>
|
<file file_type="variable" source="nsd.signed" variable="nsd_reverse_filenames">nsd_reverse_filenames_signed</file>
|
||||||
<file engine="none" source="sysuser-nsd.conf">/sysusers.d/0nsd.conf</file>
|
<file engine="none" source="sysuser-nsd.conf">/sysusers.d/0nsd.conf</file>
|
||||||
<file engine="none" source="tmpfile-nsd.conf">/tmpfiles.d/0nsd.conf</file>
|
<file engine="none" source="tmpfile-nsd.conf">/tmpfiles.d/0nsd.conf</file>
|
||||||
|
<file>/tests/nsd.yml</file>
|
||||||
</service>
|
</service>
|
||||||
</services>
|
</services>
|
||||||
<variables>
|
<variables>
|
||||||
|
|
12
seed/applicationservice/2022.03.08/nsd/templates/nsd.yml
Normal file
12
seed/applicationservice/2022.03.08/nsd/templates/nsd.yml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
address: '%%ip_eth0'
|
||||||
|
records:
|
||||||
|
%for %%domain in %%nsd_zones_all
|
||||||
|
%set %%suffix = %%normalize_family(%%domain)
|
||||||
|
%set %%hostnames = %%nsd["nsd_zone_" + %%suffix]["hostname_" + %%suffix]["hostname_" + %%suffix]
|
||||||
|
%for %%nsd in %%hostnames
|
||||||
|
%set %%type = %%nsd['type_' + %%suffix]
|
||||||
|
%if %%type == 'A'
|
||||||
|
%%{nsd}.%%domain: '%%nsd['ip_' + %%suffix]'
|
||||||
|
%end if
|
||||||
|
%end for
|
||||||
|
%end for
|
1
seed/applicationservice/2022.03.08/nsd/tests/FIXME
Normal file
1
seed/applicationservice/2022.03.08/nsd/tests/FIXME
Normal file
|
@ -0,0 +1 @@
|
||||||
|
python3-dnspython
|
14
seed/applicationservice/2022.03.08/nsd/tests/test_dns.py
Normal file
14
seed/applicationservice/2022.03.08/nsd/tests/test_dns.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# DNSSEC : https://github.com/wubo1994/DNS-resolver-in-python3/blob/master/dnssec.py
|
||||||
|
from yaml import loads
|
||||||
|
from dns.resolver import Resolver
|
||||||
|
|
||||||
|
|
||||||
|
def test_nsd():
|
||||||
|
data = loads('./nsd.yml')
|
||||||
|
resolver = Resolver()
|
||||||
|
resolver.nameservers = [data['address']]
|
||||||
|
for dns, ip in data['records'].items():
|
||||||
|
records = resolver.resolve(dns, 'A')
|
||||||
|
ips = [record.address for record in records]
|
||||||
|
assert len(ips) == 1, f"le domaine {dns} n'a pas qu'une ip {ips}"
|
||||||
|
assert ips[0] == ip, f"l'IP du domaine {dns} n'est pas correct, attendu : {ip}, obtenu {ips[0}}"
|
Loading…
Reference in a new issue