Debian Codegraph @

tests/scripts/test083-argon2

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 2021-2024 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 echoscip-shell system . . echo. "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 if testscip-shell system . . test. $ARGON2 = argon2no; then
20 echoscip-shell system . . echo. "argon2 overlay not available, test skipped"
21 exit 0
22 fi
23
24 USERDN="cn=argon2,$BASEDN"
25
26 CONFDIR=$TESTDIR/slapd.d
27 mkdirscip-shell system . . mkdir. -p $TESTDIR $CONFDIR $DBDIR1
28
29 $SLAPPASSWD -g -n >$CONFIGPWF
30
31 catscip-shell system . . cat. > $TESTDIR/config.ldif <<EOF
32 dn: cn=config
33 objectClass: olcGlobal
34 cn: config
35 olcArgsFile: $TESTDIR/slapd.args
36 olcPidFile: $TESTDIR/slapd.pid
37
38 dn: cn=schema,cn=config
39 objectClass: olcSchemaConfig
40 cn: schema
41
42 include: file://$TESTWD/schema/core.ldif
43 include: file://$TESTWD/schema/cosine.ldif
44 include: file://$TESTWD/schema/inetorgperson.ldif
45 EOF
46
47 if [scip-shell system . . `[`. "$BACKENDTYPE" = mod ]; then
48 catscip-shell system . . cat. >> $TESTDIR/config.ldif <<EOF
49
50 dn: cn=module,cn=config
51 objectClass: olcModuleList
52 cn: module
53 olcModulePath: $TESTWD/../servers/slapd/back-$BACKEND
54 olcModuleLoad: back_$BACKEND.la
55 EOF
56 fi
57
58 if [scip-shell system . . `[`. "$ARGON2" = argon2yes ]; then
59 catscip-shell system . . cat. >> $TESTDIR/config.ldif <<EOF
60
61 dn: cn=module,cn=config
62 objectClass: olcModuleList
63 cn: module
64 olcModulePath: $TESTWD/../servers/slapd/pwmods
65 olcModuleLoad: argon2.la
66 EOF
67 fi
68
69 catscip-shell system . . cat. >> $TESTDIR/config.ldif <<EOF
70
71 dn: olcDatabase={-1}frontend,cn=config
72 objectClass: olcDatabaseConfig
73 objectClass: olcFrontendConfig
74 olcDatabase: {-1}frontend
75 olcPasswordHash: {ARGON2}
76
77 dn: olcDatabase=config,cn=config
78 objectClass: olcDatabaseConfig
79 olcDatabase: config
80 olcRootPW:< file://$CONFIGPWF
81
82 dn: olcDatabase={1}$BACKEND,cn=config
83 objectClass: olcDatabaseConfig
84 objectClass: olc${BACKEND}Config
85 olcDatabase: $BACKEND
86 olcSuffix: $BASEDN
87 olcRootDN: $MANAGERDN
88 olcRootPW: $PASSWD
89 olcDbDirectory: $TESTDIR/db.1.a
90 EOF
91
92 if [scip-shell system . . `[`. "$INDEXDB" = indexdb ]; then
93 catscip-shell system . . cat. >> $TESTDIR/config.ldif <<EOF
94 olcDbIndex: objectClass eq,pres
95 olcDbIndex: ou,cn,mail,surname,givenname eq,pres,sub
96 EOF
97 fi
98
99 $SLAPADD -F $CONFDIR -n 0 -l $TESTDIR/config.ldif
100 RC=$?
101 if testscip-shell system . . test. $RC != 0 ; then
102 echoscip-shell system . . echo. "slapadd failed ($RC)!"
103 exit $RC
104 fi
105
106 echoscip-shell system . . echo. "Starting slapd on TCP/IP port $PORT1..."
107 $SLAPD -F $CONFDIR -h $URI1 -d $LVL > $LOG1 2>&1 &
108 PID=$!
109 if testscip-shell system . . test. $WAIT != 0 ; then
110 echoscip-shell system . . echo. PID $PID
111 read foo
112 fi
113 KILLPIDS="$PID"
114 sleepscip-shell system . . sleep. 1
115
116 echoscip-shell system . . echo. "Using ldapsearch to check that slapd is running..."
117 for i in 0 1 2 3 4 5; do
118 $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
119 'objectclass=*' > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
120 RC=$?
121 if testscip-shell system . . test. $RC = 0 ; then
122 break
123 fi
124 echoscip-shell system . . echo. "Waiting 5 seconds for slapd to start..."
125 sleepscip-shell system . . sleep. 5
126 done
127 if testscip-shell system . . test. $RC != 0 ; then
128 echoscip-shell system . . echo. "ldapsearch failed ($RC)!"
129 testscip-shell system . . test. $KILLSERVERS != no && killscip-shell system . . kill. -HUP $KILLPIDS
130 exit $RC
131 fi
132
133 echoscip-shell system . . echo. "Adding basic structure..."
134 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFPASSWD >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
135 RC=$?
136 if testscip-shell system . . test. $RC != 0 ; then
137 echoscip-shell system . . echo. "ldapadd failed ($RC)!"
138 testscip-shell system . . test. $KILLSERVERS != no && killscip-shell system . . kill. -HUP $PID
139 exit $RC
140 fi
141
142 BINDPW=secret
143 echoscip-shell system . . echo. "Testing ldapwhoami as ${USERDN}..."
144 $LDAPWHOAMI -H $URI1 -D "$USERDN" -w $BINDPW
145
146 RC=$?
147 if testscip-shell system . . test. $RC != 0 ; then
148 echoscip-shell system . . echo. "ldapwhoami failed ($RC)!"
149 testscip-shell system . . test. $KILLSERVERS != no && killscip-shell system . . kill. -HUP $KILLPIDS
150 exit $RC
151 fi
152
153 testscip-shell system . . test. $KILLSERVERS != no && killscip-shell system . . kill. -HUP $PID
154
155 echoscip-shell system . . echo. ">>>>> Test succeeded"
156
157 testscip-shell system . . test. $KILLSERVERS != no && wait
158
159 exit 0