1#! /bin/sh 2## $OpenLDAP$ 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 2016-2021 The OpenLDAP Foundation. 6## All rights reserved. 7## 8## Redistribution and use in source and binary forms, with or without 9## modification, are permitted only as authorized by the OpenLDAP 10## Public License. 11## 12## A copy of this license is available in the file LICENSE in the 13## top-level directory of the distribution or, alternatively, at 14## <http://www.OpenLDAP.org/license.html>. 15## 16## ACKNOWLEDGEMENTS: 17## This module was written in 2016 by Ondřej Kuzník for Symas Corp. 18 19echo "running defines.sh" 20. $SRCDIR/scripts/defines.sh 21 22. ${SCRIPTDIR}/common.sh 23 24echo "Setting up another database and variant using an alternate there..." 25mkdir $DBDIR2 26$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 27 <<EOMOD >> $TESTOUT 2>&1 28dn: olcDatabase=ldif,cn=config 29changetype: add 30objectclass: olcLdifConfig 31olcSuffix: dc=demonstration,dc=com 32olcDbDirectory: $DBDIR2 33olcRootDn: $MANAGERDN 34 35dn: olcVariantVariantAttribute={1}seealso,name={0}variant,olcOverlay={0}variant,olcDatabase={1}$BACKEND,cn=config 36changetype: modify 37replace: olcVariantAlternativeEntry 38olcVariantAlternativeEntry: ou=Societies,dc=demonstration,dc=com 39EOMOD 40RC=$? 41if test $RC != 0 ; then 42 echo "ldapmodify failed ($RC)!" 43 test $KILLSERVERS != no && kill -HUP $KILLPIDS 44 exit $RC 45fi 46 47echo "Adding alternate entry..." 48$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 49 -f data/test012-data.ldif >> $TESTOUT 2>&1 50RC=$? 51if test $RC != 0 ; then 52 echo "ldapmodify failed ($RC)!" 53 test $KILLSERVERS != no && kill -HUP $KILLPIDS 54 exit $RC 55fi 56 57echo "Checking the variant gets resolved correctly..." 58echo "# Testing a search against a variant using another DB..." >> $SEARCHOUT 59#$LDAPSEARCH -b "$BASEDN" -H $URI1 \ 60# "seealso=dc=example,dc=com" \ 61$LDAPSEARCH -b "ou=People,$BASEDN" -s base -H $URI1 \ 62 >> $SEARCHOUT 2>&1 63RC=$? 64if test $RC != 0 ; then 65 echo "ldapsearch failed ($RC)!" 66 test $KILLSERVERS != no && kill -HUP $KILLPIDS 67 exit $RC 68fi 69 70test $KILLSERVERS != no && kill -HUP $KILLPIDS 71 72LDIF=data/test012-out.ldif 73 74echo "Filtering ldapsearch results..." 75$LDIFFILTER < $SEARCHOUT > $SEARCHFLT 76echo "Filtering expected entries..." 77$LDIFFILTER < $LDIF > $LDIFFLT 78echo "Comparing filter output..." 79$CMP $SEARCHFLT $LDIFFLT > $CMPOUT 80 81if test $? != 0 ; then 82 echo "Comparison failed" 83 exit 1 84fi 85 86echo ">>>>> Test succeeded" 87 88test $KILLSERVERS != no && wait 89 90exit 0 91