#!/usr/share/ucs-test/runner bash
#
# Univention System Activation
#  test script
#
# SPDX-FileCopyrightText: 2015-2025 Univention GmbH
# SPDX-License-Identifier: AGPL-3.0-only

. tools.inc.sh

timestamp_old="$(get_license_modify_timestamp)"
license_file="$(mktemp)"
univention-config-registry filter < /usr/share/univention-ldap/core-edition.ldif > "$license_file"
http --form "license=@${license_file}"
rm -f "$license_file"

has_request_failed &&
	fail_fast 1 'Import request for uploaded license file failed'

timestamp_new="$(get_license_modify_timestamp)"
if [ "$timestamp_new" -le "$timestamp_old" ]; then
	fail_fast 1 'License has not been updated in the LDAP'
else
	echo "License data has been written to the LDAP."
fi
