当前位置: 首页>>代码示例>>Python>>正文


Python test.Test类代码示例

本文整理汇总了Python中dnstest.test.Test的典型用法代码示例。如果您正苦于以下问题:Python Test类的具体用法?Python Test怎么用?Python Test使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Test类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Test

#!/usr/bin/env python3

''' Test for loading badly formed record '''

from dnstest.test import Test

t = Test()

master = t.server("knot")

zone = t.zone("badrecord.", "badrecord.zone", storage=".")

t.link(zone, master)

t.start()

# Check if the server is answering and zone _isn't_ loaded
resp = master.dig("badrecord.", "SOA", udp=True)

# @note Either REFUSED or SERVFAIL is fine, Knot treats unloadable
# zone as expired while the older version ignored such zone.
resp.check(rcode="SERVFAIL")

# Stop master.
master.stop()

t.end()
开发者ID:gitter-badger,项目名称:knot,代码行数:27,代码来源:test.py

示例2: Test

#!/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
开发者ID:gitter-badger,项目名称:knot,代码行数:30,代码来源:test.py

示例3: Test

#!/usr/bin/env python3

'''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):
开发者ID:gitter-badger,项目名称:knot,代码行数:31,代码来源:test.py

示例4: Test

#!/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")
开发者ID:idtek,项目名称:knot,代码行数:31,代码来源:test.py

示例5: Test

#!/usr/bin/env python3

''' 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"
开发者ID:gitter-badger,项目名称:knot,代码行数:31,代码来源:test.py

示例6: Test

#!/usr/bin/env python3
"""

Basic checks for CNAME following.

- Query for CNAME, NSEC, RRSIG is not followed.
- Query for ANY meta type is not followed.
- Query for any other type is followed.

"""

from dnstest.test import Test

t = Test()

knot = t.server("knot")
zone = t.zone("follow", storage=".")
t.link(zone, knot)

t.start()

# follow CNAME (type exists)

resp = knot.dig("test.follow", "AAAA")
resp.check(rcode="NOERROR", flags="AA")
resp.check_rr("answer", "test.follow", "CNAME")
resp.check_rr("answer", "follow", "AAAA")
resp.check_empty("authority")

# follow CNAME (type doesn't exist)
开发者ID:gitter-badger,项目名称:knot,代码行数:30,代码来源:test.py

示例7: Test

#!/usr/bin/env python3

'''Test for transition from NSEC to NSEC3 on auto-signed zone using DDNS.'''

from dnstest.utils import *
from dnstest.test import Test

t = Test()

master = t.server("knot")
slave = t.server("bind")
zone = t.zone_rnd(1, dnssec=False)
t.link(zone, master, slave, ddns=True)

t.start()

# Wait for listening server with unsigned zone.
old_serial = master.zone_wait(zone)
slave.zone_wait(zone)
t.xfr_diff(master, slave, zone)

# Check NSEC absence.
master.check_nsec(zone, nonsec=True)

master.stop()

# Enable autosigning.
master.dnssec_enable = True
master.gen_key(zone, ksk=True, alg="NSEC3RSASHA1")
master.gen_key(zone, alg="NSEC3RSASHA1")
master.gen_key(zone, ksk=True, alg="RSASHA256")
开发者ID:dnstap,项目名称:knot,代码行数:31,代码来源:test.py

示例8: check_log

    found_dnskeys = dnskeys.count("DNSKEY")
    found_rrsigs = soa.count("RRSIG")

    expect_dnskeys = 3 if expect_dnskey else 2
    expect_rrsigs = 2 if expect_rrsig else 1

    check_log("DNSKEYs: %d (expected %d) RRSIGs: %d (expected %d)" %
              (found_dnskeys, expect_dnskeys, found_rrsigs, expect_rrsigs));

    if found_dnskeys != expect_dnskeys or found_rrsigs != expect_rrsigs:
        set_err("BAD DNSKEY: " + msg)
        detail_log("!DNSKEYs not published and activated as expected: " + msg)

    detail_log(SEP)

t = Test()

knot = t.server("knot")
knot.dnssec_enable = True
zone = t.zone("example.com.")
t.link(zone, knot)

# install keys (one always enabled, one for testing)
shutil.copytree(os.path.join(t.data_dir, "keys"), knot.keydir)

# parameters
ZONE = "example.com"
KEYID = "712d0d0d57fa0aa006b5e20cd84e23941e5f3ab2"
WAIT_SIGN = 2

#
开发者ID:gitter-badger,项目名称:knot,代码行数:31,代码来源:test.py

示例9: Test

#!/usr/bin/env python3

"""Test for EDNS version"""

from dnstest.test import Test
from dnstest.utils import *

t = Test()

server = t.server("knot")
zone = t.zone("example.com.")

t.link(zone, server)

t.start()

# Supported EDNS version 0.
resp = server.dig("example.com", "SOA", edns=0)
resp.check(rcode="NOERROR", edns_version=0)

