本文整理汇总了Python中mozdns.tests.utils.create_fake_zone函数的典型用法代码示例。如果您正苦于以下问题:Python create_fake_zone函数的具体用法?Python create_fake_zone怎么用?Python create_fake_zone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_fake_zone函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:Marlburo,项目名称:inventory,代码行数:35,代码来源:integration.py
示例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')
开发者ID:Marlburo,项目名称:inventory,代码行数:7,代码来源:view_tests.py
示例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)
开发者ID:Marlburo,项目名称:inventory,代码行数:32,代码来源:integration.py
示例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)
开发者ID:Marlburo,项目名称:inventory,代码行数:30,代码来源:integration.py
示例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
)
开发者ID:Marlburo,项目名称:inventory,代码行数:8,代码来源:tests.py
示例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()
开发者ID:rtucker-mozilla,项目名称:mozilla_inventory,代码行数:10,代码来源:tests.py
示例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()
开发者ID:Marlburo,项目名称:inventory,代码行数:10,代码来源:tests.py
示例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()
开发者ID:Marlburo,项目名称:inventory,代码行数:12,代码来源:basic.py
示例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)
开发者ID:Marlburo,项目名称:inventory,代码行数:13,代码来源:full_name.py
示例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()
开发者ID:caseybecking,项目名称:inventory,代码行数:14,代码来源:build_tests.py
示例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)
开发者ID:rtucker-mozilla,项目名称:mozilla_inventory,代码行数:25,代码来源:tests.py
示例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
)
开发者ID:Marlburo,项目名称:inventory,代码行数:26,代码来源:auto_create.py
示例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='')
开发者ID:bclary,项目名称:inventory,代码行数:16,代码来源:tests.py
示例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()
开发者ID:rtucker-mozilla,项目名称:mozilla_inventory,代码行数:34,代码来源:free_ip.py
示例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"))
开发者ID:Marlburo,项目名称:inventory,代码行数:27,代码来源:auto_delete.py
示例16: test_bad_nameserver_soa_state_case_3_2
def test_bad_nameserver_soa_state_case_3_2(self):
# This is Case 3 ... with ptrs
root_domain = create_fake_zone("32.in-addr.arpa", suffix="")
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.
ptr = PTR(name="asdf", ip_str="32.1.1.1", ip_type="4")
ptr.save()
s = SOA(primary="asdf.asdf", contact="asdf.asdf", description="asdf")
s.save()
root_domain.soa = s
self.assertRaises(ValidationError, root_domain.save)
开发者ID:rtucker-mozilla,项目名称:mozilla_inventory,代码行数:25,代码来源:tests.py
示例17: get_domain_and_post_data
def get_domain_and_post_data(self):
# This is different for classes that have ips instead of fqdns
domain_name = '11.22.11.in-addr.arpa'
root_domain = create_fake_zone(domain_name, suffix="")
post_data = self.post_data()
# Get the '_' in SRV records
post_data['ip_str'] = '11.22.11.1'
return root_domain, post_data
开发者ID:caseybecking,项目名称:inventory,代码行数:8,代码来源:basic.py
示例18: test_svn_conflict
def test_svn_conflict(self):
"""
This uses tasks as a block box measurement to see if conflicts are
being handled
"""
root_domain = create_fake_zone('conflict')
b1 = 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=True,
STOP_UPDATE_FILE=self.stop_update_file)
b1.build_dns() # This checked stuff in
# Check the repo out somewhere elst
command_str = "svn co file://{0} {1}".format(
self.svn_repo, self.prod_dir2
)
b1.shell_out(command_str)
# Calculate the path to the zone file so we can tamper with it.
fm = b1.get_file_meta(
View.objects.get(name='public'), root_domain,
root_domain.soa
)
# Make local changes
fname = fm['prod_fname'].replace(self.prod_dir, self.prod_dir2)
with open(fname, 'a') as fd:
fd.write(";foobar")
# Check those changes in.
b1.PROD_DIR = self.prod_dir2 # Cheat and swap the dirs
b1.vcs_checkin()
b1.PROD_DIR = self.prod_dir # Fix our little cheat
b1.FORCE = True # Force a build
# Add something to the end of the file to cause a collision
a = AddressRecord.objects.create(
label="zeenada", domain=root_domain, ip_type='4',
ip_str='255.0.0.0'
)
a.views.add(View.objects.get(name='public'))
# Alright, we should have conflicts here. See if we detect it by
# counting how many tasks need to be serviced. If the number remains
# the same that means we aborted the build due to a conflict
pre_task_count = Task.objects.all().count()
b1.build_dns()
post_task_count = Task.objects.all().count()
self.assertEqual(pre_task_count, post_task_count)
# Conflicts should be resolved. Let's see if we build successfully
pre_task_count = Task.objects.all().count()
b1.build_dns()
post_task_count = Task.objects.all().count()
self.assertTrue(pre_task_count != 0)
self.assertEqual(0, post_task_count)
开发者ID:caseybecking,项目名称:inventory,代码行数:58,代码来源:build_tests.py
示例19: test_too_many_config_lines_changed
def test_too_many_config_lines_changed(self):
create_fake_zone('asdf86')
root_domain1 = create_fake_zone('asdf87')
root_domain2 = create_fake_zone('asdf88')
root_domain3 = create_fake_zone('asdf89')
create_fake_zone('asdf90')
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=True,
STOP_UPDATE_FILE=self.stop_update)
self.assertTrue(Task.dns_full.all())
self.assertFalse(Task.dns_incremental.all().count())
b.build_dns()
self.assertFalse(Task.dns_full.all())
self.assertFalse(Task.dns_incremental.all())
# deleting one ns
for ns in root_domain1.nameserver_set.all():
ns.delete()
self.assertTrue(Task.dns_full.all())
self.assertEqual(1, Task.dns_incremental.all().count())
b.build_dns() # One zone removed should be okay
for ns in root_domain2.nameserver_set.all():
ns.delete()
for ns in root_domain3.nameserver_set.all():
ns.delete()
b.PUSH_TO_PROD = True
self.assertRaises(BuildError, b.build_dns)
开发者ID:Marlburo,项目名称:inventory,代码行数:34,代码来源:build_tests.py
示例20: setUp
def setUp(self):
from reversion.models import Version, Revision
Version.objects.all().delete()
Revision.objects.all().delete()
super(MozdnsAPITests, self).setUp()
self.domain = create_fake_zone(self.__class__.__name__.lower())
self.public_view = View.objects.get_or_create(name='public')[0]
self.private_view = View.objects.get_or_create(name='private')[0]
开发者ID:Marlburo,项目名称:inventory,代码行数:9,代码来源:test_basic.py
注:本文中的mozdns.tests.utils.create_fake_zone函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论