dataset/seed/nsd/tests/test_dns.py

15 lines
582 B
Python
Raw Normal View History

2022-07-01 22:02:44 +02:00
# 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}}"