def test_Context(): class test_args(object): source = 'dns_sprockets_lib/tests/data/001.cst.net.' zone = '001.cst.net' force_dnssec_type = 'detect' test_args_inst = test_args() test_file = File(test_args_inst) zone_obj = test_file.run() context = validators.Context(test_args_inst, zone_obj) node_names = [ dns.name.from_text('001.cst.net.'), dns.name.from_text('001.001.cst.net.'), dns.name.from_text('06ES9CGGDRORFDD4NS9AHOCAIKLDRRP8.001.cst.net.'), dns.name.from_text('AL016ABKH6LVDIG6503FS92KDMOTQH4V.001.cst.net.'), dns.name.from_text('KQGPU8I0AI43NEM212BD0079J5SI5R3K.001.cst.net.'), dns.name.from_text('test.001.cst.net.'), dns.name.from_text('test2.001.cst.net.'), dns.name.from_text('UQML1AM96TFTFMLKAGTBS82ISR050SH0.001.cst.net.')] assert context.zone_name == dns.name.from_text(test_args_inst.zone) assert context.zone_obj == zone_obj assert context.node_names == node_names assert len(context.soa_rdataset.items) == 1 assert len(context.dnskey_rdataset) == 2 assert len(context.nsec3param_rdataset) == 1 assert context.delegated_names == [] assert context.dnssec_type == 'NSEC3' assert context.is_delegated('test.001.cst.net.') is False
def test_File(): class test_args(object): source = 'dns_sprockets_lib/tests/data/001.cst.net.' zone = '001.cst.net' test_file = File(test_args()) assert test_file.rdclass == 'IN' assert test_file.allow_include == '1' zone_obj = test_file.run() assert isinstance(zone_obj, dns.zone.Zone) assert zone_obj.get_rdataset('001.cst.net.', dns.rdatatype.SOA)
def test_filter_node(): class test_args(object): source = 'dns_sprockets_lib/tests/data/001.cst.net.' zone = '001.cst.net' test_file = File(test_args()) zone_obj = test_file.run() node = zone_obj.get_node('001.cst.net.') tests = { (None, 8), ('', 8), ('SOA', 1), ('A', 0), ('SOA,NS', 2), ('SOA,NS,DNSKEY', 3), ('SOA,NS,DNSKEY,A', 3)} for test in tests: assert len(validators.filter_node(node, test[0]).rdatasets) == test[1]