#!/usr/share/ucs-test/runner python3
## desc: Append locations during dns/srv_record modification
## tags: [udm]
## roles: [domaincontroller_master]
## exposure: careful
## packages:
##   - univention-config
##   - univention-directory-manager-tools

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

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_dns_record())

		locations = ['0 1 2 %s.%s' % (uts.random_name(), uts.random_name()), '9 3 5 %s.%s' % (uts.random_name(), uts.random_name()), '6 2 4 %s.%s' % (uts.random_name(), uts.random_name())]
		srv_record = udm.create_object('dns/srv_record', superordinate=forward_zone, name='%s tcp %s' % (uts.random_string(), uts.random_string()), location=locations[0])

		udm.modify_object('dns/srv_record', dn=srv_record, superordinate=forward_zone, append={'location': locations[1:]})
		utils.verify_ldap_object(srv_record, {'sRVRecord': locations})
