echo "running defines.sh"
. $SRCDIR/scripts/defines.sh
+if test $CONSTRAINT = constraintno; then
+ echo "Constraint overlay not available, test skipped"
+ exit 0
+fi
+
CONSTRAINTDIR="$DATADIR/constraint"
ROOTLDIF="$CONSTRAINTDIR/root.ldif"
USERLDIF="$CONSTRAINTDIR/user.ldif"
olcArgsFile: $TESTDIR/slapd.args
olcPidFile: $TESTDIR/slapd.pid
-dn: cn=module,cn=config
-objectClass: olcModuleList
-cn: module
-olcModulePath: $TESTWD/../servers/slapd/overlays
-olcModuleLoad: constraint.la
-
dn: cn=schema,cn=config
objectClass: olcSchemaConfig
cn: schema
dn: olcDatabase=config,cn=config
objectClass: olcDatabaseConfig
olcDatabase: config
+olcRootPW:< file://$CONFIGPWF
dn: olcDatabase={1}$BACKEND,cn=config
objectClass: olcDatabaseConfig
olcDatabase: $BACKEND
olcSuffix: $BASEDN
olcRootDN: $MANAGERDN
-olcRootPW:< file://$CONFIGPWF
+olcRootPW: $PASSWD
olcDbDirectory: $TESTDIR/db.1.a
olcDbIndex: objectClass eq,pres
olcDbIndex: ou,cn,mail,surname,givenname eq,pres,sub
+EOF
+
+echo "Starting slapd on TCP/IP port $PORT1..."
+$SLAPD -F $CONFDIR -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
+PID=$!
+if test $WAIT != 0 ; then
+ echo PID $PID
+ read foo
+fi
+
+sleep 1
+
+echo "Inserting constraint overlay... "
+if [ "$CONSTRAINT" = constraintmod ]; then
+ $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
+dn: cn=module,cn=config
+objectClass: olcModuleList
+cn: module
+olcModulePath: $TESTWD/../servers/slapd/overlays
+olcModuleLoad: constraint.la
+EOF
+ RC=$?
+ if test $RC != 0 ; then
+ echo "ldapadd failed ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $PID
+ exit $RC
+ fi
+fi
+$LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
dn: olcOverlay=constraint,olcDatabase={1}$BACKEND,cn=config
objectClass: olcOverlayConfig
objectClass: olcConstraintConfig
olcConstraintAttribute: mail count 3
olcConstraintAttribute: mail regex ^[[:alnum:]]+@example.com$
olcConstraintAttribute: description count 2
-
EOF
-
-$SLAPD -F $CONFDIR -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
-PID=$!
-if test $WAIT != 0 ; then
- echo PID $PID
- read foo
+RC=$?
+if test $RC != 0 ; then
+ echo "ldapadd failed ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $PID
+ exit $RC
fi
-sleep 1
-
echo "Adding basic structure..."
-$LDAPADD -D $MANAGERDN -H $URI1 -y $CONFIGPWF -f $ROOTLDIF &>/dev/null
+$LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $ROOTLDIF &>/dev/null
RC=$?
if test $RC != 0 ; then
echo "ldapadd failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $PID
exit $RC
fi
-$LDAPADD -D $MANAGERDN -H $URI1 -y $CONFIGPWF -f $USERLDIF &>/dev/null
+$LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $USERLDIF &>/dev/null
RC=$?
if test $RC != 0 ; then
echo "ldapadd failed ($RC)!"
echo "Running constraint tests..."
for ldif in $SRCDIR/data/constraint/{*ok*,*fail*}.ldif; do
### reload
- $LDAPDELETE -D $MANAGERDN -H $URI1 -y $CONFIGPWF $USERDN &>/dev/null
+ $LDAPDELETE -D "$MANAGERDN" -H $URI1 -w $PASSWD $USERDN &>/dev/null
RC=$?
if test $RC != 0 ; then
echo "ldapdelete failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $PID
exit $RC
fi
- $LDAPADD -D $MANAGERDN -H $URI1 -y $CONFIGPWF -f $USERLDIF &>/dev/null
+ $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $USERLDIF &>/dev/null
RC=$?
if test $RC != 0 ; then
echo "ldapadd failed ($RC)!"
echo -n " [$ldif]: "
### modify
- $LDAPMODIFY -H $URI1 -x -D "$MANAGERDN" -f $ldif -y $CONFIGPWF &>/dev/null
+ $LDAPMODIFY -H $URI1 -x -D "$MANAGERDN" -f $ldif -w $PASSWD &>/dev/null
RC=$?
if test $RC == 0 ; then
echo "OK" | tee -a $SCRIPTOUT