本文整理汇总了Python中mozdns.domain.models.Domain类的典型用法代码示例。如果您正苦于以下问题:Python Domain类的具体用法?Python Domain怎么用?Python Domain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Domain类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.o = Domain(name="org")
self.o.save()
self.o_e = Domain(name="oregonstate.org")
self.o_e.save()
self.b_o_e = Domain(name="bar.oregonstate.org")
self.b_o_e.save()
示例2: test_update_has_child_domain
def test_update_has_child_domain(self):
Domain(name='com99').save()
f_c = Domain(name='foo.com99')
f_c.save()
Domain(name='boo.foo.com99').save()
f_c.name = 'foobar.com99'
self.assertRaises(ValidationError, f_c.save)
示例3: DeleteStaticStaticRegTests
class DeleteStaticStaticRegTests(TestCase):
def create_domain(self, name, ip_type=None, delegated=False):
if ip_type is None:
ip_type = '4'
if name in ('arpa', 'in-addr.arpa', 'ip6.arpa'):
pass
else:
name = ip_to_domain_name(name, ip_type=ip_type)
d = Domain(name=name, delegated=delegated)
d.clean()
self.assertTrue(d.is_reverse)
return d
def setUp(self):
self.arpa = self.create_domain(name='arpa')
self.arpa.save()
self.i_arpa = self.create_domain(name='in-addr.arpa')
self.i_arpa.save()
self.c = Domain(name="ccc")
self.c.save()
self.f_c = Domain(name="foo.ccc")
self.f_c.save()
self.r1 = self.create_domain(name="10")
self.r1.save()
self.n = create_fake_host(hostname="foo.mozilla.com")
self.n.clean()
self.n.save()
View.objects.get_or_create(name="private")
def do_add(self, label, domain, ip_str, system, ip_type='4'):
r = StaticReg(
label=label, domain=domain, ip_str=ip_str,
ip_type=ip_type, system=system
)
r.clean()
r.save()
return r
def do_delete(self, r):
ip_str = r.ip_str
fqdn = r.fqdn
r.delete()
self.assertFalse(
AddressRecord.objects.filter(ip_str=ip_str, fqdn=fqdn))
def test1_delete_basic(self):
# Does deleting a system delete it's interfaces?
label = "foo"
domain = self.f_c
ip_str = "10.0.0.2"
system = create_fake_host(hostname="foo")
system.save()
kwargs = {
'label': label, 'domain': domain, 'ip_str': ip_str,
'system': system}
self.do_add(**kwargs)
self.assertTrue(StaticReg.objects.filter(**kwargs))
system.delete()
self.assertFalse(StaticReg.objects.filter(**kwargs))
示例4: test_bad_delete
def test_bad_delete(self):
network = "129.0.0.0"
prefixlen = "24"
kwargs = {'network': network, 'prefixlen': prefixlen, 'ip_type': '4'}
s = self.do_basic_add(**kwargs)
s_pk = s.pk
self.assertTrue(s)
d = Domain(name="asdf")
d.save()
start_str = "129.0.0.1"
end_str = "129.0.0.255"
network = s
r = Range(start_str=start_str, end_str=end_str, network=network)
r.clean()
r.save()
self.assertEqual(r.network, s)
self.assertTrue(len(s.range_set.all()) == 1)
self.assertRaises(ValidationError, s.delete)
self.assertTrue(Network.objects.get(pk=s_pk))
r.delete()
s.delete()
self.assertEqual(len(Network.objects.filter(pk=s_pk)), 0)
示例5: 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"))
示例6: CNAMEStaticRegTests
class CNAMEStaticRegTests(TestCase):
def create_domain(self, name, ip_type=None, delegated=False):
if ip_type is None:
ip_type = '4'
if name in ('arpa', 'in-addr.arpa', 'ip6.arpa'):
pass
else:
name = ip_to_domain_name(name, ip_type=ip_type)
d = Domain(name=name, delegated=delegated)
d.clean()
self.assertTrue(d.is_reverse)
return d
def setUp(self):
self.arpa = self.create_domain(name='arpa')
self.arpa.save()
self.i_arpa = self.create_domain(name='in-addr.arpa')
self.i_arpa.save()
self.c = Domain(name="ccc")
self.c.save()
self.f_c = Domain(name="foo.ccc")
self.f_c.save()
self.r1 = self.create_domain(name="10")
self.r1.save()
self.n = System()
self.n.clean()
self.n.save()
def do_add_intr(self, mac, label, domain, ip_str, ip_type='4'):
r = StaticInterface(mac=mac, label=label, domain=domain, ip_str=ip_str,
ip_type=ip_type, system=self.n)
r.clean()
r.save()
repr(r)
return r
def test1_delete_cname(self):
mac = "11:22:33:44:55:66"
label = "foo4"
domain = self.f_c
ip_str = "10.0.0.2"
kwargs = {'mac': mac, 'label': label, 'domain': domain,
'ip_str': ip_str}
i = self.do_add_intr(**kwargs)
cn, _ = CNAME.objects.get_or_create(label='foo', domain=domain,
target=label + "." + domain.name)
self.assertRaises(ValidationError, i.delete)
def test1_delete_override(self):
mac = "12:22:33:44:55:66"
label = "foo6"
domain = self.f_c
ip_str = "10.0.0.2"
kwargs = {'mac': mac, 'label': label, 'domain': domain,
'ip_str': ip_str}
i = self.do_add_intr(**kwargs)
cn, _ = CNAME.objects.get_or_create(label='food', domain=domain,
target=label + "." + domain.name)
i.delete(check_cname=False)
示例7: test_delegation_add_domain
def test_delegation_add_domain(self):
name = "boom1"
dom = Domain(name=name, delegated=True)
dom.save()
name = "boom.boom1"
dom = Domain(name=name, delegated=False)
self.assertRaises(ValidationError, dom.save)
示例8: SSHFPTests
class SSHFPTests(TestCase):
def setUp(self):
self.o = Domain(name="org")
self.o.save()
self.o_e = Domain(name="mozilla.org")
self.o_e.save()
def do_generic_add(self, data):
sshfp = SSHFP(**data)
sshfp.__repr__()
sshfp.save()
self.assertTrue(sshfp.details())
self.assertTrue(sshfp.get_absolute_url())
self.assertTrue(sshfp.get_edit_url())
self.assertTrue(sshfp.get_delete_url())
rsshfp = SSHFP.objects.filter(**data)
self.assertEqual(len(rsshfp), 1)
return sshfp
def do_remove(self, data):
sshfp = self.do_generic_add(data)
sshfp.delete()
rmx = SSHFP.objects.filter(**data)
self.assertTrue(len(rmx) == 0)
def test_add_remove_sshfp(self):
label = "asdf"
key = "eee85bca3608ec860fc290bea491ce35d1f0a094"
s_type = 1
a_type = 1
data = {'label': label, 'key': key, 'domain': self.o_e,
'algorithm_number': a_type, 'fingerprint_type': s_type}
self.do_generic_add(data)
label = "asdk"
key = "eee85bca3608ac860fc290bea491ce35d1f0a094"
s_type = 1
a_type = 1
data = {'label': label, 'key': key, 'domain': self.o_e,
'algorithm_number': a_type, 'fingerprint_type': s_type}
self.do_generic_add(data)
label = "df"
key = "eee85bca3608ec860fc290bea491ce35d1f0a094"
s_type = 1
a_type = 1
data = {'label': label, 'key': key, 'domain': self.o_e,
'algorithm_number': a_type, 'fingerprint_type': s_type}
self.do_generic_add(data)
label = "12314"
key = "eee85bca3608ec860fc290bea491ce35d1f0a094"
s_type = 1
a_type = 1
data = {'label': label, 'key': key, 'domain': self.o,
'algorithm_number': a_type, 'fingerprint_type': s_type}
self.do_generic_add(data)
示例9: test_remove_has_child_records
def test_remove_has_child_records(self):
Domain(name='com').save()
f_c = Domain(name='foo.com')
f_c.save()
cn = CNAME(domain=f_c, label="no", target="asdf")
cn.full_clean()
cn.save()
self.assertRaises(ValidationError, f_c.delete)
示例10: build_sample_domain
def build_sample_domain():
domain_name = ''
for i in range(2):
domain_name = random_label()
domain = Domain(name=domain_name)
soa = SOA(
primary=random_label(), contact="asf", description=random_label())
soa.save()
domain.soa = soa
domain.save()
return domain
示例11: create_domain
def create_domain(self, name, ip_type=None, delegated=False):
if ip_type is None:
ip_type = '4'
if name in ('arpa', 'in-addr.arpa', 'ip6.arpa'):
pass
else:
name = ip_to_domain_name(name, ip_type=ip_type)
d = Domain(name=name, delegated=delegated)
d.clean()
self.assertTrue(d.is_reverse)
return d
示例12: test_add_address_underscore_in_name_domain
def test_add_address_underscore_in_name_domain(self):
d = Domain(name="_mssucks.edu")
d.save()
data = {'label': '*', 'domain': d, 'ip': "128.193.0.10"}
self.do_add_record(data)
data = {'label': 'foo', 'domain': d, 'ip': "128.193.0.10"}
a = self.do_add_record(data)
a.save()
data = {'label': 'noop', 'domain': d, 'ip': "128.193.0.10"}
self.do_add_record(data)
示例13: test2_add_domain
def test2_add_domain(self):
# Some domains have '_' in their name. Make sure validation allows
# this.
c = Domain(name='cz')
c.save()
c1 = Domain(name='_foo.cz')
c1.save()
c2 = Domain(name='moo_foo._foo.cz')
c2.save()
示例14: TXTTests
class TXTTests(TestCase):
def setUp(self):
self.o = Domain(name="org")
self.o.save()
self.o_e = Domain(name="oregonstate.org")
self.o_e.save()
def do_generic_add(self, data):
txt = TXT(**data)
txt.__repr__()
txt.save()
self.assertTrue(txt.details())
self.assertTrue(txt.get_absolute_url())
self.assertTrue(txt.get_edit_url())
self.assertTrue(txt.get_delete_url())
rtxt = TXT.objects.filter(**data)
self.assertTrue(len(rtxt) == 1)
return txt
def do_remove(self, data):
txt = self.do_generic_add(data)
txt.delete()
rmx = TXT.objects.filter(**data)
self.assertTrue(len(rmx) == 0)
def test_add_remove_txt(self):
label = "asdf"
data = "asdf"
data = {'label': label, 'txt_data': data, 'domain': self.o_e}
self.do_generic_add(data)
label = "asdf"
data = "asdfasfd"
data = {'label': label, 'txt_data': data, 'domain': self.o_e}
self.do_generic_add(data)
label = "df"
data = "aasdf"
data = {'label': label, 'txt_data': data, 'domain': self.o_e}
self.do_generic_add(data)
label = "12314"
data = "dd"
data = {'label': label, 'txt_data': data, 'domain': self.o}
self.do_generic_add(data)
def test_bad_data(self):
label = "asdf"
data = '"dfa f'
data = {'label': label, 'txt_data': data, 'domain': self.o_e}
self.assertRaises(ValidationError, self.do_generic_add, data)
示例15: test_no_soa_block2
def test_no_soa_block2(self):
c = Domain(name='moo')
c.save()
f_c = Domain(name='foo.moo')
f_c.save()
s, _ = SOA.objects.get_or_create(primary="bar23", contact="Foo",
description="bar")
f_c.soa = s
f_c.save()
self.assertRaises(ValidationError, ensure_label_domain, "baz.moo")