#!/usr/share/ucs-test/runner bash
# shellcheck shell=bash
## desc: Test prohibitedObjectClass in UMC policy
## exposure: careful
## tags: [udm]
## bugs:
##  - 38663
##  - 38712

PROPERTY='prohibitedObjectClasses'
PROPVAL='univentionDhcpService'
# shellcheck source=../../lib/base.sh
. "$TESTLIBPATH/base.sh" || exit 137
. udm.sh || exit 137

check () {
	wait_for_replication
	policy "cn=$name,$BASE" -s >"$tmp/service.sh"
	grep -Fx "univentionDhcpRouters=\"$router\"" "$tmp/service.sh" &&
		die "Policy applied to DHCP-Service not having objectClass=$PROPVAL"
	pypolicy "cn=$name,$BASE" \
		"{'univentionDhcpRouters': {'policy': 'cn=p1,cn=$name,$BASE'}}" &&
		die "Policy applied to DHCP-Service not having objectClass=$PROPVAL"

	policy "cn=$NET,cn=$name,$BASE" -s >"$tmp/subnet.sh"
	grep -Fx "univentionDhcpRouters=\"$router\"" "$tmp/subnet.sh" ||
		die "Policy not applied to DHCP-Subnet having objectClass=$PROPVAL"
	pypolicy "cn=$NET,cn=$name,$BASE" \
		"{'univentionDhcpRouters': {'policy': 'cn=p1,cn=$name,$BASE', 'fixed': 0, 'value': ['$router']}}" ||
		die "Policy not applied to DHCP-Subnet having objectClass=$PROPVAL"
}

setup
check
toggle_case
check
:
