set -e
service univention-management-console-server restart
sleep 2
for i in $(seq 1 10); do
	umc-set -U Administrator -P old -e -o '{"password": {"password": "old", "new_password": "new"}}' 2>&1 | grep "authentication failed"
done
service slapd restart
sleep 2
umc-set -U Administrator -P old -e -o '{"password": {"password": "old", "new_password": "new"}}' 2>&1 | grep "authentication failed"
close_waits=$(lsof -p $(pidof -x univention-management-console-server) | grep CLOSE_WAIT| wc -l)
if [ $close_waits -gt 0 ]; then
	echo "failed"
	exit 1
fi
