#!/usr/share/ucs-test/runner python3
## desc: Create dns/host record with wrong object type as superordinate
## tags: [udm]
## roles: [domaincontroller_master]
## bugs: [15660]
## exposure: careful
## packages:
##   - univention-config
##   - univention-directory-manager-tools
## versions:
##  3.1-1: skip

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


def main(subnet):
	with udm_test.UCSTestUDM() as udm:
		reverse_zone = udm.create_object('dns/reverse_zone', nameserver=uts.random_dns_record(), subnet=subnet)
		try:
			dns_host = udm.create_object('dns/host_record', name=uts.random_name(), superordinate=reverse_zone)
		except udm_test.UCSTestUDM_CreateUDMObjectFailed:
			return

		ldap = uldap.getAdminConnection()
		ldap.delete(dns_host)
		utils.fail('UDM did not report an error while trying to create an host record with reverse zone as superordinate')


if __name__ == '__main__':
	for subnet in ('10.20.30', '2011:06f8:13dc:0002:19b7:d592:09dd'):
		main(subnet)
