def test_template_delete(self):
     """Records are deleted if corresponding template is deleted"""
     # This is managed by django's default ForeignKey.on_delete
     # so doesn't need implementation, but let's test it anyways:
     domain = Domain(
         name='example.com',
         template=self.domain_template1,
         reverse_template=self.domain_template2,
     )
     domain.save()
     assert_does_exist(
         Record,
         domain=domain,
         content='192.168.1.3'
     )
     assert_does_exist(
         Record,
         name='3.1.168.192.in-addr.arpa',
         type='PTR'
     )
     self.t1_a_record.delete()
     self.assertEqual(domain.record_set.count(), 2)
     assert_not_exists(
         Record,
         domain=domain,
         content='192.168.1.3'
     )
     assert_not_exists(
         Record,
         name='3.1.168.192.in-addr.arpa',
         type='PTR'
     )
Exemplo n.º 2
0
 def test_record_creation(self):
     request = RecordRequest.objects.create(
         domain=self.domain,
         type='CNAME',
         name='site.example.com',
         content='www.example.com',
     )
     request.accept()
     assert_does_exist(Record, content='www.example.com')
Exemplo n.º 3
0
 def test_subdomain_creation(self):
     request = DomainRequest.objects.create(
         parent_domain=self.domain,
         name='subdomain.example.com',
         owner=self.user1,
     )
     request.accept()
     assert_does_exist(
         Domain, name='subdomain.example.com', owner=self.user1
     )
Exemplo n.º 4
0
 def test_record_change(self):
     request = RecordRequest.objects.create(
         domain=self.domain,
         record=self.record,
         type='CNAME',
         name='forum.example.com',
         content='djangobb.example.com',
     )
     request.accept()
     assert_does_exist(Record, content='djangobb.example.com')
     assert_not_exists(Record, content='phpbb.example.com')
 def test_ptr_autoremove(self):
     """A PTR record is automatically removed with its A record"""
     a = RecordFactory(
         domain=self.domain,
         type='A',
         name='site.example.com',
         content='192.168.1.1',
         auto_ptr=AutoPtrOptions.ALWAYS,
     )
     assert_does_exist(Record, name='1.1.168.192.in-addr.arpa', type='PTR')
     a.delete()
     assert_not_exists(Record, name='1.1.168.192.in-addr.arpa', type='PTR')
Exemplo n.º 6
0
 def test_template_add(self):
     """Records are added if the domain template gets a new record
     template"""
     domain = Domain(name='example.com', template=self.domain_template1)
     domain.save()
     self.t1_ns2_record = RecordTemplateFactory(
         type='NS',
         name='{domain-name}',
         content=('ns2.{domain-name}'),
         domain_template=self.domain_template1,
     )
     self.assertEqual(domain.record_set.count(), 4)
     assert_does_exist(Record, domain=domain, content='ns2.example.com')
Exemplo n.º 7
0
 def test_ptr_domain_exists(self):
     """A PTR record with 'only-if-domain' is created if domain exists"""
     domain = DomainFactory(name='1.168.192.in-addr.arpa')
     RecordFactory(
         domain=self.domain,
         type='A',
         name='site.example.com',
         content='192.168.1.1',
         auto_ptr=AutoPtrOptions.ONLY_IF_DOMAIN,
     )
     assert_does_exist(Record,
                       domain=domain,
                       name='1.1.168.192.in-addr.arpa')
 def test_ptr_domain_exists(self):
     """A PTR record with 'only-if-domain' is created if domain exists"""
     domain = DomainFactory(name='1.168.192.in-addr.arpa')
     RecordFactory(
         domain=self.domain,
         type='A',
         name='site.example.com',
         content='192.168.1.1',
         auto_ptr=AutoPtrOptions.ONLY_IF_DOMAIN,
     )
     assert_does_exist(
         Record,
         domain=domain,
         name='1.1.168.192.in-addr.arpa'
     )
