1 1.1 christos #!/bin/sh 2 1.1 christos # $OpenLDAP$ 3 1.1 christos ## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4 1.1 christos ## 5 1.1 christos ## Copyright 2016-2021 Ondej Kuznk, Symas Corp. 6 1.1.1.2 christos ## Copyright 2021-2024 The OpenLDAP Foundation. 7 1.1 christos ## All rights reserved. 8 1.1 christos ## 9 1.1 christos ## Redistribution and use in source and binary forms, with or without 10 1.1 christos ## modification, are permitted only as authorized by the OpenLDAP 11 1.1 christos ## Public License. 12 1.1 christos ## 13 1.1 christos ## A copy of this license is available in the file LICENSE in the 14 1.1 christos ## top-level directory of the distribution or, alternatively, at 15 1.1 christos ## <http://www.OpenLDAP.org/license.html>. 16 1.1 christos 17 1.1 christos echo "running defines.sh" 18 1.1 christos . $SRCDIR/scripts/defines.sh 19 1.1 christos 20 1.1 christos if test $OTP = otpno; then 21 1.1 christos echo "OTP overlay not available, test skipped" 22 1.1 christos exit 0 23 1.1 christos fi 24 1.1 christos 25 1.1.1.2 christos export URI1 MANAGERDN PASSWD BABSDN BJORNSDN 26 1.1.1.2 christos 27 1.1.1.2 christos OTP_DATA=$DATADIR/otp/totp.ldif 28 1.1.1.2 christos 29 1.1.1.2 christos mkdir -p $TESTDIR $DBDIR1 30 1.1.1.2 christos 31 1.1 christos for python in python3 python2 python2.7 python27 python ""; do 32 1.1 christos if test x"$python" = x; then 33 1.1 christos echo "Useable Python environment not found, skipping test" 34 1.1 christos exit 0 35 1.1 christos fi 36 1.1 christos 37 1.1 christos "$python" "$0".py --check >>$TESTOUT 2>&1 38 1.1 christos RC=$? 39 1.1 christos case $RC in 40 1.1 christos 0) 41 1.1 christos break;; 42 1.1 christos 1) 43 1.1 christos echo "$python is missing some required modules, skipping" 44 1.1 christos python="" 45 1.1 christos continue;; 46 1.1 christos 127) 47 1.1 christos ;; 48 1.1 christos esac 49 1.1 christos done 50 1.1 christos 51 1.1 christos echo "Running slapadd to build slapd database..." 52 1.1 christos . $CONFFILTER $BACKEND < $CONF > $ADDCONF 53 1.1 christos $SLAPADD -f $ADDCONF -l $LDIFORDERED 54 1.1 christos RC=$? 55 1.1 christos if test $RC != 0 ; then 56 1.1 christos echo "slapadd failed ($RC)!" 57 1.1 christos exit $RC 58 1.1 christos fi 59 1.1 christos 60 1.1 christos mkdir $TESTDIR/confdir 61 1.1 christos . $CONFFILTER $BACKEND < $CONF > $CONF1 62 1.1 christos 63 1.1 christos $SLAPPASSWD -g -n >$CONFIGPWF 64 1.1 christos echo "database config" >>$CONF1 65 1.1 christos echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >>$CONF1 66 1.1 christos 67 1.1 christos echo "Starting slapd on TCP/IP port $PORT1..." 68 1.1 christos $SLAPD -f $CONF1 -F $TESTDIR/confdir -h $URI1 -d $LVL > $LOG1 2>&1 & 69 1.1 christos PID=$! 70 1.1 christos if test $WAIT != 0 ; then 71 1.1 christos echo PID $PID 72 1.1 christos read foo 73 1.1 christos fi 74 1.1 christos KILLPIDS="$PID" 75 1.1 christos 76 1.1 christos sleep $SLEEP0 77 1.1 christos 78 1.1 christos for i in 0 1 2 3 4 5; do 79 1.1 christos $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \ 80 1.1 christos 'objectclass=*' > /dev/null 2>&1 81 1.1 christos RC=$? 82 1.1 christos if test $RC = 0 ; then 83 1.1 christos break 84 1.1 christos fi 85 1.1 christos echo "Waiting ${SLEEP1} seconds for slapd to start..." 86 1.1 christos sleep ${SLEEP1} 87 1.1 christos done 88 1.1 christos 89 1.1 christos if [ "$OTP" = otpmod ]; then 90 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF \ 91 1.1 christos >> $TESTOUT 2>&1 <<EOMOD 92 1.1 christos dn: cn=module,cn=config 93 1.1 christos objectClass: olcModuleList 94 1.1 christos cn: module 95 1.1 christos olcModulePath: $TESTWD/../servers/slapd/overlays 96 1.1 christos olcModuleLoad: otp.la 97 1.1 christos EOMOD 98 1.1 christos RC=$? 99 1.1 christos if test $RC != 0 ; then 100 1.1 christos echo "ldapmodify failed ($RC)!" 101 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 102 1.1 christos exit $RC 103 1.1 christos fi 104 1.1 christos fi 105 1.1 christos 106 1.1 christos echo "Loading test otp configuration..." 107 1.1 christos $LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 108 1.1 christos >> $TESTOUT 2>&1 <<EOMOD 109 1.1 christos dn: olcOverlay={0}otp,olcDatabase={1}$BACKEND,cn=config 110 1.1 christos changetype: add 111 1.1 christos objectClass: olcOverlayConfig 112 1.1 christos EOMOD 113 1.1 christos RC=$? 114 1.1 christos if test $RC != 0 ; then 115 1.1 christos echo "ldapmodify failed ($RC)!" 116 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 117 1.1 christos exit $RC 118 1.1 christos fi 119 1.1 christos 120 1.1 christos echo "Provisioning tokens and configuration..." 121 1.1 christos $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \ 122 1.1 christos >> $TESTOUT 2>&1 < $OTP_DATA 123 1.1 christos RC=$? 124 1.1 christos if test $RC != 0 ; then 125 1.1 christos echo "ldapmodify failed ($RC)!" 126 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 127 1.1 christos exit $RC 128 1.1 christos fi 129 1.1 christos 130 1.1 christos "$python" "$0".py 131 1.1 christos RC=$? 132 1.1 christos 133 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 134 1.1 christos 135 1.1 christos if test $RC != 0 ; then 136 1.1 christos echo "Test failed ($RC)!" 137 1.1 christos else 138 1.1 christos echo ">>>>> Test succeeded" 139 1.1 christos fi 140 1.1 christos 141 1.1 christos test $KILLSERVERS != no && wait 142 1.1 christos 143 1.1 christos exit $RC 144