Skip to content

Commit 7c164a4

Browse files
committed
Added dockerfile for tests.
It is now possible to run testsuite in docker, using supplied file. See instructions in t/README. Tests are adjusted to run on alpine linux which includes modular builds of openldap server software.
1 parent 6fad4f3 commit 7c164a4

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

Dockerfile.test

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM python:2-alpine
2+
3+
WORKDIR /usr/src/app/
4+
COPY nginx-ldap-auth-daemon.py /usr/src/app/
5+
6+
WORKDIR /tests
7+
COPY t/ldap-auth.t /tests
8+
COPY t/runtests.sh /tests
9+
10+
# Install required software
11+
RUN \
12+
apk --no-cache add openldap-dev && \
13+
apk --no-cache add openldap && \
14+
apk --no-cache add openldap-back-hdb && \
15+
apk --no-cache add openldap-clients && \
16+
apk --no-cache add openssl && \
17+
apk --no-cache add nginx && \
18+
apk --no-cache add nginx-mod-http-geoip && \
19+
apk --no-cache add nginx-mod-stream-geoip && \
20+
apk --no-cache add nginx-mod-http-image-filter && \
21+
apk --no-cache add nginx-mod-stream && \
22+
apk --no-cache add nginx-mod-mail && \
23+
apk --no-cache add nginx-mod-http-perl && \
24+
apk --no-cache add nginx-mod-http-xslt-filter && \
25+
apk --no-cache add mercurial && \
26+
apk --no-cache add perl && \
27+
apk --no-cache add --virtual build-dependencies build-base && \
28+
pip install python-ldap && \
29+
pip install coverage && \
30+
apk del build-dependencies
31+
32+
33+
# Install tests
34+
RUN \
35+
cd /tests && \
36+
hg clone https://hg.nginx.org/nginx-tests && \
37+
mv ldap-auth.t nginx-tests
38+
39+
WORKDIR /usr/src/app/
40+
41+
ENV TEST_LDAP_DAEMON=/usr/sbin/slapd
42+
ENV TEST_LDAP_AUTH_DAEMON=/usr/src/app/nginx-ldap-auth-daemon.py
43+
ENV TEST_NGINX_BINARY=/usr/sbin/nginx
44+
ENV TEST_NGINX_MODULES=/usr/lib/nginx/modules
45+
ENV LDAPTLS_REQCERT=never
46+
47+
WORKDIR /tests/nginx-tests
48+
49+
CMD ["/tests/runtests.sh"]

t/README

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
To run tests use supplied Dockerfile.test:
2+
3+
docker build -f Dockerfile.test -t my-tag .
4+
docker run my-tag
5+
6+
To run without Docker:
7+
18
Test suite is available at http://hg.nginx.org/nginx-tests.
29
Check the http://hg.nginx.org/nginx-tests/file/tip/README file
310
for instructions on how to use it.

t/ldap-auth.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ access to *
264264
by users read
265265
by anonymous read
266266
267+
moduleload back_hdb
267268
database hdb
268269
suffix "dc=test,dc=local"
269270
rootdn "cn=root,dc=test,dc=local"
@@ -298,6 +299,7 @@ access to *
298299
by users read
299300
by anonymous read
300301
302+
moduleload back_hdb
301303
database hdb
302304
suffix "ou=Users, dc=test,dc=local"
303305
rootdn "cn=root, ou=Users, dc=test,dc=local"

t/runtests.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# shell script to start testsuite and run coverage
4+
# to be executed as Dockerfile CMD
5+
6+
export TEST_NGINX_LEAVE=1
7+
rm -rf /tmp/nginx-test-*
8+
9+
perl ldap-auth.t
10+
11+
testdir=$(find /tmp -name 'nginx-test-*' -print -quit)
12+
cd $testdir
13+
coverage2 html && printf "Coverage report: docker cp <cid>:$testdir/htmlcov <hostdir>\n"

0 commit comments

Comments
 (0)