本文整理汇总了Python中mozdns.tests.utils.create_fake_zone函数的典型用法代码示例。如果您正苦于以下问题:Python create_fake_zone函数的具体用法?Python create_fake_zone怎么用?Python create_fake_zone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_fake_zone函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_integration1
def test_integration1(self):
create_fake_zone("wee.wee.mozilla.com", "")
res, error = compile_to_django("wee.wee.mozilla.com")
self.assertFalse(error)
self.assertEqual(len(res['SOA']), 1)
self.assertEqual(len(res['NS']), 1)
self.assertEqual(len(res['DOMAIN']), 1)
create_fake_zone("wee1.wee.mozilla.com", "")
res, error = compile_to_django("wee1.wee.mozilla.com")
self.assertFalse(error)
self.assertEqual(len(res['SOA']), 1)
self.assertEqual(len(res['NS']), 1)
self.assertEqual(len(res['DOMAIN']), 1)
res, error = compile_to_django("wee1.wee.mozilla.com OR "
"wee.wee.mozilla.com")
self.assertFalse(error)
self.assertEqual(len(res['SOA']), 2)
self.assertEqual(len(res['NS']), 2)
self.assertEqual(len(res['DOMAIN']), 2)
res, error = compile_to_django("wee1.wee.mozilla.com type=:SOA")
self.assertFalse(error)
self.assertEqual(len(res['SOA']), 1)
self.assertEqual(len(res['NS']), 0)
self.assertEqual(len(res['DOMAIN']), 0)
res, error = compile_to_django(
"wee1.wee.mozilla.com type=:NS OR "
"wee.wee.mozilla.com type=:DOMAIN")
self.assertFalse(error)
self.assertEqual(len(res['SOA']), 0)
self.assertEqual(len(res['NS']), 1)
self.assertEqual(len(res['DOMAIN']), 1)
示例2: setUp
def setUp(self):
View.objects.create(name="public")
View.objects.create(name="private")
self.d = create_fake_zone('foo.com', suffix="")
self.rd = create_fake_zone('10.in-addr.arpa', suffix="")
self.client = Client()
self.s = create_fake_host(hostname='exists.mozilla.com')
示例3: test_integration4_ip
def test_integration4_ip(self):
create_fake_zone("wee3.wee.mozilla.com", "")
create_fake_zone("1.2.ip6.arpa", "")
res, error = compile_to_django("1.2.ip6.arpa")
self.assertFalse(error)
self.assertEqual(len(res['SOA']), 1)
self.assertEqual(len(res['NS']), 1)
self.assertEqual(len(res['DOMAIN']), 1)
ptr = PTR(name="host1.wee2.wee.mozilla.com", ip_str="2111:0::",
ip_type="6")
ptr.save()
res, error = compile_to_django(ptr.ip_str)
self.assertFalse(error)
self.assertEqual(len(res['PTR']), 1)
self.assertEqual(len(res['A']), 0)
res, error = compile_to_django("2111:0:0::")
self.assertFalse(error)
self.assertEqual(len(res['PTR']), 0)
self.assertEqual(len(res['A']), 0)
res, error = compile_to_django("ip=:2111:0:0::")
self.assertFalse(error)
self.assertEqual(len(res['PTR']), 1)
self.assertEqual(len(res['A']), 0)
res, error = compile_to_django("ip=:2111:1:0::")
self.assertFalse(error)
self.assertEqual(len(res['PTR']), 0)
self.assertEqual(len(res['A']), 0)
示例4: test_integration5_ip
def test_integration5_ip(self):
root_domain = create_fake_zone("wee5.wee.mozilla.com", "")
create_fake_zone("10.in-addr.arpa", "")
res, error = compile_to_django("10.in-addr.arpa OR "
"wee5.wee.mozilla.com")
self.assertFalse(error)
self.assertEqual(len(res['SOA']), 2)
self.assertEqual(len(res['NS']), 2)
self.assertEqual(len(res['DOMAIN']), 2)
ptr = PTR(name="host1.wee2.wee.mozilla.com", ip_str="10.0.0.1",
ip_type="4")
ptr.save()
addr = AddressRecord(label="host1", domain=root_domain,
ip_str="10.0.0.1", ip_type="4")
addr.save()
res, error = compile_to_django(ptr.ip_str)
self.assertFalse(error)
self.assertEqual(len(res['PTR']), 1)
self.assertEqual(len(res['A']), 1)
res, error = compile_to_django("10.0.0.2")
self.assertFalse(error)
self.assertEqual(len(res['PTR']), 0)
self.assertEqual(len(res['A']), 0)
res, error = compile_to_django("ip=:10.0.0.1")
self.assertFalse(error)
self.assertEqual(len(res['PTR']), 1)
self.assertEqual(len(res['A']), 1)
示例5: setUp
def setUp(self):
create_fake_zone('10.in-addr.arpa', suffix='')
self.domain = create_fake_zone('foo.mozilla.com', suffix='')
self.s = create_fake_host(hostname='foo.mozilla.com')
self.sreg = StaticReg.objects.create(
label='', domain=self.domain, ip_str='10.0.0.1', ip_type='4',
system=self.s
)
示例6: setUp
def setUp(self):
self.g = create_fake_zone("gz", suffix="")
self.c_g = create_fake_zone("coo.gz", suffix="")
self.d = create_fake_zone("dz", suffix="")
self.r1 = create_fake_zone("10.in-addr.arpa", suffix="")
self.r1.save()
self.s = System()
self.s.save()
示例7: setUp
def setUp(self):
self.g = create_fake_zone("gz", suffix="")
self.c_g = create_fake_zone("coo.gz", suffix="")
self.d = create_fake_zone("dz", suffix="")
self.r1 = create_fake_zone("10.in-addr.arpa", suffix="")
self.r1.save()
self.s = create_fake_host(hostname="foo.mozilla.com")
self.s.save()
示例8: setUp
def setUp(self):
self.num = 0
create_fake_zone('2.ip6.arpa', suffix="")
self.domain = create_fake_zone('foo.mozilla.com', suffix='')
self.s = create_fake_host(hostname='foo.mozilla.com')
self.sreg = StaticReg.objects.create(
label='', domain=self.domain, ip_str='2222:123::', ip_type='6',
system=self.s
)
self.s = create_fake_host(hostname='foobar.mozilla.com')
self.g = Group.objects.create(name='foobar')
super(HWAdapterTest, self).setUp()
示例9: test_basic_add_remove9
def test_basic_add_remove9(self):
# Make sure all record types block
f_c = create_fake_zone("foo.foo22", suffix="")
self.assertFalse(f_c.purgeable)
fqdn = "y.z.foo.foo22"
label, the_domain = ensure_label_domain(fqdn)
addr = AddressRecord(label=label, domain=the_domain,
ip_type='4', ip_str="10.2.3.4")
addr.save()
self.assertFalse(prune_tree(the_domain))
f_c = create_fake_zone("y.z.foo.foo22", suffix="")
self.assertFalse(f_c.purgeable)
示例10: test_build_zone
def test_build_zone(self):
create_fake_zone('asdf1')
b = DNSBuilder(STAGE_DIR=self.stage_dir, PROD_DIR=self.prod_dir,
LOCK_FILE=self.lock_file, LOG_SYSLOG=False,
FIRST_RUN=True, PUSH_TO_PROD=False,
STOP_UPDATE_FILE=self.stop_update_file)
b.build_dns()
create_fake_zone('asdf2')
b.build_dns()
create_fake_zone('asdf3')
create_fake_zone('asdf4')
b.build_dns()
create_fake_zone('asdf5')
b.build_dns()
示例11: test_bad_nameserver_soa_state_case_3_0
def test_bad_nameserver_soa_state_case_3_0(self):
# This is Case 3
root_domain = create_fake_zone("asdf30")
for ns in root_domain.nameserver_set.all():
ns.delete()
soa = ns.domain.soa
ns.domain.soa = None
root_domain.soa = None # Shit's getting cached
ns.domain.save()
soa.delete()
# At his point we should have a domain pointed at no SOA record with no
# records attached to it. It also has no child domains.
# Add a record to the domain.
a = AddressRecord(
label='', domain=root_domain, ip_type="6", ip_str="1::")
a.save()
s = SOA(primary="asdf.asdf", contact="asdf.asdf", description="asdf")
s.save()
root_domain.soa = s
self.assertRaises(ValidationError, root_domain.save)
示例12: test_extend_doesnt_touch
def test_extend_doesnt_touch(self):
# When we create a new domain, ensure that things are not touched
root_domain = create_fake_zone("foo.mozilla.com", suffix="")
shouldnt_be_touched = AddressRecord.objects.create(
label='', domain=root_domain, ip_str='10.0.0.1', ip_type='4'
)
# Extend the tree
label, baz_domain = ensure_label_domain('bar.baz.foo.mozilla.com')
AddressRecord.objects.create(
label=label, domain=baz_domain, ip_str='10.0.0.1', ip_type='4'
)
# The update() call will bypass the save/clean method of AddressRecord
# so the fqdn of the A will remain unchanged. If our tree extender
# function is touching this record its label will be changed to ''.
AddressRecord.objects.filter(pk=shouldnt_be_touched.pk).update(
label='shouldnt be touched'
)
ensure_label_domain('wee.boo.bar.baz.foo.mozilla.com')
self.assertEqual(
'shouldnt be touched',
AddressRecord.objects.get(pk=shouldnt_be_touched.pk).label
)
示例13: setUp
def setUp(self):
self.factory = RequestFactory()
self.private_view, _ = View.objects.get_or_create(name='private')
self.operating_system = OperatingSystem.objects.create(
name='foo', version='1.1'
)
self.system_status = SystemStatus.objects.create(
status='production', color='burgandy', color_code='wtf?'
)
self.allocation = Allocation.objects.create(name='something')
self.system_type = SystemType.objects.create(
type_name='Virtual Server'
)
self.domain = create_fake_zone('foobar.mozilla.com', suffix='')
self.build_domain = create_fake_zone('build.mozilla.org', suffix='')
self.rdomain = create_fake_zone('10.in-addr.arpa', suffix='')
示例14: setUp
def setUp(self):
self.system = System()
d1 = create_fake_zone("mozilla.com.com", suffix="")
soa = d1.soa
v, _ = Vlan.objects.get_or_create(name="private", number=3)
s, _ = Site.objects.get_or_create(name="phx1")
s1, _ = Site.objects.get_or_create(name="corp", parent=s)
d, _ = Domain.objects.get_or_create(name="phx1.mozilla.com.com")
d.soa = soa
d.save()
d1, _ = Domain.objects.get_or_create(name="corp.phx1.mozilla.com.com")
d1.soa = soa
d1.save()
d2, _ = Domain.objects.get_or_create(
name="private.corp.phx1.mozilla.com.com")
d2.soa = soa
d2.save()
d, _ = Domain.objects.get_or_create(name="arpa")
d, _ = Domain.objects.get_or_create(name="in-addr.arpa")
d, _ = Domain.objects.get_or_create(name="ip6.arpa")
d, _ = Domain.objects.get_or_create(name="15.in-addr.arpa")
d, _ = Domain.objects.get_or_create(name="2.in-addr.arpa")
n = Network(network_str="15.0.0.0/8", ip_type="4")
n.clean()
n.site = s1
n.vlan = v
n.save()
r = Range(start_str="15.0.0.0", end_str="15.0.0.10",
network=n)
r.clean()
r.save()
示例15: test_cleanup_cname
def test_cleanup_cname(self):
# Make sure CNAME record block
c = Domain(name='foo1')
c.save()
self.assertFalse(c.purgeable)
f_c = create_fake_zone('foo.foo1', suffix="")
self.assertEqual(f_c.name, 'foo.foo1')
self.assertFalse(Domain.objects.filter(name="x.y.z.foo.foo1"))
self.assertFalse(Domain.objects.filter(name="y.z.foo.foo1"))
self.assertFalse(Domain.objects.filter(name="z.foo.foo1"))
self.assertTrue(Domain.objects.filter(name="foo.foo1"))
self.assertFalse(f_c.purgeable)
fqdn = "cname.x.y.z.foo.foo1"
label, the_domain = ensure_label_domain(fqdn)
cname = CNAME(label=label, domain=the_domain, target="foo")
cname.save()
self.assertFalse(prune_tree(the_domain))
cname.delete()
self.assertFalse(Domain.objects.filter(name="x.y.z.foo.foo1"))
self.assertFalse(Domain.objects.filter(name="y.z.foo.foo1"))
self.assertFalse(Domain.objects.filter(name="z.foo.foo1"))
fqdn = "bar.x.y.z.foo.poo"
self.assertTrue(Domain.objects.filter(name="foo.foo1"))