Пример #1
0
 def test_allows_underscores_without_addresses(self):
     name = factory.make_name('n_me')
     domain = factory.make_Domain()
     dnsresource = DNSResource(name=name, domain=domain)
     dnsresource.save()
     dnsresource_from_db = DNSResource.objects.get(name=name)
     self.assertThat(dnsresource_from_db, MatchesStructure.byEquality(
         name=name))
Пример #2
0
 def test_fqdn_returns_correctly_for_atsign(self):
     name = '@'
     domain = factory.make_Domain()
     dnsresource = DNSResource(name=name, domain=domain)
     dnsresource.save()
     sip = factory.make_StaticIPAddress()
     dnsresource.ip_addresses.add(sip)
     self.assertEqual(domain.name, dnsresource.fqdn)
Пример #3
0
 def test_allows_atsign(self):
     name = '@'
     domain = factory.make_Domain()
     dnsresource = DNSResource(name=name, domain=domain)
     dnsresource.save()
     dnsresource_from_db = DNSResource.objects.get(name=name)
     self.assertThat(dnsresource_from_db, MatchesStructure.byEquality(
         name=name))
Пример #4
0
 def test_creates_dnsresource(self):
     name = factory.make_name('name')
     domain = factory.make_Domain()
     dnsresource = DNSResource(name=name, domain=domain)
     dnsresource.save()
     dnsresource_from_db = DNSResource.objects.get(name=name)
     self.assertThat(dnsresource_from_db, MatchesStructure.byEquality(
         name=name))
Пример #5
0
 def test_get_addresses_returns_addresses(self):
     # Verify that the return includes node addresses, and
     # dnsresource-attached addresses.
     name = factory.make_name()
     domain = factory.make_Domain()
     dnsresource = DNSResource(name=name, domain=domain)
     dnsresource.save()
     subnet = factory.make_Subnet()
     node = factory.make_Node_with_Interface_on_Subnet(
         subnet=subnet, hostname=name, domain=domain)
     sip1 = factory.make_StaticIPAddress()
     node.interface_set.first().ip_addresses.add(sip1)
     sip2 = factory.make_StaticIPAddress()
     dnsresource.ip_addresses.add(sip2)
     self.assertItemsEqual(
         (sip1.get_ip(), sip2.get_ip()),
         dnsresource.get_addresses())
Пример #6
0
 def test_rejects_multiple_dnsresource_with_same_name(self):
     name = factory.make_name('name')
     domain = factory.make_Domain()
     dnsresource = DNSResource(name=name, domain=domain)
     dnsresource.save()
     dnsresource2 = DNSResource(name=name, domain=domain)
     with ExpectedException(
             ValidationError,
             re.escape("{'__all__': "
                       "['Labels must be unique within their zone.']")):
         dnsresource2.save(force_update=True)
Пример #7
0
 def test_rejects_addresses_if_underscore_in_name(self):
     name = factory.make_name("n_me")
     domain = factory.make_Domain()
     dnsresource = DNSResource(name=name, domain=domain)
     dnsresource.save()
     sip = factory.make_StaticIPAddress()
     dnsresource.ip_addresses.add(sip)
     with ExpectedException(
         ValidationError,
         re.escape("{'__all__': ['Invalid dnsresource name: %s." % (name,)),
     ):
         dnsresource.save(force_update=True)