#!/usr/share/ucs-test/runner bash
# shellcheck shell=bash
## desc: Test policy ignores ordering of objectClasses
## exposure: careful
## tags: [udm]
## roles:
##  - domaincontroller_master
## join: true
## bugs:
##  - 41641

# shellcheck source=../../lib/base.sh
. "$TESTLIBPATH/base.sh" || exit 137
. udm.sh || exit 137

setup () {
	udm-test dhcp/service create \
		--position "$BASE" \
		--set service="$name"

	ldapadd -x -D "cn=admin,$ldap_base" -y /etc/ldap.secret <<__LDIF__
dn: cn=p1,cn=$name,$BASE
objectClass: top
objectClass: univentionPolicy
objectClass: univentionPolicyDhcpRouting
objectClass: univentionObject
univentionObjectType: policies/dhcp_routing
cn: p1
univentionDhcpRouters: 192.168.0.1

dn: cn=p2,cn=$name,$BASE
objectClass: top
objectClass: univentionPolicyDhcpRouting
objectClass: univentionPolicy
objectClass: univentionObject
univentionObjectType: policies/dhcp_routing
cn: p2
univentionDhcpRouters: 192.168.0.1

__LDIF__
}

check () {
	udm-test dhcp/service modify \
		--dn "cn=$name,$BASE" \
		--policy-reference "cn=p1,cn=$name,$BASE"
	wait_for_replication
	policy "cn=$name,$BASE" >"$tmp/1"

	udm-test dhcp/service modify \
		--dn "cn=$name,$BASE" \
		--policy-reference "cn=p2,cn=$name,$BASE"
	wait_for_replication
	policy "cn=$name,$BASE" >"$tmp/2"

	diff -u "$tmp/1" "$tmp/2"
}

setup
check
:
