From 03ac28c541cfe151f6ffcb336631d587d44b6cf8 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Wed, 12 Sep 2007 21:13:49 +0000 Subject: [PATCH] slapo-memberof test --- tests/data/memberof.out | 150 +++++++++++++++++++ tests/data/slapd-config-naked.conf | 14 ++ tests/scripts/defines.sh | 2 + tests/scripts/test052-memberof | 228 +++++++++++++++++++++++++++++ 4 files changed, 394 insertions(+) create mode 100644 tests/data/memberof.out create mode 100644 tests/data/slapd-config-naked.conf create mode 100755 tests/scripts/test052-memberof diff --git a/tests/data/memberof.out b/tests/data/memberof.out new file mode 100644 index 0000000000..ff6e7e3a63 --- /dev/null +++ b/tests/data/memberof.out @@ -0,0 +1,150 @@ +# Search the entire database... +dn: cn=Baby Herman,ou=People,dc=example,dc=com +objectClass: inetOrgPerson +cn: Baby Herman +sn: Herman +memberOf: cn=Cartoonia,ou=Groups,dc=example,dc=com + +dn: cn=Cartoonia,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Cartoonia +member: cn=Roger Rabbit,ou=People,dc=example,dc=com +member: cn=Baby Herman,ou=People,dc=example,dc=com + +dn: dc=example,dc=com +objectClass: organization +objectClass: dcObject +o: Example, Inc. +dc: example + +dn: ou=Groups,dc=example,dc=com +objectClass: organizationalUnit +ou: Groups + +dn: ou=People,dc=example,dc=com +objectClass: organizationalUnit +ou: People + +dn: cn=Roger Rabbit,ou=People,dc=example,dc=com +objectClass: inetOrgPerson +cn: Roger Rabbit +sn: Rabbit +memberOf: cn=Cartoonia,ou=Groups,dc=example,dc=com + +# Re-search the entire database... +dn: cn=Baby Herman,ou=People,dc=example,dc=com +objectClass: inetOrgPerson +cn: Baby Herman +sn: Herman +memberOf: cn=Cartoonia,ou=Groups,dc=example,dc=com + +dn: cn=Cartoonia,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Cartoonia +member: cn=Roger Rabbit,ou=People,dc=example,dc=com +member: cn=Baby Herman,ou=People,dc=example,dc=com +member: cn=Jessica Rabbit,ou=People,dc=example,dc=com + +dn: dc=example,dc=com +objectClass: organization +objectClass: dcObject +o: Example, Inc. +dc: example + +dn: ou=Groups,dc=example,dc=com +objectClass: organizationalUnit +ou: Groups + +dn: cn=Jessica Rabbit,ou=People,dc=example,dc=com +objectClass: inetOrgPerson +cn: Jessica Rabbit +sn: Rabbit +memberOf: cn=Cartoonia,ou=Groups,dc=example,dc=com + +dn: ou=People,dc=example,dc=com +objectClass: organizationalUnit +ou: People + +dn: cn=Roger Rabbit,ou=People,dc=example,dc=com +objectClass: inetOrgPerson +cn: Roger Rabbit +sn: Rabbit +memberOf: cn=Cartoonia,ou=Groups,dc=example,dc=com + +# Re-search the entire database... +dn: cn=Baby Herman,ou=People,dc=example,dc=com +objectClass: inetOrgPerson +cn: Baby Herman +sn: Herman +memberOf: cn=Cartoonia,ou=Groups,dc=example,dc=com + +dn: cn=Cartoonia,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Cartoonia +member: cn=Roger Rabbit,ou=People,dc=example,dc=com +member: cn=Baby Herman,ou=People,dc=example,dc=com +member: cn=Jessica Rabbit,ou=People,dc=example,dc=com +member: cn=Cartoonia,ou=Groups,dc=example,dc=com +memberOf: cn=Cartoonia,ou=Groups,dc=example,dc=com + +dn: dc=example,dc=com +objectClass: organization +objectClass: dcObject +o: Example, Inc. +dc: example + +dn: ou=Groups,dc=example,dc=com +objectClass: organizationalUnit +ou: Groups + +dn: cn=Jessica Rabbit,ou=People,dc=example,dc=com +objectClass: inetOrgPerson +cn: Jessica Rabbit +sn: Rabbit +memberOf: cn=Cartoonia,ou=Groups,dc=example,dc=com + +dn: ou=People,dc=example,dc=com +objectClass: organizationalUnit +ou: People + +dn: cn=Roger Rabbit,ou=People,dc=example,dc=com +objectClass: inetOrgPerson +cn: Roger Rabbit +sn: Rabbit +memberOf: cn=Cartoonia,ou=Groups,dc=example,dc=com + +# Re-search the entire database... +dn: cn=Cartoonia,ou=Groups,dc=example,dc=com +objectClass: groupOfNames +cn: Cartoonia +member: cn=Roger Rabbit,ou=People,dc=example,dc=com +member: cn=Jessica Rabbit,ou=People,dc=example,dc=com +member: cn=Cartoonia,ou=Groups,dc=example,dc=com +memberOf: cn=Cartoonia,ou=Groups,dc=example,dc=com + +dn: dc=example,dc=com +objectClass: organization +objectClass: dcObject +o: Example, Inc. +dc: example + +dn: ou=Groups,dc=example,dc=com +objectClass: organizationalUnit +ou: Groups + +dn: cn=Jessica Rabbit,ou=People,dc=example,dc=com +objectClass: inetOrgPerson +cn: Jessica Rabbit +sn: Rabbit +memberOf: cn=Cartoonia,ou=Groups,dc=example,dc=com + +dn: ou=People,dc=example,dc=com +objectClass: organizationalUnit +ou: People + +dn: cn=Roger Rabbit,ou=People,dc=example,dc=com +objectClass: inetOrgPerson +cn: Roger Rabbit +sn: Rabbit +memberOf: cn=Cartoonia,ou=Groups,dc=example,dc=com + diff --git a/tests/data/slapd-config-naked.conf b/tests/data/slapd-config-naked.conf new file mode 100644 index 0000000000..ad7b2e7e89 --- /dev/null +++ b/tests/data/slapd-config-naked.conf @@ -0,0 +1,14 @@ +include @SCHEMADIR@/core.schema +include @SCHEMADIR@/cosine.schema +include @SCHEMADIR@/inetorgperson.schema +include @SCHEMADIR@/openldap.schema + +#mod#modulepath ../servers/slapd/back-@BACKEND@/ +#mod#moduleload back_@BACKEND@.la +#monitormod#modulepath ../servers/slapd/back-monitor/ +#monitormod#moduleload back_monitor.la + +#monitor#database monitor + +database config +include @TESTDIR@/configpw.conf diff --git a/tests/scripts/defines.sh b/tests/scripts/defines.sh index a3168c00ed..ae55ad3995 100755 --- a/tests/scripts/defines.sh +++ b/tests/scripts/defines.sh @@ -124,6 +124,7 @@ PLSRMASTERCONF=$DATADIR/slapd-syncrepl-multiproxy.conf DDSCONF=$DATADIR/slapd-dds.conf PASSWDCONF=$DATADIR/slapd-passwd.conf UNDOCONF=$DATADIR/slapd-config-undo.conf +NAKEDCONF=$DATADIR/slapd-config-naked.conf DYNAMICCONF=$DATADIR/slapd-dynamic.ldif @@ -325,6 +326,7 @@ SUBTREERENAMEOUT=$DATADIR/subtree-rename.out ACIOUT=$DATADIR/aci.out DYNLISTOUT=$DATADIR/dynlist.out DDSOUT=$DATADIR/dds.out +MEMBEROFOUT=$DATADIR/memberof.out SHTOOL="$SRCDIR/../build/shtool" # Just in case we linked the binaries dynamically diff --git a/tests/scripts/test052-memberof b/tests/scripts/test052-memberof new file mode 100755 index 0000000000..687b53ede8 --- /dev/null +++ b/tests/scripts/test052-memberof @@ -0,0 +1,228 @@ +#! /bin/sh +# $OpenLDAP$ +## This work is part of OpenLDAP Software . +## +## Copyright 1998-2007 The OpenLDAP Foundation. +## All rights reserved. +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted only as authorized by the OpenLDAP +## Public License. +## +## A copy of this license is available in the file LICENSE in the +## top-level directory of the distribution or, alternatively, at +## . + +echo "running defines.sh" +. $SRCDIR/scripts/defines.sh + +mkdir -p $TESTDIR $DBDIR1 $TESTDIR/confdir + +$SLAPPASSWD -g -n >$CONFIGPWF +echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf + +echo "Starting slapd on TCP/IP port $PORT1..." +. $CONFFILTER $BACKEND $MONITORDB < $NAKEDCONF > $CONF1 +$SLAPD -f $CONF1 -F $TESTDIR/confdir -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & +PID=$! +if test $WAIT != 0 ; then + echo PID $PID + read foo +fi +KILLPIDS="$PID" + +sleep 1 +for i in 0 1 2 3 4 5; do + $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \ + 'objectclass=*' > /dev/null 2>&1 + RC=$? + if test $RC = 0 ; then + break + fi + echo "Waiting 5 seconds for slapd to start..." + sleep 5 +done +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +cat /dev/null > $TESTOUT + +echo "Running ldapadd to build slapd config database..." +$LDAPADD -h $LOCALHOST -p $PORT1 -D 'cn=config' -w `cat $CONFIGPWF` \ + >> $TESTOUT 2>&1 <> $TESTOUT 2>&1 << EOF +dn: $BASEDN +objectClass: organization +objectClass: dcObject +o: Example, Inc. +dc: example + +dn: ou=People,$BASEDN +objectClass: organizationalUnit +ou: People + +dn: ou=Groups,$BASEDN +objectClass: organizationalUnit +ou: Groups + +dn: cn=Roger Rabbit,ou=People,$BASEDN +objectClass: inetOrgPerson +cn: Roger Rabbit +sn: Rabbit + +dn: cn=Baby Herman,ou=People,$BASEDN +objectClass: inetOrgPerson +cn: Baby Herman +sn: Herman + +dn: cn=Cartoonia,ou=Groups,$BASEDN +objectClass: groupOfNames +cn: Cartoonia +member: cn=Roger Rabbit,ou=People,$BASEDN +member: cn=Baby Herman,ou=People,$BASEDN +EOF +RC=$? +if test $RC != 0 ; then + echo "ldapadd failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Search the entire database..." +echo "# Search the entire database..." >> $SEARCHOUT +$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ + '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1 +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Running ldapmodify to add a member..." +$LDAPMODIFY -h $LOCALHOST -p $PORT1 \ + -D "cn=Manager,$BASEDN" -w secret \ + >> $TESTOUT 2>&1 << EOF +dn: cn=Jessica Rabbit,ou=People,$BASEDN +changetype: add +objectClass: inetOrgPerson +cn: Jessica Rabbit +sn: Rabbit + +dn: cn=Cartoonia,ou=Groups,$BASEDN +changetype: modify +add: member +member: cn=Jessica Rabbit,ou=People,$BASEDN +EOF + +echo "Re-search the entire database..." +echo "# Re-search the entire database..." >> $SEARCHOUT +$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ + '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1 +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Running ldapmodify to add self..." +$LDAPMODIFY -h $LOCALHOST -p $PORT1 \ + -D "cn=Manager,$BASEDN" -w secret \ + >> $TESTOUT 2>&1 << EOF +dn: cn=Cartoonia,ou=Groups,$BASEDN +changetype: modify +add: member +member: cn=Cartoonia,ou=Groups,$BASEDN +EOF + +echo "Re-search the entire database..." +echo "# Re-search the entire database..." >> $SEARCHOUT +$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ + '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1 +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Running ldapdelete to remove a member..." +$LDAPMODIFY -h $LOCALHOST -p $PORT1 \ + -D "cn=Manager,$BASEDN" -w secret \ + >> $TESTOUT 2>&1 << EOF +dn: cn=Baby Herman,ou=People,$BASEDN +changetype: delete +EOF + +echo "Re-search the entire database..." +echo "# Re-search the entire database..." >> $SEARCHOUT +$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ + '(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1 +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +test $KILLSERVERS != no && kill -HUP $KILLPIDS + +LDIF=$MEMBEROFOUT + +echo "Filtering ldapsearch results..." +. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT +echo "Filtering original ldif used to create database..." +. $LDIFFILTER < $LDIF > $LDIFFLT +echo "Comparing filter output..." +$CMP $SEARCHFLT $LDIFFLT > $CMPOUT + +if test $? != 0 ; then + echo "Comparison failed" + exit 1 +fi + +echo ">>>>> Test succeeded" + +test $KILLSERVERS != no && wait + +exit 0 -- 2.39.5