#!/usr/share/ucs-test/runner python3
## desc: Check that required=True is enforced for multivalue extended attributes
## tags: [udm]
## roles: [domaincontroller_master]
## bugs: [31302]
## exposure: careful
## packages:
##   - univention-config
##   - univention-directory-manager-tools
## versions:
##  3.1-1: skip
##  3.2-0: fixed

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


def main():
	with udm_test.UCSTestUDM() as udm:
		udm.create_object(
			'settings/extended_attribute',
			position=udm.UNIVENTION_CONTAINER,
			name=uts.random_string(),
			shortDescription='Test short description',
			CLIName='univentionUCSTestAttribute',
			module='groups/group',
			objectClass='univentionFreeAttributes',
			ldapMapping='univentionFreeAttribute15',
			valueRequired='1',
			multivalue='1'
		)

		try:
			udm.create_group()
		except udm_test.UCSTestUDM_CreateUDMObjectFailed:
			return

		utils.fail('UDM did not report an error while trying to create an object even though a required multivalue extended attribute was not given')


if __name__ == '__main__':
	main()
