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