#!/usr/share/ucs-test/runner python
## desc: Set A and AAAA during dns/host modification
## tags: [udm]
## roles: [domaincontroller_master]
## exposure: careful
## packages:
##   - univention-config
##   - univention-directory-manager-tools

import univention.testing.utils as utils
import univention.testing.udm as udm_test
import univention.testing.strings as uts

if __name__ == '__main__':
	with udm_test.UCSTestUDM() as udm:
		forward_zone = udm.create_object('dns/forward_zone', zone = '%s.%s' % (uts.random_name(), uts.random_name()), nameserver = uts.random_string())

		# IPv4 case:
		host_record = udm.create_object('dns/host_record', superordinate = forward_zone, name = uts.random_name())

		ip = '10.20.30.40'
		udm.modify_object('dns/host_record', dn = host_record, superordinate = forward_zone, a = ip)
		utils.verify_ldap_object(host_record, {'aRecord': [ip]})

		# IPv6 case:
		host_record = udm.create_object('dns/host_record', superordinate = forward_zone, name = uts.random_name())

		ip = '2011:06f8:13dc:0002:19b7:d592:09dd:1041'
		udm.modify_object('dns/host_record', dn = host_record, superordinate = forward_zone, a = ip)
		utils.verify_ldap_object(host_record, {'aAAARecord': [ip]})