# Unsupported EDNS version 1.
resp = server.dig("example.com", "SOA", edns=1)
resp.check(rcode="BADVERS", edns_version=0)
compare(resp.count(section="answer"), 0, "Answer count")
compare(resp.count(section="authority"), 0, "Authority count")
compare(resp.count(section="additional"), 0, "Additional count")


t.end()
开发者ID:gitter-badger,项目名称:knot,代码行数:29,代码来源:test.py

示例10: range

    return ''.join(random.choice(chars) for _ in range(63))

def flood(server, zone):
    rr = None
    updates = []
    for i in range(UPDATE_COUNT):
        update = server.update(zone)
        for j in range(UPDATE_SIZE):
            rr = [randstr() + "." + zone[0].name, 3600, "TXT", randstr()]
            update.add(*rr)
        update.send()
    return rr

random.seed()

t = Test()

zone = t.zone_rnd(1, dnssec=False, records=4)
master = t.server("knot")

# set journal limit for the master
master.ixfr_fslimit = "800k"

slaves = [t.server("knot") for _ in range(2)]
# set journal limit for one of the slaves
slaves[0].ixfr_fslimit = "500k"

for s in slaves:
    t.link(zone, master, s, ddns=True, ixfr=True)

t.start()
开发者ID:jkadlec,项目名称:knot-dns-zoneapi,代码行数:31,代码来源:test.py

示例11: Test

#!/usr/bin/env python3

"""
Multi-master failover tests.
"""

from dnstest.test import Test

t = Test()

# testing zone
zone = t.zone_rnd(1, dnssec=False, records=1)[0]
zone.update_soa(serial=1, refresh=600, retry=600, expire=3600)

# +---------+       +---------+
# | master1 <-------+ master2 |
# +----^----+       +----^----+
#      |                 |    
#      |   +---------+   |    
#      +---+  slave  +---+    
#          +---------+   

master1 = t.server("knot")
master2 = t.server("bind")
slave = t.server("knot")

# flush zones immediatelly
for server in [master1, master2, slave]:
    slave.zonefile_sync = "0"

t.link([zone], master1, master2)
开发者ID:gitter-badger,项目名称:knot,代码行数:31,代码来源:test.py

示例12: Test

#!/usr/bin/env python3

'''Test for IXFR from Knot to Knot'''

from dnstest.test import Test

t = Test()

master = t.server("knot")
slave = t.server("knot")
zones = t.zone_rnd(5, records=50) + t.zone("records.")

t.link(zones, master, slave, ixfr=True)

t.start()

# Wait for AXFR to slave server.
serials_init = master.zones_wait(zones)
slave.zones_wait(zones)

serials_prev = serials_init
for i in range(4):
    # Update zone files on master.
    for zone in zones:
        master.update_zonefile(zone, random=True)
    master.reload()

    # Wait for IXFR to slave.
    serials = master.zones_wait(zones, serials_prev)
    slave.zones_wait(zones, serials_prev)
    serials_prev = serials
开发者ID:gitter-badger,项目名称:knot,代码行数:31,代码来源:test.py

示例13: Test

#!/usr/bin/env python3

'''Test for loading of dumped zone'''

from dnstest.test import Test

t = Test()

master = t.server("bind")
slave = t.server("knot")
reference = t.server("bind")

zones = t.zone_rnd(4) + t.zone(".") + t.zone("records.")

t.link(zones, master, slave)
t.link(zones, reference)

t.start()

# Wait for servers.
master.zones_wait(zones)
slave.zones_wait(zones)
reference.zones_wait(zones)

# Dump zones on slave.
slave.flush()

# Compare master with reference server
t.xfr_diff(reference, master, zones)

# Compare slave with reference server
开发者ID:gitter-badger,项目名称:knot,代码行数:31,代码来源:test.py

示例14: Test

#!/usr/bin/env python3

'''Test for server version over CH/TXT'''

from dnstest.test import Test

t = Test()

ver = "ver. 1.3.1-p3"
server1 = t.server("knot", version=ver)
server2 = t.server("knot", version=True)
server3 = t.server("knot", version=False)
server4 = t.server("knot")

t.start()

# 1a) Custom version string.
resp = server1.dig("version.server", "TXT", "CH")
resp.check('"' + ver + '"')

# 1b) Bind old version of above.
resp = server1.dig("version.bind", "TXT", "CH")
resp.check('"' + ver + '"')

# 2) Automatic version string (can't be tested).
resp = server2.dig("version.server", "TXT", "CH")
resp.check(rcode="NOERROR")

# 3) Explicitly disabled.
resp = server3.dig("version.server", "TXT", "CH")
resp.check(rcode="REFUSED")
开发者ID:dnstap,项目名称:knot,代码行数:31,代码来源:test.py

示例15: Test

#!/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()
开发者ID:dnstap,项目名称:knot,代码行数:28,代码来源:test.py


注:本文中的dnstest.test.Test类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。