xref: /netbsd-src/external/bsd/openldap/dist/contrib/slapd-modules/variant/tests/scripts/test003-search (revision e670fd5c413e99c2f6a37901bb21c537fcd322d2)
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 "Testing searches against regular entries..."
25echo "# Testing searches against regular entries..." >> $SEARCHOUT
26$LDAPSEARCH -b "$BASEDN" -H $URI1 \
27	"(|(name=Elliot)(description=*hiker*))" \
28	>> $SEARCHOUT 2>&1
29RC=$?
30if test $RC != 0 ; then
31	echo "ldapsearch failed ($RC)!"
32	test $KILLSERVERS != no && kill -HUP $KILLPIDS
33	exit $RC
34fi
35
36echo "Testing searches listing variants..."
37echo >> $SEARCHOUT
38echo "# Testing searches listing variants..." >> $SEARCHOUT
39$LDAPSEARCH -b "$BASEDN" -s one -H $URI1 \
40	>> $SEARCHOUT 2>&1
41RC=$?
42if test $RC != 0 ; then
43	echo "ldapsearch failed ($RC)!"
44	test $KILLSERVERS != no && kill -HUP $KILLPIDS
45	exit $RC
46fi
47
48echo >> $SEARCHOUT
49$LDAPSEARCH -b "$BASEDN" -s base -H $URI1 \
50	>> $SEARCHOUT 2>&1
51RC=$?
52if test $RC != 0 ; then
53	echo "ldapsearch failed ($RC)!"
54	test $KILLSERVERS != no && kill -HUP $KILLPIDS
55	exit $RC
56fi
57
58echo >> $SEARCHOUT
59$LDAPSEARCH -s base -H $URI1 \
60	-b "cn=Bjorn Jensen,ou=Information Technology Division,ou=People,$BASEDN" \
61	'(ou=Information Technology Division)' \
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
70echo >> $SEARCHOUT
71$LDAPSEARCH -b "cn=ITD Staff,ou=Groups,$BASEDN" -s base -H $URI1 \
72	>> $SEARCHOUT 2>&1
73RC=$?
74if test $RC != 0 ; then
75	echo "ldapsearch failed ($RC)!"
76	test $KILLSERVERS != no && kill -HUP $KILLPIDS
77	exit $RC
78fi
79
80echo "Testing searches filtering on variants..."
81echo >> $SEARCHOUT
82echo "# Testing searches filtering on variants..." >> $SEARCHOUT
83$LDAPSEARCH -b "$BASEDN" -H $URI1 \
84	"(st=Alumni Association)" st \
85	>> $SEARCHOUT 2>&1
86RC=$?
87if test $RC != 0 ; then
88	echo "ldapsearch failed ($RC)!"
89	test $KILLSERVERS != no && kill -HUP $KILLPIDS
90	exit $RC
91fi
92
93test $KILLSERVERS != no && kill -HUP $KILLPIDS
94
95LDIF=data/test003-out.ldif
96
97echo "Filtering ldapsearch results..."
98$LDIFFILTER -s e < $SEARCHOUT > $SEARCHFLT
99echo "Filtering expected entries..."
100$LDIFFILTER -s e < $LDIF > $LDIFFLT
101echo "Comparing filter output..."
102$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
103
104if test $? != 0 ; then
105	echo "Comparison failed"
106	exit 1
107fi
108
109echo ">>>>> Test succeeded"
110
111test $KILLSERVERS != no && wait
112
113exit 0
114