def test_in_cache(self): namelist_filename = 'namelist.tmp' namelist = ['localhost', 'test', 'www', 'mail'] with open(namelist_filename, 'w') as fd: fd.writelines([f"{name}\n" for name in namelist]) helper = DnsHelper('zonetransfer.me') ns = '81.4.108.41' result = in_cache(helper, namelist_filename, ns) os.remove(namelist_filename) assert len(result) == 1 and result[0]['type'] == 'A'
def test_zone_transfer(self): helper = DnsHelper('megacorpone.com') records = helper.zone_transfer() assert len(records) == 30
def test_get_ptr(self): helper = DnsHelper('megacorpone.com') records = helper.get_ptr('51.79.37.18') assert len(records) == 1 and match(r'^.+\.megacorpone\.com$', records[0][1])
def test_get_soa(self): helper = DnsHelper('megacorpone.com') records = helper.get_soa() for record in records: assert record[0] == 'SOA'
def test_get_srv(self): helper = DnsHelper('nsztm1.digi.ninja') records = helper.get_srv('_sip._tcp.zonetransfer.me') for record in records: assert record[0] == 'SRV'
def test_get_ip(self): helper = DnsHelper('google.com') records = helper.get_ip('google.com') for record in records: ip = IPAddress(record[2]) assert ip.version in [4, 6] # ~ redundant
def test_get_txt(self): helper = DnsHelper('gmail.com') records = helper.get_txt() for record in records: assert record[0] == 'TXT'
def test_get_mx(self): helper = DnsHelper('google.com') records = helper.get_mx() for record in records: assert record[0] == 'MX'
def test_get_aaaa(self): helper = DnsHelper('google.com') records = helper.get_aaaa('ipv6.google.com') for record in records: assert record[0] in ['AAAA', 'CNAME']
def test_get_ptr(self): helper = DnsHelper('megacorpone.com') records = helper.get_ptr('51.79.37.18') assert len(records) == 1 and 'megacorpone.com' in records[0][1]
def test_zone_transfer(self): helper = DnsHelper('zonetransfer.me') records = helper.zone_transfer() assert len(records) == 135
def test_se_result_process(self): helper = DnsHelper('zonetransfer.me') hosts = ['www.megacorpone.com', 'www.zonetransfer.me'] result = cli.se_result_process(helper, hosts) assert len(result) >= 2