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