xref: /openbsd/regress/usr.sbin/ldapd/Makefile (revision fd0cc40e)
1# $OpenBSD: Makefile,v 1.1 2016/09/01 14:59:52 landry Exp $
2
3LOG=${.CURDIR}/log
4OUT=${.CURDIR}/out
5WRK!=mktemp -d
6DIT=dc=example,dc=com
7DIT2=dc=bar,dc=quux
8NLV=0.65
9
10# Needs p5-ldap and openldap (client)
11
12PERL_REQUIRE !=	perl -Mstrict -Mwarnings -e ' \
13    eval { require Net::LDAP } or print $@; \
14'
15.if ! empty (PERL_REQUIRE)
16regress:
17	@echo "${PERL_REQUIRE}"
18	@echo install p5-ldap
19	@exit 1
20.endif
21
22.BEGIN:
23	@[ -z "${SUDO}" ] || ${SUDO} true
24	@${SUDO} install -m 600 -o root ${.CURDIR}/ldapd.conf ${WRK}
25	@${SUDO} ldapd -n -r ${WRK} -f ${WRK}/ldapd.conf
26	@${SUDO} ldapd -dvv -r ${WRK} -f ${WRK}/ldapd.conf > ${LOG} 2>&1 &
27	@sleep 1
28	@grep -a startup ${LOG} |sed -e 's/.*\[// ; s/\].*//' > ldapd.pid
29.END:
30	@${SUDO} kill $$(cat ldapd.pid)
31	@-${SUDO} rm -Rf ${WRK}
32
33clean:
34	@-${SUDO} rm -Rf ${WRK}
35
36all: connect import perl cpan
37
38connect:
39	-ldapsearch -x -H ldapi://%2ftmp%2fldapi | diff - ${OUT}/empty.log
40	-ldapsearch -x -p 6639 -h localhost 2>&1 | diff - ${OUT}/empty.log
41	-ldapsearch -x -p 6636 -h localhost 2>&1 | diff - ${OUT}/empty.log
42
43import:
44	ldapadd -f ${.CURDIR}/dit-example.ldif -Dcn=admin,${DIT} -x -w secret -h localhost -p 6639 | diff - ${OUT}/adding.log
45	ldapsearch -x -b ${DIT} -h localhost -p 6639 | diff - ${OUT}/example.log
46	ldapsearch -x -D cn=admin,${DIT} -w secret -b ${DIT} -h localhost -p 6639 | diff - ${OUT}/example.log
47
48purge: import
49	ldapdelete -Dcn=admin,${DIT} -x -w secret -h localhost -p 6639 -r ${DIT}
50	-ldapsearch -x -p 6639 -h localhost 2>&1 | diff - ${OUT}/empty.log
51
52perl:
53	@-perl run-tests.pl
54
55# run tests from Net::LDAP
56# requires all of databases/p5-ldap RUN_DEPENDS
57# tests above 41 fail because ldapd doesnt handle uppercase namespaces
58cpan:
59	tar -C ${WRK} -xzf /usr/ports/distfiles/perl-ldap-${NLV}.tar.gz
60	@${SUDO} install -m 600 -o root ${.CURDIR}/nldapd.conf ${WRK}/perl-ldap-${NLV}
61	cp common.pl ${WRK}/perl-ldap-${NLV}/t
62	cd ${WRK}/perl-ldap-${NLV} && perl Makefile.PL --skipdeps
63	sed -i -e 's/OpenLDAPperson/inetOrgPerson/' ${WRK}/perl-ldap-${NLV}/data/*.ldif
64	@-${SUDO} ${MAKE} -C ${WRK}/perl-ldap-${NLV} test
65
66.include <bsd.regress.mk>
67