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'
     )
Esempio n. 2
0
 def test_ptr_domain_not_exists(self):
     """A PTR record with 'only-if-domain' is created if domain exists"""
     RecordFactory(
         domain=self.domain,
         type='A',
         name='site.example.com',
         content='192.168.1.1',
         auto_ptr=AutoPtrOptions.ONLY_IF_DOMAIN,
     )
     assert_not_exists(Record, name='1.1.168.192.in-addr.arpa')
Esempio n. 3
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')
 def test_ptr_domain_not_exists(self):
     """A PTR record with 'only-if-domain' is created if domain exists"""
     RecordFactory(
         domain=self.domain,
         type='A',
         name='site.example.com',
         content='192.168.1.1',
         auto_ptr=AutoPtrOptions.ONLY_IF_DOMAIN,
     )
     assert_not_exists(
         Record,
         name='1.1.168.192.in-addr.arpa'
     )
Esempio n. 6
0
 def test_default_ptr_never(self):
     """A PTR record is not created if auto_ptr set to NEVER"""
     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.NEVER,
     )
     assert_not_exists(Record,
                       domain=domain,
                       name='1.1.168.192.in-addr.arpa')
 def test_default_ptr_never(self):
     """A PTR record is not created if auto_ptr set to NEVER"""
     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.NEVER,
     )
     assert_not_exists(
         Record,
         domain=domain,
         name='1.1.168.192.in-addr.arpa'
     )
Esempio n. 8
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')
Esempio n. 9
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')
 def test_auto_ptr_off(self):
     """PTR is removed when setting auto_ptr to NEVER"""
     record = RecordFactory(
         domain=self.domain,
         type='A',
         name='site.example.com',
         content='192.168.1.1',
         auto_ptr=AutoPtrOptions.ALWAYS,
     )
     domain = Domain.objects.get(name='1.168.192.in-addr.arpa')
     record.auto_ptr = AutoPtrOptions.NEVER
     record.save()
     assert_not_exists(
         Record,
         domain=domain,
         name='1.1.168.192.in-addr.arpa',
     )
 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',
     )