source: mod_gnutls/test/Makefile.am @ 4b9e34a

asyncio
Last change on this file since 4b9e34a was 4b9e34a, checked in by Fiona Klute <fiona.klute@…>, 13 months ago

Unify tests for CGI variables with and without client certificate

Both can work with the same server configuration, so it makes sense to
start only one server instance.

  • Property mode set to 100644
File size: 13.5 KB
Line 
1SUBDIRS = tests
2
3VALGRIND_SUPPRESS = suppressions.valgrind
4EXTRA_DIST = $(VALGRIND_SUPPRESS)
5
6if ENABLE_VALGRIND
7valgrind = --valgrind \
8        $(foreach supp,$(VALGRIND_SUPPRESS),--valgrind-suppressions "$(srcdir)/$(supp)")
9else
10valgrind =
11endif
12
13# Generate the test scripts
14test-%.bash: test-template.bash.in | tests/%/
15        testname="$(*)"; \
16        sed -e s/_NUM_/$${testname%%_*}/ -e 's,_VALGRIND_,$(valgrind),' < $< > $@
17        chmod a+x $@
18
19test_scripts = test-00_basic.bash \
20        test-01_priorities_config.bash \
21        test-02_cache_in_vhost.bash \
22        test-03_cachetimeout_in_vhost.bash \
23        test-04_basic_nosni.bash \
24        test-06_verify_sni_a.bash \
25        test-07_verify_sni_b.bash \
26        test-08_verify_no_sni_fallback_to_first_vhost.bash \
27        test-09_verify_no_sni_fails_with_wrong_order.bash \
28        test-10_client_verification.bash \
29        test-12_cgi_variables.bash \
30        test-14_resume_session.bash
31if USE_MSVA
32test_scripts += test-15_basic_msva.bash
33endif
34test_scripts += test-16_view-status.bash \
35        test-17_cgi_vars_large_cert.bash \
36        test-19_TLS_reverse_proxy.bash \
37        test-20_TLS_reverse_proxy_client_auth.bash \
38        test-21_TLS_reverse_proxy_wrong_cert.bash \
39        test-22_TLS_reverse_proxy_crl_revoke.bash \
40        test-23_TLS_reverse_proxy_mismatched_priorities.bash \
41        test-24_pkcs11_cert.bash \
42        test-26_redirect_HTTP_to_HTTPS.bash \
43        test-27_OCSP_server.bash \
44        test-28_HTTP2_support.bash \
45        test-29_force_handshake_vhost.bash \
46        test-30_ip_based_vhosts.bash \
47        test-31_vhost_SNI_serveralias_match.bash \
48        test-32_vhost_SNI_serveralias_mismatch.bash \
49        test-33_vhost_SNI_serveralias_missinghost.bash \
50        test-34_TLS_reverse_proxy_h2.bash \
51        test-35_client_reauth.bash \
52        test-36_OCSP_server_nonce.bash \
53        test-37_TLS_reverse_proxy_resume_session.bash
54
55MOSTLYCLEANFILES = $(test_scripts)
56dist_check_SCRIPTS = netns_py.bash test-template.bash.in
57
58TEST_EXTENSIONS = .bash .py
59PY_LOG_COMPILER = $(PYTHON)
60TESTS = doctest-mgstest.py $(test_scripts)
61
62check_PROGRAMS = pgpcrc
63pgpcrc_SOURCES = pgpcrc.c
64
65# build OCSP database tool
66if ENABLE_OCSP_TEST
67check_PROGRAMS += gen_ocsp_index
68gen_ocsp_index_SOURCES = gen_ocsp_index.c cert_helper.c
69gen_ocsp_index_CFLAGS = $(LIBGNUTLS_CFLAGS)
70gen_ocsp_index_LDFLAGS = $(LIBGNUTLS_LIBS)
71noinst_HEADERS = cert_helper.h
72endif
73
74# Python tools for tests
75noinst_PYTHON = https-test-client.py mgstest/http.py mgstest/__init__.py \
76        mgstest/hooks.py mgstest/ocsp.py mgstest/services.py \
77        mgstest/softhsm.py mgstest/tests.py mgstest/valgrind.py runtest.py \
78        softhsm-init.py doctest-mgstest.py required-modules.py data/ocsp.py \
79        check_test_ips.py
80
81# Identities in the miniature CA, server, and client environment for
82# the test suite
83shared_identities = authority authority/client
84pgp_identities = $(shared_identities)
85x509_only_identities = authority/server authority/imposter \
86        authority/subca authority/subca/server \
87        rogueca rogueca/rogueclient
88if ENABLE_OCSP_TEST
89x509_only_identities += authority/ocsp-responder authority/subca/ocsp-responder
90endif
91x509_identities = $(shared_identities) $(x509_only_identities)
92identities = $(shared_identities) $(x509_only_identities)
93# Append strings after ":=" to each identity to generate a list of
94# necessary files
95pgp_tokens = $(pgp_identities:=/cert.pgp) \
96        $(pgp_identities:=/secret.pgp)
97x509_keys = $(x509_identities:=/secret.key)
98x509_certs = $(x509_identities:=/x509.pem)
99x509_tokens = $(x509_certs) $(x509_keys)
100tokens = $(x509_tokens)
101if USE_MSVA
102tokens += $(pgp_tokens)
103endif
104
105if !DISABLE_FLOCK
106# flock command for write access to the authority keyring
107GPG_FLOCK = @FLOCK@ authority/lock
108endif
109
110include $(srcdir)/test_ca.mk
111
112# Test cases trying to create keys and certificates in parallel causes
113# race conditions. Ensure that all keys and certificates are generated
114# before tests get to run.
115#
116# NOTE: Once the support files have been generated, test cases can be
117# run with multiple jobs, but real parallelization would require
118# dynamic port assignments. At the moment, lock files ensure that only
119# one Apache instance (possibly plus a proxy back end instance) is
120# running at any time, so test cases actually have to wait for each
121# other - just not in any particular order.
122check_DATA = $(tokens) authority/server/crl.pem
123
124MOSTLYCLEANFILES += cache/* logs/* outputs/* authority/server/crl.pem
125
126cert_templates = authority/template.in authority/client/template.in \
127        authority/imposter/template.in authority/ocsp-responder/template \
128        authority/server/template.in \
129        authority/subca/template.in authority/subca/server/template.in \
130        authority/subca/ocsp-responder/template \
131        rogueca/template rogueca/rogueclient/template.in
132generated_templates = authority/template authority/client/template \
133        authority/imposter/template rogueca/rogueclient/template \
134        authority/server/template
135
136# Delete X.509 private keys on full clean. Note that unless you need
137# to generate fresh keys, the "mostlyclean" target should be
138# sufficient (see below).
139CLEANFILES = $(x509_keys)
140
141# Delete X.509 certificates and generated templates on "mostlyclean"
142# target. Certificates can be rebuilt without generating new key
143# pairs, and regenerating them makes it possible to change identities
144# (e.g. host names) without wasting time on new keys (which would
145# happen after "clean").
146MOSTLYCLEANFILES += $(x509_certs) $(generated_templates) $(identities:=/uid)
147
148
149# Delete PGP keyrings on "mostlyclean" target. They are created from
150# the X.509 private keys and certificates with an expiration time of
151# one day, so regenerating them is both fast and frequently
152# necessary.
153pgp_patterns = /*.pgp /*.pgp.raw /*.gpg /*.gpg~ /gpg.conf \
154        /*.kbx /*.kbx~ /S.gpg-agent /private-keys-v1.d/*
155MOSTLYCLEANFILES += $(foreach pat,$(pgp_patterns),$(pgp_identities:=$(pat))) \
156        authority/lock authority/tofu.db
157# GnuPG random pool, no need to regenerate on every build
158CLEANFILES += authority/random_seed
159
160# GnuPG 2 starts gpg-agent processes per GNUPGHOME (one for every PGP
161# identity) while creating the PGP certificates. This target is called
162# by both "check-local" and "mostlyclean-local": The former because
163# agent processes are started while preparing for "check" and are no
164# longer needed afterwards, the latter to make sure they are gone
165# along with their certificates.
166stop-gnupg-agent:
167        for id in $(pgp_identities) $(msva_home); do \
168                GNUPGHOME=$$id/ gpgconf --kill gpg-agent || true; \
169        done
170
171check-local: stop-gnupg-agent
172
173# Delete lock files for test servers on "mostlyclean" target.
174MOSTLYCLEANFILES += *.lock
175
176# Build certificate chain files. Note that intermediate tokens must be
177# listed explicitly, or the dependency chain will be broken because
178# the higher level pattern matches, too.
179chain_tokens = authority/server/x509-chain.pem \
180        authority/subca/x509-chain.pem \
181        authority/subca/server/x509-chain.pem
182check_DATA += $(chain_tokens)
183MOSTLYCLEANFILES += $(chain_tokens) authority/x509-chain.pem
184
185# rule to build MSVA trust database
186if USE_MSVA
187msva_home = msva.gnupghome
188check_DATA += $(msva_home)/trustdb.gpg authority/client/uid
189MOSTLYCLEANFILES += $(foreach pat,$(pgp_patterns),$(msva_home)$(pat))
190$(msva_home)/trustdb.gpg: authority/minimal.pgp authority/client/cert.pgp
191        mkdir -p -m 0700 $(dir $@)
192        GNUPGHOME=$(dir $@) gpg --import < $<
193        printf "%s:6:\n" "$$(GNUPGHOME=authority/ gpg --with-colons --list-secret-keys --fingerprint | grep ^fpr: | cut -f 10 -d :)" | GNUPGHOME=$(dir $@) gpg --import-ownertrust
194        GNUPGHOME=$(dir $@) gpg --import < authority/client/cert.pgp
195        printf "keyserver does-not-exist.example\n" > $(msva_home)/gpg.conf
196endif
197
198if ENABLE_OCSP_TEST
199# rules to build OCSP database
200ocsp_index_data = authority/ocsp_index.txt authority/ocsp_index.txt.attr \
201        authority/subca/ocsp_index.txt authority/subca/ocsp_index.txt.attr
202check_DATA += $(ocsp_index_data)
203MOSTLYCLEANFILES += $(ocsp_index_data)
204
205# The "find" command builds a list of all certificates directly below
206# the CA that aren't for the ocsp-responder.
207%/ocsp_index.txt: $(x509_tokens) gen_ocsp_index
208        ./gen_ocsp_index $$(find $(*) -mindepth 2 -maxdepth 2 ! -path '*/ocsp-responder/*' -name x509.pem) > $@
209
210%/ocsp_index.txt.attr:
211        @mkdir -m 0700 -p $(dir $@)
212        echo "unique_subject = no" > $@
213endif
214
215# SoftHSM token, note that the SoftHSM 2 token is a directory
216SOFTHSM2_TOKEN = authority/server/softhsm2.db
217# included in mostlyclean-local below
218clean-softhsm2-db:
219        -rm -rf $(SOFTHSM2_TOKEN)
220
221if HAVE_SOFTHSM
222check_DATA += $(SOFTHSM2_TOKEN)
223endif HAVE_SOFTHSM
224
225check_DATA += make-test-dirs
226extra_dirs = logs cache outputs
227make-test-dirs:
228        mkdir -p $(extra_dirs)
229
230.PHONY: make-test-dirs clean-softhsm2-db stop-gnupg-agent
231
232
233if ENABLE_COVERAGE
234coverage_raw_dir = outputs/coverage
235coverage_out = coverage
236MOSTLYCLEANFILES += $(coverage_raw_dir)/*
237endif
238
239mostlyclean-local: clean-softhsm2-db stop-gnupg-agent
240        -rmdir $(pgp_identities:=/private-keys-v1.d) || true
241if USE_MSVA
242        -rmdir $(msva_home)/private-keys-v1.d || true
243endif
244
245# Delete test data directories, and wait for test services to
246# exit. The reason for the wait is that Apache instances may take some
247# time to exit and delete their PID files. Occasionally some PID files
248# where still around during "distcheck" runs by the time the target
249# checked if the build directory was really empty after "distclean",
250# breaking the build. Delaying "clean-local" until PID files are gone
251# avoids this issue, and the timeout will expose actually unclean
252# stops.
253clean-local:
254if ENABLE_COVERAGE
255        -rmdir $(coverage_raw_dir) || true
256        -rm -rf $(coverage_out) || true
257endif
258        -rmdir $(extra_dirs) || true
259if USE_MSVA
260        -rmdir $(msva_home) || true
261endif
262        wait=0; \
263        while ls *.pid && test "$$wait" -lt "@TEST_LOCK_WAIT@"; do \
264                wait=$$(($$wait + 1)); \
265                echo "waiting for test services to exit ($$wait seconds)"; \
266                sleep 1; \
267        done
268
269# Apache configuration and data files
270apache_data = base_apache.conf cgi_module.conf data/dump.cgi \
271        data/test.txt data/secret/mirror.cgi data/secret/test.txt \
272        mime.types proxy_mods.conf
273
274# Which modules are compiled into the Apache binary varies between
275# distributions. required-modules.py creates additional LoadModule
276# directives if needed.
277check_DATA += apache-conf/required-modules.conf
278MOSTLYCLEANFILES += apache-conf/required-modules.conf
279apache-conf/required-modules.conf: required-modules.py
280        APACHE2=@APACHE2@ AP_LIBEXECDIR=@AP_LIBEXECDIR@ $(PYTHON) $< >$@
281
282# Documentation for the test system
283test_doc = README.md sample_fail.yaml sample_test.yaml
284
285EXTRA_DIST += $(apache_data) $(cert_templates) $(shared_identities:=/uid.in) \
286        authority/server/crl.template $(test_doc)
287
288# Lockfile for the main Apache process
289test_lockfile = ./test.lock
290# Lockfile for the proxy backend Apache process (if any)
291backend_lockfile = ./backend.lock
292# Lockfile for the OCSP server Apache process (if any)
293ocsp_lockfile = ./ocsp.lock
294
295# port for the main Apache server
296TEST_PORT ?= 9932
297# port for MSVA in test cases that use it
298MSVA_PORT ?= 9933
299# port for TLS proxy backend server
300BACKEND_PORT ?= 9934
301# port for plain HTTP server
302TEST_HTTP_PORT ?= 9935
303# port for the OCSP responder
304if ENABLE_OCSP_TEST
305OCSP_PORT ?= 9936
306OCSP_URI_TEMPLATE = ocsp_uri = http://$(TEST_HOST):$(OCSP_PORT)/ocsp/
307endif
308# maximum time to wait for MSVA startup (milliseconds)
309TEST_SERVICE_MAX_WAIT ?= 10000
310# wait loop time for MSVA startup (milliseconds)
311TEST_SERVICE_WAIT ?= 400
312
313AM_TESTS_ENVIRONMENT = export APACHE2=@APACHE2@; \
314        export AP_LIBEXECDIR=@AP_LIBEXECDIR@; \
315        export PYTHON="@PYTHON@"; \
316        export TEST_LOCK_WAIT="@TEST_LOCK_WAIT@"; \
317        export TEST_IP="@TEST_IP@"; \
318        export TEST_HOST="@TEST_HOST@"; \
319        export TEST_PORT="$(TEST_PORT)"; \
320        export MSVA_PORT="$(MSVA_PORT)"; \
321        export TEST_SERVICE_MAX_WAIT="$(TEST_SERVICE_MAX_WAIT)"; \
322        export TEST_SERVICE_WAIT="$(TEST_SERVICE_WAIT)"; \
323        export TEST_QUERY_TIMEOUT="@TEST_QUERY_TIMEOUT@"; \
324        export BACKEND_HOST="@TEST_HOST@"; \
325        export BACKEND_PORT="$(BACKEND_PORT)"; \
326        export TEST_HTTP_PORT="$(TEST_HTTP_PORT)"; \
327        export HTTP_CLI="@HTTP_CLI@";
328
329if HAVE_SOFTHSM
330AM_TESTS_ENVIRONMENT += export SOFTHSM="@SOFTHSM@"; \
331        export SOFTHSM_LIB="@SOFTHSM_LIB@";
332endif
333
334if ENABLE_OCSP_TEST
335AM_TESTS_ENVIRONMENT += export OPENSSL="@OPENSSL@"; \
336        export OCSP_PORT="$(OCSP_PORT)";
337endif
338
339if ENABLE_VALGRIND
340AM_TESTS_ENVIRONMENT += export VALGRIND="@VALGRIND@";
341endif
342
343if ENABLE_NETNS
344AM_TESTS_ENVIRONMENT += export UNSHARE="@UNSHARE@"; \
345        export USE_TEST_NAMESPACE=1;
346endif
347# Without flock tests must not run in parallel, and PID files are used
348# to prevent conflicts between server instances. Otherwise set lock
349# files for flock.
350if DISABLE_FLOCK
351AM_TESTS_ENVIRONMENT += export TEST_LOCK="apache2.pid"; \
352        export BACKEND_LOCK="backend.pid"; \
353        export OCSP_LOCK="ocsp.pid";
354.NOTPARALLEL:
355else
356AM_TESTS_ENVIRONMENT += export FLOCK="@FLOCK@"; \
357        export TEST_LOCK="$(test_lockfile)"; \
358        export BACKEND_LOCK="$(backend_lockfile)"; \
359        export OCSP_LOCK="$(ocsp_lockfile)";
360endif
361
362if ENABLE_COVERAGE
363AM_TESTS_ENVIRONMENT += export LLVM_PROFILE_FILE="$(coverage_raw_dir)/%p-%3m.profraw";
364
365outputs/coverage.profdata: $(coverage_raw_dir)/*.profraw
366        llvm-profdata merge -sparse $^ -o $@
367
368coverage/index.html: outputs/coverage.profdata
369        llvm-cov show ../src/.libs/mod_gnutls.so -instr-profile=$< -format=html $(srcdir)/../src/*.c $(srcdir)/../src/*.h $(srcdir)/../include/*.h -output-dir=$(dir $@)/
370
371coverage: coverage/index.html
372endif
373
374# Echo AM_TESTS_ENVIRONMENT. This can be useful for debugging, e.g. if
375# you want to manually run an Apache instance with Valgrind using the
376# same configuration as a test case.
377show-test-env: export TEST_ENV=$(AM_TESTS_ENVIRONMENT)
378show-test-env:
379        @echo "$${TEST_ENV}"
380
381# Build the test suite README as HTML if pandoc is available.
382if USE_PANDOC
383noinst_DATA = README.html
384MOSTLYCLEANFILES += $(noinst_DATA)
385%.html: %.md $(srcdir)/../doc/style.css
386        $(PANDOC) --css $(filter %.css,$^) --metadata pagetitle="$(<)" --self-contained -f markdown -o $@ $<
387endif
Note: See TracBrowser for help on using the repository browser.