#!/usr/share/ucs-test/runner python3
## desc: Move container/cn into another container/cn and the latter one into another container/cn
## tags: [udm]
## roles: [domaincontroller_master]
## exposure: careful
## packages:
##   - univention-config
##   - univention-directory-manager-tools

import ldap.dn

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:
		cn_name = uts.random_string()
		cn2_name = uts.random_string()

		cn = udm.create_object('container/cn', name=cn_name)
		cn2 = udm.create_object('container/cn', name=cn2_name)
		cn3 = udm.create_object('container/cn', name=uts.random_name())

		udm.move_object('container/cn', dn=cn, position=cn2)
		udm.move_object('container/cn', dn=cn2, position=cn3)
		utils.verify_ldap_object('cn=%s,cn=%s,%s' % (ldap.dn.escape_dn_chars(cn_name), ldap.dn.escape_dn_chars(cn2_name), cn3))
