#!/usr/share/ucs-test/runner bash
## desc: Test zarafa contact object
## bugs: [31870]
## packages:
##  - zarafa4ucs
## tags:
##  - apptest
## exposure: dangerous

. "$TESTLIBPATH/base.sh" || exit 137
. "$TESTLIBPATH/user.sh" || exit 137
. "$TESTLIBPATH/random.sh" || exit 137
. "$TESTLIBPATH/zarafa.sh" || exit 137
. "/usr/share/univention-lib/all.sh" || exit 137

eval "$(/usr/sbin/ucr shell)"

RETVAL=100

stop_udm_cli_server

echo "Testing zarafa contacts..."
USERCOUNT=$(get_total_zarafa_user_count)
FIRSTNAME=$(user_randomname)
LASTNAME=$(user_randomname)
CN="$FIRSTNAME $LASTNAME"
createZarafaContact "$FIRSTNAME" "$LASTNAME"

wait_for_replication_and_postrun
sleep 3
zarafa-admin -l | egrep "$CN" && fail_test 110 "zarafa contact should not be visible in zarafa user list"

[ ! "$(get_total_zarafa_user_count)" = "$USERCOUNT" ] && fail_test 110 "creating a zarafa contact should not increase the usercount"

deleteZarafaContact "${CN}"
wait_for_replication

exit $RETVAL
