#!/usr/share/ucs-test/runner python3
## desc: settings/extented_attribute
## tags: [udm,apptest]
## roles: [domaincontroller_master]
## exposure: careful
## packages:
##   - univention-directory-manager-tools

import univention.testing.udm as udm_test
from univention.config_registry import ConfigRegistry
import pytest


def main():
	ucr = ConfigRegistry()
	ucr.load()
	with udm_test.UCSTestUDM() as udm:
		kwargs = dict(name='test', ldapMapping='foo', objectClass='bar', shortDescription='test', valueRequired='1', CLIName='test', module=['users/user'])
		with pytest.raises(udm_test.UCSTestUDM_CreateUDMObjectFailed):
			udm.create_object('settings/extended_attribute', position='cn=custom attributes,cn=univention,%s' % ucr['ldap/base'], **kwargs)
		kwargs['default'] = 'foo'
		udm.create_object('settings/extended_attribute', position='cn=custom attributes,cn=univention,%s' % ucr['ldap/base'], **kwargs)


if __name__ == '__main__':
	main()
