xref: /netbsd-src/external/bsd/openldap/dist/contrib/slapd-modules/variant/tests/scripts/test010-limits (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	-z 1 "(|(name=Elliot)(description=*hiker*))" \
28	>> $SEARCHOUT 2>&1
29RC=$?
30case $RC in
310)
32	echo "ldapsearch should have failed ($RC)!"
33	test $KILLSERVERS != no && kill -HUP $KILLPIDS
34	exit 1
35	;;
364)
37	echo "sizelimit reached ($RC)"
38	;;
39*)
40	echo "ldapsearch failed ($RC)!"
41	test $KILLSERVERS != no && kill -HUP $KILLPIDS
42	exit $RC
43	;;
44esac
45
46echo "Testing searches listing variants where limits just fit..."
47echo "# Testing searches listing variants where limits just fit..." >> $SEARCHOUT
48$LDAPSEARCH -b "$BASEDN" -s one -H $URI1 \
49	-z 3 >> $SEARCHOUT 2>&1
50RC=$?
51if test $RC != 0 ; then
52	echo "ldapsearch failed ($RC)!"
53	test $KILLSERVERS != no && kill -HUP $KILLPIDS
54	exit $RC
55fi
56
57echo "Testing searches filtering on variants going over the specified limit..."
58echo "# Testing searches filtering on variants going over the specified limit..." >> $SEARCHOUT
59$LDAPSEARCH -b "$BASEDN" -H $URI1 \
60	-z 1 "(name=Alumni Association)" \
61	>> $SEARCHOUT 2>&1
62RC=$?
63case $RC in
640)
65	echo "ldapsearch should have failed ($RC)!"
66	test $KILLSERVERS != no && kill -HUP $KILLPIDS
67	exit 1
68	;;
694)
70	echo "sizelimit reached ($RC)"
71	;;
72*)
73	echo "ldapsearch failed ($RC)!"
74	test $KILLSERVERS != no && kill -HUP $KILLPIDS
75	exit $RC
76	;;
77esac
78
79test $KILLSERVERS != no && kill -HUP $KILLPIDS
80
81LDIF=data/test010-out.ldif
82
83echo "Filtering ldapsearch results..."
84$LDIFFILTER -s e < $SEARCHOUT > $SEARCHFLT
85echo "Filtering expected entries..."
86$LDIFFILTER -s e < $LDIF > $LDIFFLT
87echo "Comparing filter output..."
88$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
89
90if test $? != 0 ; then
91	echo "Comparison failed"
92	exit 1
93fi
94
95echo ">>>>> Test succeeded"
96
97test $KILLSERVERS != no && wait
98
99exit 0
100