#!/usr/share/ucs-test/runner bash
## desc: Create OX users with expired password
## bugs: [34140]
## packages:
##  - univention-ox
## tags:
##  - apptest
## exposure: dangerous

. "/usr/share/univention-lib/all.sh" || exit 137
. "ox.sh" || exit 137

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

RETVAL=100

username="$(user_randomname)"
mail="$(random_mailaddress)@$domainname"

create_ox_user "$username" "$mail" "" "" \
	--set overridePWHistory=0 \
	--set overridePWLength=0 \
	--set pwdChangeNextLogin=1

wait_for_replication

ox_login "$username" "univention" && fail_test 110 "Login with expired password was permitted"

new_password="$(random_string)"
change_password "$username" "$new_password"

wait_for_replication

ox_login "$username" "univention" && fail_test 110 "Login as OX user with the old password was allowed"
ox_login "$username" "$new_password" || fail_test 110 "Login as OX user with the new password was denied"

user_remove "$username"

wait_for_replication

exit $RETVAL
# vim:set ft=sh:
