Skip to content

Commit

Permalink
Merge pull request #258 from AvRajath/master
Browse files Browse the repository at this point in the history
Added TXT record
  • Loading branch information
AvRajath authored Apr 14, 2020
2 parents f2eca35 + 520f714 commit e7c2b79
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
18 changes: 17 additions & 1 deletion infoblox_client/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,5 +1090,21 @@ class MXRecord(InfobloxObject):
_all_searchable_fields = ['name', 'mail_exchanger', 'comment', 'creator',
'ddns_principal', 'preference', 'view', 'zone']
_updateable_search_fields = ['name', 'mail_exchanger', 'preference']
_return_fields = ['name', 'mail_exchanger', 'preference']
_return_fields = ['name', 'mail_exchanger', 'preference', 'extattrs']
_shadow_fields = ['_ref']


class TXTRecord(InfobloxObject):
_infoblox_type = 'record:txt'
_fields = ['aws_rte53_record_info', 'cloud_info', 'comment',
'creation_time', 'creator', 'ddns_principal', 'ddns_protected',
'disable', 'dns_name', 'extattrs', 'forbid_reclamation',
'last_queried', 'name', 'reclaimable', 'shared_record_group',
'text', 'ttl', 'use_ttl', 'view', 'zone']
_search_for_update_fields = ['name', 'view']
_updateable_search_fields = ['comment', 'creator', 'ddns_principal',
'name', 'text', 'view']
_all_searchable_fields = ['comment', 'creator', 'ddns_principal', 'name',
'reclaimable', 'text', 'view', 'zone']
_return_fields = ['extattrs', 'name', 'text', 'view']
_shadow_fields = ['_ref']
30 changes: 27 additions & 3 deletions tests/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
'mail_exchanger': 'demo.my_zone.com'
}

DEFAULT_TXT_RECORD = {
'_ref': 'record:txt/%s'
'text_test.my_zone.com/my_dns_view' % REC,
'view': 'my_dns_view',
'name': 'text_test.my_zone.com',
'text': 'hello_test'
}


class TestObjects(unittest.TestCase):

Expand Down Expand Up @@ -138,7 +146,7 @@ def test_Create_MX_Record(self):
{'name': 'mx.demo.my_zone.com',
'mail_exchanger': 'demo.my_zone.com',
'view': 'my_dns_view',
'preference': 1}, ['name', 'mail_exchanger', 'preference'])
'preference': 1}, ['name', 'mail_exchanger', 'preference', 'extattrs'])

def test_update_MX_Record(self):
mx_record_copy = [
Expand All @@ -158,7 +166,7 @@ def test_update_MX_Record(self):
{'name': 'mx1.demo.my_zone.com',
'mail_exchanger': 'demo2.my_zone.com',
'preference': 1},
['name', 'mail_exchanger', 'preference'])
['name', 'mail_exchanger', 'preference', 'extattrs'])

def test_search_and_delete_MX_Record(self):
mx_record_copy = copy.deepcopy(DEFAULT_MX_RECORD)
Expand All @@ -171,11 +179,12 @@ def test_search_and_delete_MX_Record(self):
'record:mx', {'view': 'some_view',
'name': 'some_name'},
extattrs=None, force_proxy=False, max_results=None,
return_fields=['name', 'mail_exchanger', 'preference'])
return_fields=['name', 'mail_exchanger', 'preference', 'extattrs'])
mx_record.delete()
connector.delete_object.assert_called_once_with(
DEFAULT_MX_RECORD['_ref'])


def test_create_host_record_with_ttl(self):
mock_record = DEFAULT_HOST_RECORD
host_record_copy = copy.deepcopy(mock_record)
Expand Down Expand Up @@ -526,3 +535,18 @@ def test__remap_fields_support_unknown_fields(self):
data = {'host_name': 'cp.com',
'unknown_field': 'some_data'}
self.assertEqual(data, objects.Member._remap_fields(data))

def test_TXT_Record(self):
mock_record = DEFAULT_TXT_RECORD
txt_record_copy = copy.deepcopy(mock_record)
connector = self._mock_connector(create_object=txt_record_copy)
txt = objects.TXTRecord.create(connector, name='text_test.my_zone.com',
text='hello_text',
view='my_dns_view')
self.assertIsInstance(txt, objects.TXTRecord)
connector.create_object.assert_called_once_with(
'record:txt',
{'name': 'text_test.my_zone.com',
'text': 'hello_text',
'view': 'my_dns_view',
}, ['extattrs', 'name', 'text', 'view'])

0 comments on commit e7c2b79

Please sign in to comment.