Exemplo n.º 9
0
 def test_record_creation(self):
     """Records are created when template is used to create a domain"""
     domain = Domain(
         name='example.com',
         template=self.domain_template1,
         reverse_template=self.domain_template2,
     )
     domain.save()
     self.assertEqual(domain.record_set.count(), 3)
     self.assertSetEqual(
         set(r.content for r in domain.record_set.all()), {
             'ns1.example.com hostmaster.example.com '
             '0 43200 600 1209600 600', 'ns1.example.com', '192.168.1.3'
         })
     assert_does_exist(Record, type='PTR', name='3.1.168.192.in-addr.arpa')
 def test_template_add(self):
     """Records are added if the domain template gets a new record
     template"""
     domain = Domain(name='example.com', template=self.domain_template1)
     domain.save()
     self.t1_ns2_record = RecordTemplateFactory(
         type='NS',
         name='{domain-name}',
         content=(
             'ns2.{domain-name}'
         ),
         domain_template = self.domain_template1,
     )
     self.assertEqual(domain.record_set.count(), 4)
     assert_does_exist(Record, domain=domain, content='ns2.example.com')
Exemplo n.º 11
0
 def test_domain_change(self):
     request = DomainRequest.objects.create(
         domain=self.domain,
         name='example.com',
         type='MASTER',
         owner=self.user2,
     )
     request.accept()
     assert_does_exist(
         Domain,
         name='example.com',
         type='MASTER',
         owner=self.user1
     )
     assert_not_exists(Domain, name='example.com', type='NATIVE')
Exemplo n.º 12
0
 def test_template_delete(self):
     """Records are deleted if corresponding template is deleted"""
     # This is managed by django's default ForeignKey.on_delete
     # so doesn't need implementation, but let's test it anyways:
     domain = Domain(
         name='example.com',
         template=self.domain_template1,
         reverse_template=self.domain_template2,
     )
     domain.save()
     assert_does_exist(Record, domain=domain, content='192.168.1.3')
     assert_does_exist(Record, name='3.1.168.192.in-addr.arpa', type='PTR')
     self.t1_a_record.delete()
     self.assertEqual(domain.record_set.count(), 2)
     assert_not_exists(Record, domain=domain, content='192.168.1.3')
     assert_not_exists(Record, name='3.1.168.192.in-addr.arpa', type='PTR')
Exemplo n.º 13
0
 def test_default_ptr_created(self):
     """A PTR record is created for an A record with default template"""
     RecordFactory(
         domain=self.domain,
         type='A',
         name='site.example.com',
         content='192.168.1.1',
         auto_ptr=AutoPtrOptions.ALWAYS,
         owner=self.user,
     )
     domain = Domain.objects.get(name='1.168.192.in-addr.arpa')
     self.assertTrue(domain.get_soa().content.endswith('600'))
     assert_does_exist(
         Record,
         domain=domain,
         name='1.1.168.192.in-addr.arpa',
         owner=self.user,
     )
 def test_record_creation(self):
     """Records are created when template is used to create a domain"""
     domain = Domain(
         name='example.com',
         template=self.domain_template1,
         reverse_template=self.domain_template2,
     )
     domain.save()
     self.assertEqual(domain.record_set.count(), 3)
     self.assertSetEqual(
         set(r.content for r in domain.record_set.all()),
         {
             'ns1.example.com hostmaster.example.com '
             '0 43200 600 1209600 600',
             'ns1.example.com',
             '192.168.1.3'
         }
     )
     assert_does_exist(Record, type='PTR', name='3.1.168.192.in-addr.arpa')
Exemplo n.º 15
0
 def test_auto_ptr_edit(self):
     """PTR changes when A changes"""
     record = RecordFactory(
         domain=self.domain,
         type='A',
         name='site.example.com',
         content='192.168.1.1',
         auto_ptr=AutoPtrOptions.ALWAYS,
     )
     record.content = '192.168.1.9'
     record.save()
     domain = Domain.objects.get(name='1.168.192.in-addr.arpa')
     assert_does_exist(
         Record,
         domain=domain,
         name='9.1.168.192.in-addr.arpa',
     )
     assert_not_exists(
         Record,
         domain=domain,
         name='1.1.168.192.in-addr.arpa',
     )