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

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

if __name__ == '__main__':
	with udm_test.UCSTestUDM() as udm:
		forward_zone = udm.create_object('dns/forward_zone', nameserver=uts.random_dns_record(), zone='%s.%s' % (uts.random_name(), uts.random_name()))
		try:
			ptr = udm.create_object('dns/ptr_record', address='40', superordinate=forward_zone)
		except udm_test.UCSTestUDM_CreateUDMObjectFailed:
			sys.exit(0)

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