#!/usr/share/ucs-test/runner bash
# shellcheck shell=bash
## desc: Change the server password
## roles-not: [basesystem]
## tags:
##  - SKIP-UCSSCHOOL
##  - basic
##  - apptest
## exposure: dangerous
## join: true

# shellcheck source=../../lib/base.sh
. "$TESTLIBPATH/base.sh" || exit 137
. /usr/share/univention-lib/ucr.sh

RETVAL=100

eval "$(ucr shell)"

old_interval=$server_password_interval

ucr set server/password/interval=0

/usr/lib/univention-server/server_password_change || fail_test 110 "server_password_change failed"

ucr set server/password/interval="$old_interval"

new_pw=$(< /etc/machine.secret)
if [ "$new_pw" = "$old_pw" ]; then
	fail_test 110 "machine.secret unchanged after server_password_change"
fi

wait_for_replication

/usr/share/univention-join/check_join_status || fail_test 110 "check_join_status failed"

exit $RETVAL
