#!/usr/share/ucs-test/runner bash
# shellcheck shell=bash
## desc: "Make concurrent changes in AD"
## exposure: dangerous
## packages:
## - univention-s4-connector
## bugs:
##  - 35336

# Skip test, waiting for https://forge.univention.org/bugzilla/show_bug.cgi?id=35336
exit 131

# shellcheck source=../../lib/base.sh
. "$TESTLIBPATH/base.sh" || exit 137
# shellcheck source=../../lib/udm.sh
. "$TESTLIBPATH/udm.sh" || exit 137
# shellcheck source=../../lib/random.sh
. "$TESTLIBPATH/random.sh" || exit 137

. "s4connector.sh" || exit 137
test -n "$connector_s4_ldap_host" || exit 137
connector_running_on_this_host || exit 137

for((i=0;i<10;i++)); do

	echo "********************************************"
	echo "* Round $((i+1)) of 10"
	echo "********************************************"

	username="$(random_chars)"
	ad_createuser "$username" || fail_test 110
	AD_DN="CN=$username,CN=users,$(ad_get_base)"

	ad_wait_for_synchronization; fail_bool 0 110

	for((j=0;j<10;j++)); do
		ad_set_attribute "$AD_DN" "description" "univention$j"; fail_bool 0 110
		sleep $i
	done

	ad_wait_for_synchronization; fail_bool 0 110

	ad_verify_attribute "$AD_DN" "description" "univention9"; fail_bool 0 110

	ad_delete "$AD_DN" || fail_test 110

	if [ "$RETVAL" != 100 ]; then
		break
	fi
done

exit $RETVAL
