本文整理汇总了Python中dnstest.test.Test.zone方法的典型用法代码示例。如果您正苦于以下问题:Python Test.zone方法的具体用法?Python Test.zone怎么用?Python Test.zone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dnstest.test.Test
的用法示例。
在下文中一共展示了Test.zone方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: zone
# 需要导入模块: from dnstest.test import Test [as 别名]
# 或者: from dnstest.test.Test import zone [as 别名]
#!/usr/bin/env python3
'''Test for reload of a changed zone (serial up, nochange, serial down). '''
from dnstest.test import Test
from dnstest.utils import set_err, detail_log
t = Test()
master = t.server("knot")
# Zone setup
zone = t.zone("serial.", storage = ".")
t.link(zone, master, ixfr = True)
t.start()
# Load zones
serial = master.zone_wait(zone)
def reload_zone(serial, version):
master.update_zonefile(zone, version)
master.reload()
new_serial = master.zone_wait(zone)
if new_serial != serial:
set_err("SOA MISMATCH")
detail_log("!Zone '%s' SOA serial %s != %s" % (zone[0].name, new_serial, serial))
return
resp = master.dig("new-record%d.%s" % (version, zone[0].name), "A")
resp.check(rcode="NOERROR")
示例2: Test
# 需要导入模块: from dnstest.test import Test [as 别名]
# 或者: from dnstest.test.Test import zone [as 别名]
#!/usr/bin/env python3
'''TTL mismatch test'''
from dnstest.utils import *
from dnstest.test import Test
t = Test()
zone = t.zone("example.com.")
master = t.server("knot")
t.link(zone, master, ddns=True)
t.start()
# Add new RR with different TTL to a RRSet that is already in the zone
# The UPDATE should be REFUSED
check_log("Add RR with different TTL")
up = master.update(zone)
up.add("mail.example.com.", 1000, "A", "1.2.3.4")
up.send("REFUSED")
resp = master.dig("mail.example.com.", "A")
resp.check_record(section="answer", rtype="A", ttl="3600", rdata="192.0.2.3")
resp.check_record(section="answer", rtype="A", nordata="1.2.3.4")
# Try to add two RRs belonging to one RRSet, but with different TTLs
# The UPDATE should be REFUSED
# This also tests rollback in case of addition
示例3: Test
# 需要导入模块: from dnstest.test import Test [as 别名]
# 或者: from dnstest.test.Test import zone [as 别名]
'''Test for flush event'''
from dnstest.utils import *
from dnstest.test import Test
import os
FLUSH_SLEEP = 5.5
t = Test()
master = t.server("bind")
slave = t.server("knot")
slave.zonefile_sync = "5s"
zone = t.zone("example.")
zone_path = slave.dir + "/slave/" + zone[0].file_name
t.link(zone, master, slave)
t.start()
slave.stop()
try:
os.remove(zone_path)
except:
pass
slave.start()
slave.zone_wait(zone)
#check that the zone file has not been flushed
if os.path.exists(zone_path):
check_log("Zonefile created too soon: " + str(os.stat(zone_path).st_ctime))
示例4: Test
# 需要导入模块: from dnstest.test import Test [as 别名]
# 或者: from dnstest.test.Test import zone [as 别名]
#!/usr/bin/env python3
'''NSEC test based on RFC-4035 example.'''
from dnstest.test import Test
t = Test()
knot = t.server("knot")
knot.DIG_TIMEOUT = 2
bind = t.server("bind")
zone = t.zone("example.", "example.zone.nsec", storage=".")
t.link(zone, knot)
t.link(zone, bind)
t.start()
# B1. Answer.
resp = knot.dig("x.w.example", "MX", dnssec=True)
resp.check(rcode="NOERROR", flags="QR AA", eflags="DO")
resp.cmp(bind)
# B2. Name Error.
resp = knot.dig("ml.example", "A", dnssec=True)
resp.check(rcode="NXDOMAIN", flags="QR AA", eflags="DO")
resp.cmp(bind)
# B3. No Data Error.
resp = knot.dig("ns1.example", "MX", dnssec=True)
resp.check(rcode="NOERROR", flags="QR AA", eflags="DO")
示例5: Test
# 需要导入模块: from dnstest.test import Test [as 别名]
# 或者: from dnstest.test.Test import zone [as 别名]
''' Check 'dnstap' query module functionality. '''
import os
import re
from dnstest.test import Test
from dnstest.module import ModDnstap
from dnstest.utils import *
t = Test()
ModDnstap.check()
# Initialize server configuration
knot = t.server("knot")
zone = t.zone("flags.")
t.link(zone, knot)
# Configure 'dnstap' module for all queries (default).
dflt_sink = t.out_dir + "/all.tap"
knot.add_module(None, ModDnstap(dflt_sink))
# Configure 'dnstap' module for flags zone only.
flags_sink = t.out_dir + "/flags.tap"
knot.add_module(zone, ModDnstap(flags_sink))
t.start()
dflt_qname = "dnstap_default_test"
resp = knot.dig(dflt_qname + ".example", "NS")
flags_qname = "dnstap_flags_test"
resp = knot.dig(flags_qname + ".flags", "NS")
示例6: Test
# 需要导入模块: from dnstest.test import Test [as 别名]
# 或者: from dnstest.test.Test import zone [as 别名]
from dnstest.test import Test
from dnstest.module import ModSynthRecord
t = Test()
ModSynthRecord.check()
# Zone indexes
FWD = 0
REV4 = 1
REV6 = 2
# Initialize server configuration
knot = t.server("knot")
zone = t.zone("forward.", storage=".") + \
t.zone("1.168.192.in-addr.arpa.", storage=".") + \
t.zone("1.6.b.0.0.0.0.0.0.2.6.2.ip6.arpa.", storage=".")
t.link(zone, knot)
# Enable DNSSEC
knot.dnssec_enable = True
for z in zone:
knot.gen_key(z, ksk=True, alg="RSASHA256")
knot.gen_key(z, alg="RSASHA256")
# Configure 'synth_record' modules for auto forward/reverse zones
knot.add_module(zone[FWD], ModSynthRecord("forward", None, None, "192.168.0.1"))
knot.add_module(zone[FWD], ModSynthRecord("forward", "dynamic4-", "900", "192.168.1.0-192.168.1.127"))
knot.add_module(zone[FWD], ModSynthRecord("forward", "dynamic6-", "900", "2620:0:b61::/52"))
knot.add_module(zone[REV4], ModSynthRecord("reverse", "dynamic4-", "900", "192.168.1.0/25", "forward."))
示例7: Test
# 需要导入模块: from dnstest.test import Test [as 别名]
# 或者: from dnstest.test.Test import zone [as 别名]
#!/usr/bin/env python3
'''Test for mismatched TTLs handling on slave zone load.'''
'''NOTE: dnspython can't keep different TTLs in one rrset. So we can't check
the slave server properly.'''
from dnstest.test import Test
t = Test()
master = t.server("dummy")
slave = t.server("knot")
zone = t.zone("ttl-mismatch.", storage=".", exists=False)
t.link(zone, master, slave)
# Create invalid zone file.
slave.update_zonefile(zone, version=1)
t.start()
# Check if the zone was loaded.
resp = slave.dig("ttl.ttl-mismatch.", "A")
resp.check(rcode="NOERROR", flags="QR AA", noflags="TC AD RA")
t.end()
示例8: Test
# 需要导入模块: from dnstest.test import Test [as 别名]
# 或者: from dnstest.test.Test import zone [as 别名]
#!/usr/bin/env python3
'''Test for EDNS0 UDP payload size'''
from dnstest.test import Test
t = Test()
knot = t.server("knot")
bind = t.server("bind")
zones = t.zone("flags.") + t.zone("example.", "example.zone.nsec", storage=".")
t.link(zones, knot)
t.link(zones, bind)
t.start()
# TC - TXT record doesn't fit into UDP message.
resp = knot.dig("513resp.flags", "TXT", udp=True)
resp.check(flags="TC")
resp.cmp(bind, authority=False) # Knot puts SOA compared to Bind!
# no TC - UDP message is extended using EDNS0/payload.
resp = knot.dig("513resp.flags", "TXT", udp=True, bufsize=600)
resp.check(noflags="TC")
resp.cmp(bind)
# no TC - UDP message is extended using EDNS0/payload just for answer.
resp = knot.dig("513resp.flags", "TXT", udp=True, bufsize=524)
resp.check(noflags="TC")
示例9: Test
# 需要导入模块: from dnstest.test import Test [as 别名]
# 或者: from dnstest.test.Test import zone [as 别名]
#!/usr/bin/env python3
'''Test for dropping of out of zone records during incoming XFR'''
from dnstest.test import Test
t = Test()
master = t.server("bind")
slave = t.server("knot")
zone = t.zone("out-of-zone.")
t.link(zone, master, slave)
t.start()
master.zones_wait(zone)
slave.zones_wait(zone)
t.xfr_diff(master, slave, zone)
t.end()
示例10: Test
# 需要导入模块: from dnstest.test import Test [as 别名]
# 或者: from dnstest.test.Test import zone [as 别名]
#!/usr/bin/env python3
'''Test for signing a zone with wierd records.'''
from dnstest.utils import *
from dnstest.test import Test
t = Test()
master = t.server("knot")
zone = t.zone("records.")
t.link(zone, master)
# Enable autosigning.
master.dnssec_enable = True
master.gen_key(zone, ksk=True, alg="RSASHA1")
master.gen_key(zone, alg="RSASHA1")
master.gen_confile()
t.start()
master.zone_wait(zone)
t.sleep(1)
master.flush()
t.sleep(1)
# Verify signed zone file.
master.zone_verify(zone)
t.stop()
示例11: Test
# 需要导入模块: from dnstest.test import Test [as 别名]
# 或者: from dnstest.test.Test import zone [as 别名]
#!/usr/bin/env python3
"""Test for record removal over IXFR to slave zone which doesn't contain this record"""
from dnstest.test import Test
t = Test()
master = t.server("bind")
slave = t.server("knot")
zone = t.zone("existing.", storage=".")
t.link(zone, master, slave, ixfr=True)
# Remove the record from slave zone file (no SOA serial change).
slave.update_zonefile(zone, version=2)
t.start()
# Wait for zones.
serial = master.zone_wait(zone)
slave.zone_wait(zone)
# Update master file without the record (new SOA serial).
master.update_zonefile(zone, version=1)
master.reload()
# Wait for zones and compare them.
master.zone_wait(zone, serial)
slave.zone_wait(zone, serial)
示例12: Test
# 需要导入模块: from dnstest.test import Test [as 别名]
# 或者: from dnstest.test.Test import zone [as 别名]
#!/usr/bin/env python3
'''Test for loading non-existing zone file'''
from dnstest.test import Test
t = Test()
master = t.server("knot")
zones = t.zone("notexist.", exists=False) + t.zone("example.com.")
t.link(zones, master)
t.start()
# Check if the server is answering and zone _isn't_ loaded
resp = master.dig("notexist.", "SOA", udp=True)
resp.check(rcode="SERVFAIL") # Unloadable zone, but in the zone database
# Check if the server is answering and zone is unknown
resp = master.dig("xfiles.", "SOA", udp=True)
resp.check(rcode="REFUSED")
# The other zone should answer without problem
resp = master.dig("example.com.", "SOA", udp=True)
resp.check(rcode="NOERROR")
# Stop master.
master.stop()
示例13: Test
# 需要导入模块: from dnstest.test import Test [as 别名]
# 或者: from dnstest.test.Test import zone [as 别名]
#!/usr/bin/env python3
"""Test for AXFR from Bind to Knot"""
from dnstest.test import Test
t = Test()
master = t.server("bind")
slave = t.server("knot")
zones = t.zone_rnd(10) + t.zone(".") + t.zone("records.")
t.link(zones, master, slave)
t.start()
master.zones_wait(zones)
slave.zones_wait(zones)
t.xfr_diff(master, slave, zones)
t.end()
示例14: get_binary
# 需要导入模块: from dnstest.test import Test [as 别名]
# 或者: from dnstest.test.Test import zone [as 别名]
from dnstest.params import get_binary
# Find PROTOS binaries
protos_bin = [ "c09-dns-query-r1.jar", "c09-dns-zonetransfer-r1.jar" ]
protos_java_bin = get_binary("PROTOS_JAVA_BIN", "java")
protos_query_bin = get_binary("PROTOS_QUERY_BIN", protos_bin[0])
protos_zonetransfer_bin = get_binary("PROTOS_ZONETRANSFER_BIN", protos_bin[1])
if not protos_java_bin:
raise Skip("Java not found")
if not protos_query_bin:
raise Skip("'%s' PROTOS binary not found" % protos_bin[0])
t = Test(address=4, tsig=False) # PROTOS works on IPv4, no TSIG
master = t.server("dummy")
slave = t.server("knot")
zone = t.zone("protos.invalid.", exists=False)
t.link(zone, master, slave)
# Update configuration
t.start()
''' Run PROTOS test case with given parameters. '''
def protos_run(name, binfile, params):
if not binfile:
return
check_call([protos_java_bin, "-jar", binfile] + params,
stdout=open(master.fout, mode="w"), stderr=open(master.ferr, mode="w"))
shutil.move(master.fout, master.fout + "." + name)
shutil.move(master.ferr, master.ferr + "." + name)
# Evaluate parameters
示例15: types
# 需要导入模块: from dnstest.test import Test [as 别名]
# 或者: from dnstest.test.Test import zone [as 别名]
Basic checks of Additional section content.
- Query into a delegation scope adds glue into additionals.
- Query for NS/MX/SRV adds target A+AAAA into additionals.
- Query for other types (like PTR) does NOT cause lookup of additionals.
- Query for NS/MX/SRV pointing to CNAME does NOT cause lookup of additionals.
"""
from dnstest.test import Test
t = Test()
knot = t.server("knot")
zone = t.zone("test", storage=".")
t.link(zone, knot)
t.start()
# NS authoritative
resp = knot.dig("test", "NS")
resp.check(rcode="NOERROR", flags="AA")
resp.check_rr("answer", "test", "NS")
resp.check_rr("additional", "a.ns.test", "A")
resp.check_rr("additional", "a.ns.test", "AAAA")
resp.check_rr("additional", "b.ns.test", "AAAA")
# NS delegation